Пример #1
0
        static void testProlog3()
        {
            // we can  do a graph of connected kb's
            // the query is from a point in the graph and the system gathers the KB
            // Wonder if we "logicRank" the graph in someway so we inference over what's relevant
            // Also what kind of connected graphs can we concoct ?
            // Maybe we want to have prove walk the KB graph?
            // Should the KB be constructed depth-first or breath first ?
            //  (It may not matter so long as the items of a given predicate appear in one MT)
            // probably should have classic optomizations like first term indexing for speed
            // Should work on built-ins. (Done except for eval) (Dmiles did eval)

            prologEngine.connectMT("sense1MT", "baseKB");
            prologEngine.connectMT("sense2MT", "baseKB");
            prologEngine.connectMT("spindleMT", "sense1MT");
            prologEngine.connectMT("spindleMT", "sense2MT");
            prologEngine.insertKB("canSense(X):-sense(X).\n", "baseKB");
            prologEngine.appendKB("genls(A,B):-genls(A,X),genls(X,B).\n", "baseKB");
            prologEngine.appendKB("isa(A,B):-isa(A,X),genls(X,B).\n", "baseKB");

            prologEngine.insertKB("sense(dog).\nsense(cat).\n", "sense1MT");
            prologEngine.insertKB("sense(boy).\nsense(girl).\n", "sense2MT");
            prologEngine.appendKB("isa(john,boy).\ngenls(boy,human).\ngenls(human,mammal).\n", "sense2MT");
            prologEngine.askQuery("canSense(WHAT1)", "sense1MT");
            prologEngine.askQuery("canSense(WHAT2)", "sense2MT");
            prologEngine.askQuery("canSense(WHAT3)", "spindleMT");
            prologEngine.askQuery("isa(john,JOHN_IS)", "spindleMT");
            //prologEngine.KBGraph.PrintToConsole();
        }
Пример #2
0
        public void GenRulesFromMt(SIProlog pEngine, string sourceMt, string destMt, string targetAttribute)
        {
            MtDataSource samples = new MtDataSource(pEngine, sourceMt);

            TreeAttributeCollection attributes = samples.GetValidAttributeCollection(targetAttribute);

            DecisionTree id3  = new DecisionTree();
            TreeNode     root = id3.mountTree(samples, targetAttribute, attributes);

            string prologCode = PrologPrintNode(root, "", targetAttribute);

            pEngine.insertKB(prologCode, destMt);
            string codeSummary = PrintNode(root, "") + Environment.NewLine + PrologPrintNode(root, "", "result");

            Console.WriteLine(codeSummary);
        }