Пример #1
0
        /// <summary>
        /// Gets evidence for given question.
        /// </summary>
        /// <param name="question">The question.</param>
        /// <returns>The evidence.</returns>
        private QuestionEvidence getQuestionEvidence(FeatureCover question)
        {
            QuestionEvidence evidence;

            if (!_questions.TryGetValue(question.OriginalUtterance, out evidence))
            {
                _questions[question.OriginalUtterance] = evidence = new QuestionEvidence(question);
            }
            return(evidence);
        }
Пример #2
0
        private IEnumerable <NodeReference> evaluate(StructuredInterpretation interpretation, QuestionEvidence question)
        {
            HashSet <NodeReference> inputSet = null;

            for (var i = 0; i < _generalFeatureNodes.Length; ++i)
            {
                var generalNode = _generalFeatureNodes[i];
                var featureNode = question.GetFeatureNode(generalNode, Graph);
                var constraint  = interpretation.GetGeneralConstraint(i);
                if (inputSet == null)
                {
                    inputSet = constraint.FindSet(featureNode, Graph);
                }
                else
                {
                    inputSet.IntersectWith(constraint.FindSet(featureNode, Graph));
                }
            }

            var pool = new ContextPool(Graph);

            pool.Insert(inputSet.ToArray());
            foreach (var distinguishConstraint in interpretation.DisambiguationConstraints)
            {
                distinguishConstraint.Execute(pool);
            }
            return(pool.ActiveNodes);
        }