private ParsedUtterance substitute(ParsedUtterance pattern, ParsedUtterance utterance) { var patternNodes = InputState.QA.GetPatternNodes(pattern); var utteranceNodes = InputState.QA.GetRelatedNodes(utterance).ToArray(); if (patternNodes.Count != utteranceNodes.Length) { //semantic equivalence is missing - we won't allow equivalence question return(null); } //substitute every word in pattern, according to utterance var substitutions = HeuristicQAModule.GetSubstitutions(utteranceNodes, patternNodes, InputState.QA.Graph); var substitutedWords = new List <string>(); foreach (var patternWord in pattern.Words) { var patternNode = InputState.QA.Graph.GetNode(patternWord); NodeReference substitutedNode; if (!substitutions.TryGetValue(patternNode, out substitutedNode)) { //there is no substitution - by default we take node from pattern substitutedNode = patternNode; } substitutedWords.Add(substitutedNode.Data); } return(ParsedUtterance.From(substitutedWords)); }
internal DialogState(HeuristicQAModule qa) { _propertyToValue = new Dictionary <object, object>(); _qa.SetValue(_propertyToValue, qa); }
public StateContext(HeuristicQAModule module) { QuestionAnsweringModule = module; CallStorage = module.Storage; Graph = module.Graph; }