Esempio n. 1
0
 internal void LinkEntityValueToConcept(EntityValue entityValue, IList <string> conceptIds)
 {
     foreach (var conceptId in conceptIds)
     {
         if (Concepts.ContainsKey(conceptId))
         {
             var concept = Concepts[conceptId];
             entityValue.AddConcept(concept);
             concept.AddEntityValueReference(entityValue);
         }
         else
         {
             LogMessage(entityValue.LineNumber, MessageType.Info, "Entity value " + entityValue.Entity.Name + " > \"" + entityValue.Name + "\" => (warning) concept reference : " + conceptId + " (a conflicting concept with the same canonical value but a different id may have been defined before)");
         }
     }
     if (Concepts.ContainsKey(entityValue.CanonicalValue))
     {
         var concept = Concepts[entityValue.CanonicalValue];
         if (entityValue.Concepts == null || !entityValue.Concepts.Contains(concept))
         {
             entityValue.AddConcept(concept);
             concept.AddEntityValueReference(entityValue);
         }
     }
 }
 public EntityValueMatch(string textReplacedWithConcepts, int startIndex, int stopIndex, EntityValue entityValue)
 {
     TextReplacedWithConcepts = textReplacedWithConcepts;
     StartIndex  = startIndex;
     StopIndex   = stopIndex;
     EntityValue = entityValue;
 }
 internal void AddEntityValueReference(EntityValue entityValue)
 {
     if (EntityValueReferences == null)
     {
         EntityValueReferences = new List <EntityValue>();
     }
     EntityValueReferences.Add(entityValue);
 }
Esempio n. 4
0
 public void SetVariableAndEntityValue(DialogVariable variable, EntityValue entityValue)
 {
     Variable = variable;
     if (entityValue != null)
     {
         Type        = DialogConditionType.EntityValueCondition;
         Entity      = entityValue.Entity;
         EntityValue = entityValue;
     }
 }
Esempio n. 5
0
        internal void LinkDialogVariableConditionToDialogVariableAndEntityValue(DialogNode dialogNode, DialogVariableCondition variableCondition, DialogVariablesSimulator dialogVariables)
        {
            if (String.IsNullOrEmpty(variableCondition.VariableName))
            {
                return;
            }

            DialogVariable variable    = null;
            EntityValue    entityValue = null;

            if (!Variables.ContainsKey(variableCondition.VariableName))
            {
                LogMessage(dialogNode.LineNumber, MessageType.InvalidReference, "Variable condition references undefined variable name : \"" + variableCondition.VariableName + "\"");
            }
            else
            {
                variable = Variables[variableCondition.VariableName];
                variable.AddDialogNodeReference(dialogNode, VariableReferenceType.Read);

                if (variableCondition.Comparison != ConditionComparison.HasValue && !String.IsNullOrEmpty(variableCondition.Value))
                {
                    var entity = dialogVariables.TryGetEntityFromVariable(variable);
                    if (entity != null)
                    {
                        entityValue = entity.TryGetEntityValueFromName(variableCondition.Value);
                        if (entityValue == null)
                        {
                            var message = "Variable condition references undefined entity value name \"" + variableCondition.Value + "\" for entity " + entity.Name;
                            var suggestedEntityValue = entity.SuggestEntityValueFromName(variableCondition.Value, Entities.Values);
                            if (suggestedEntityValue != null)
                            {
                                if (suggestedEntityValue.Entity == entity)
                                {
                                    message += ", you may want to replace this name with \"" + suggestedEntityValue.Name + "\" (defined line " + suggestedEntityValue.LineNumber + ")";
                                }
                                else
                                {
                                    message += ", you may want to move this condition under another entity \"" + suggestedEntityValue.Entity.Name + "\" with value \"" + suggestedEntityValue.Name + "\" (defined line " + suggestedEntityValue.LineNumber + ")";
                                }
                            }
                            LogMessage(dialogNode.LineNumber, MessageType.InvalidReference, message);
                        }
                        else
                        {
                            entityValue.AddDialogNodeReference(dialogNode);
                        }
                    }
                }
            }
            variableCondition.SetVariableAndEntityValue(variable, entityValue);
        }
 public EntityValue TryGetEntityValueFromConcept(string conceptCanonicalValue)
 {
     if (EntityValueFromConceptDictionary == null)
     {
         return(null);
     }
     else
     {
         EntityValue entityValue = null;
         if (EntityValueFromConceptDictionary.TryGetValue(conceptCanonicalValue, out entityValue))
         {
             return(entityValue);
         }
         else
         {
             return(null);
         }
     }
 }
 public EntityValue TryGetEntityValue(string canonicalValue)
 {
     if (EntityValuesDictionary == null)
     {
         return(null);
     }
     else
     {
         EntityValue entityValue = null;
         if (EntityValuesDictionary.TryGetValue(canonicalValue, out entityValue))
         {
             return(entityValue);
         }
         else
         {
             return(null);
         }
     }
 }
 public EntityValue TryGetEntityValueFromName(string name)
 {
     if (EntityValueNamesDictionary == null)
     {
         return(null);
     }
     else
     {
         EntityValue entityValue = null;
         if (EntityValueNamesDictionary.TryGetValue(name, out entityValue))
         {
             return(entityValue);
         }
         else
         {
             return(null);
         }
     }
 }
Esempio n. 9
0
 public DisambiguationOption(string text, EntityValue entityValue)
 {
     Text        = text;
     EntityValue = entityValue;
 }
 internal void AddEntityValue(EntityValue entityValue, IMessageCollector errors)
 {
     Values.Add(entityValue);
 }
 public EntityValueProbability(int distance, EntityValue entityValue)
 {
     this.distance    = distance;
     this.entityValue = entityValue;
 }