protected override bool adviceAnswer(string question, bool isBasedOnContext, NodeReference correctAnswerNode, IEnumerable <NodeReference> context) { var parsedQuestion = UtteranceParser.Parse(question); var covers = FeatureCover.GetFeatureCovers(parsedQuestion, Graph); //setup interpretation generator var factory = new InterpretationsFactory(parsedQuestion, isBasedOnContext, correctAnswerNode); var contextPool = new ContextPool(Graph); contextPool.Insert(context.ToArray()); var generator = new InterpretationGenerator(covers, factory, contextPool, this); //!!!!!!!!!!!!!!TODOOOOOOOOOOOOO!!!!!!!!!!!!!! //We have to check compatibility of the generator with all known interpretations _interpretationGenerators.Add(generator); //register covers according to its feature keys foreach (var cover in generator.Covers) { List <Tuple <InterpretationGenerator, FeatureCover> > generators; if (!_keyToGeneratorCovers.TryGetValue(cover.FeatureKey, out generators)) { _keyToGeneratorCovers[cover.FeatureKey] = generators = new List <Tuple <InterpretationGenerator, FeatureCover> >(); } generators.Add(Tuple.Create(generator, cover)); } //TODO decide whether it would be benefitial to report that //the advice is taken into account, however we don't believe it much. //TODO initialize with first interpretation? return(true); }
private bool isCompatibleInterpretation(Interpretation instantiatedInterpretation, InterpretationGenerator generator) { var contextPool = generator.CreateContextPoolCopy(); foreach (var rule in instantiatedInterpretation.Rules) { rule.Execute(contextPool); } return(generator.ContainsCorrectAnswer(contextPool)); }