コード例 #1
0
        internal bool MoveNext()
        {
            _rules.Clear();
            _selectedNodes.Clear();


            var nextSegment = findNextSegment();

            if (nextSegment == null)
            {
                //there are no more available segments.
                return(false);
            }

            _factory.Enqueue(nextSegment);

            _rules.AddRange(createRule(nextSegment));
            _selectedNodes.UnionWith(findSelectedNodes(nextSegment));


            ConsoleServices.Print("NEW TOPIC", Rules);
            ConsoleServices.PrintEmptyLine();

            return(true);
        }
コード例 #2
0
        private void addRule(ConstraintPoolRule[] rules, HashSet <NodeReference> remainingNodes)
        {
            var isCompleteRule = remainingNodes.Count == 0;

            if (isCompleteRule)
            {
                //complete rules don't need more extending
                _completeRules.Add(rules);
            }
            else
            {
                //rule is incomplete
                _incompleteRuleSequence.Add(rules);
                _remainingNodes.Add(remainingNodes);
            }

            ConsoleServices.Print("RULES", rules, remainingNodes);
            ConsoleServices.PrintEmptyLine();
        }
コード例 #3
0
        private static void RuleQuestionTest(string dbPath)
        {
            var loader    = loadDB(dbPath);
            var graph     = new ComposedGraph(loader.DataLayer);
            var generator = new StructuredInterpretationGenerator(graph);

            var denotation1 = graph.GetNode("Barack Obama");
            var q1          = "Who is United States of America president?";

            var denotation2 = graph.GetNode("Vladimir Putin");
            var q2          = "Who is Russia president?";

            var q3          = "Who is Czech republic president?";
            var denotation3 = graph.GetNode("Miloš Zeman");

            generator.AdviceAnswer(q1, denotation1);
            generator.AdviceAnswer(q2, denotation2);
            generator.Optimize(5000);

            var interpretations = new List <Ranked <StructuredInterpretation> >();

            foreach (var evidence in generator.GetEvidences(q3))
            {
                foreach (var interpretation in evidence.AvailableRankedInterpretations)
                {
                    interpretations.Add(interpretation);
                }
            }

            interpretations.Sort((a, b) => a.Rank.CompareTo(b.Rank));
            foreach (var interpretation in interpretations)
            {
                var answer = generator.Evaluate(q3, interpretation.Value);
                ConsoleServices.Print(interpretation);
                ConsoleServices.Print(answer);
                ConsoleServices.PrintEmptyLine();
            }

            var qGenerator = new QuestionGenerator(generator);

            //var questions = Generator.FindDistinguishingNodeQuestions();
            throw new NotImplementedException();
        }