Ejemplo n.º 1
0
        internal void Add(InterpretationsFactory interpretationsFactory, IEnumerable <FeatureCover> covers)
        {
            //create simple mapping which doesn't need expensive computation
            var entry = new OptimizedEntry(this, interpretationsFactory, covers);

            registerEntry(entry);
        }
        internal InterpretationGenerator(IEnumerable <FeatureCover> covers, InterpretationsFactory interpretations, ContextPool context, ProbabilisticQAModule owner)
        {
            var coversCopy = covers.ToArray();

            if (coversCopy.Length == 0)
            {
                throw new NotSupportedException("Cannot create InterpretationGenerator without feature covers");
            }

            Covers = coversCopy;

            _interpretations = interpretations;
            _context         = context.Clone();
            _owner           = owner;
            _topicSelector   = interpretations.GetTopicSelector(owner.Graph);
            if (_topicSelector.MoveNext())
            {
                //initialize constraint selector
                _currentConstraintSelector = interpretations.GetConstraintSelector(owner.Graph, _topicSelector.SelectedNodes);
            }
        }
Ejemplo n.º 3
0
        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);
        }