Search in sources :

Example 6 with APROptions

use of edu.cmu.ml.proppr.util.APROptions in project ProPPR by TeamCohen.

the class DuplicateSignatureRuleTest method test2.

@Test
public void test2() throws LogicProgramException, IOException {
    APROptions apr = new APROptions("depth=10");
    WamProgram program = WamBaseProgram.load(new File(PROGRAM));
    ProofGraph pg = new StateProofGraph(Query.parse("canExit(steve,X)"), apr, program);
    Prover p = new TracingDfsProver(apr);
    Map<Query, Double> result = p.solvedQueries(pg, new StatusLogger());
    for (Map.Entry<Query, Double> e : result.entrySet()) {
        System.out.println(e.getValue() + "\t" + e.getKey());
        assertEquals("Steve not allowed to exit " + e.getKey() + "\n", "canExit(steve,kitchen).", e.getKey().toString());
    }
}
Also used : TracingDfsProver(edu.cmu.ml.proppr.prove.TracingDfsProver) StatusLogger(edu.cmu.ml.proppr.util.StatusLogger) Query(edu.cmu.ml.proppr.prove.wam.Query) StateProofGraph(edu.cmu.ml.proppr.prove.wam.StateProofGraph) ProofGraph(edu.cmu.ml.proppr.prove.wam.ProofGraph) Prover(edu.cmu.ml.proppr.prove.Prover) TracingDfsProver(edu.cmu.ml.proppr.prove.TracingDfsProver) WamProgram(edu.cmu.ml.proppr.prove.wam.WamProgram) StateProofGraph(edu.cmu.ml.proppr.prove.wam.StateProofGraph) APROptions(edu.cmu.ml.proppr.util.APROptions) File(java.io.File) Map(java.util.Map) Test(org.junit.Test)

Example 7 with APROptions

use of edu.cmu.ml.proppr.util.APROptions in project ProPPR by TeamCohen.

the class PathDprProverTest method test.

@Test
public void test() throws IOException, LogicProgramException {
    APROptions apr = new APROptions();
    apr.epsilon = 1e-5;
    apr.alpha = 0.01;
    WamProgram program = WamBaseProgram.load(new File(RULES));
    WamPlugin[] plugins = new WamPlugin[] { SparseGraphPlugin.load(apr, new File(SparseGraphPluginTest.PLUGIN)) };
    PathDprProver p = new PathDprProver(apr);
    Query query = Query.parse("kids(bette,Y)");
    StateProofGraph pg = new StateProofGraph(query, apr, program, plugins);
    p.prove(pg, new StatusLogger());
}
Also used : StatusLogger(edu.cmu.ml.proppr.util.StatusLogger) WamPlugin(edu.cmu.ml.proppr.prove.wam.plugins.WamPlugin) Query(edu.cmu.ml.proppr.prove.wam.Query) WamProgram(edu.cmu.ml.proppr.prove.wam.WamProgram) StateProofGraph(edu.cmu.ml.proppr.prove.wam.StateProofGraph) APROptions(edu.cmu.ml.proppr.util.APROptions) File(java.io.File) Test(org.junit.Test) GrounderTest(edu.cmu.ml.proppr.GrounderTest) SparseGraphPluginTest(edu.cmu.ml.proppr.prove.wam.plugins.SparseGraphPluginTest)

Example 8 with APROptions

use of edu.cmu.ml.proppr.util.APROptions in project ProPPR by TeamCohen.

the class WeightedRulesTest method test.

@Test
public void test() throws IOException, LogicProgramException {
    APROptions apr = new APROptions();
    Prover p = new DprProver(apr);
    WamProgram program = WamBaseProgram.load(RULES);
    WamPlugin[] plugins = new WamPlugin[] { FactsPlugin.load(apr, FACTS, false) };
    Grounder grounder = new Grounder(apr, p, program, plugins);
    assertTrue(plugins[0].claim("ruleWeight#/2"));
    Query query = Query.parse("shoppingList(X)");
    ProofGraph pg = new StateProofGraph(new InferenceExample(query, new Query[] { Query.parse("shoppingList(kidney_beans)") }, new Query[] { Query.parse("shoppingList(cinnamon)") }), apr, new SimpleSymbolTable<Feature>(), program, plugins);
    //		Map<String,Double> m = p.solutions(pg);
    //		System.out.println(Dictionary.buildString(m, new StringBuilder(), "\n").toString());
    GroundedExample ex = grounder.groundExample(p, pg);
    ex.getGraph().serialize();
    String serialized = grounder.serializeGroundedExample(pg, ex).replaceAll("\t", "\n");
    System.out.println(serialized);
    assertTrue("Rule weights must appear in ground graph (2.0)", serialized.indexOf("2.0") >= 0);
    assertTrue("Rule weights must appear in ground graph (3.0)", serialized.indexOf("3.0") >= 0);
}
Also used : GroundedExample(edu.cmu.ml.proppr.examples.GroundedExample) Query(edu.cmu.ml.proppr.prove.wam.Query) StateProofGraph(edu.cmu.ml.proppr.prove.wam.StateProofGraph) ProofGraph(edu.cmu.ml.proppr.prove.wam.ProofGraph) DprProver(edu.cmu.ml.proppr.prove.DprProver) Prover(edu.cmu.ml.proppr.prove.Prover) DprProver(edu.cmu.ml.proppr.prove.DprProver) WamProgram(edu.cmu.ml.proppr.prove.wam.WamProgram) StateProofGraph(edu.cmu.ml.proppr.prove.wam.StateProofGraph) Feature(edu.cmu.ml.proppr.prove.wam.Feature) InferenceExample(edu.cmu.ml.proppr.examples.InferenceExample) APROptions(edu.cmu.ml.proppr.util.APROptions) Grounder(edu.cmu.ml.proppr.Grounder) Test(org.junit.Test)

Example 9 with APROptions

use of edu.cmu.ml.proppr.util.APROptions in project ProPPR by TeamCohen.

the class TracingDfsProverTest method setup.

@Override
public void setup() throws IOException {
    super.setup();
    TracingDfsProver p = new TracingDfsProver(new APROptions());
    this.prover = p;
}
Also used : APROptions(edu.cmu.ml.proppr.util.APROptions)

Example 10 with APROptions

use of edu.cmu.ml.proppr.util.APROptions in project ProPPR by TeamCohen.

the class FactsPluginTest method test.

@Test
public void test() throws LogicProgramException {
    APROptions apr = new APROptions();
    FactsPlugin p = FactsPlugin.load(apr, new File(GrounderTest.FACTS), false);
    WamProgram program = new WamBaseProgram();
    Query q = Query.parse("validClass(X)");
    StateProofGraph pg = new StateProofGraph(q, apr, program, p);
    Prover prover = new DprProver();
    Map<String, Double> sols = prover.solutions(pg, new StatusLogger());
    assertEquals(2, sols.size());
}
Also used : StatusLogger(edu.cmu.ml.proppr.util.StatusLogger) Query(edu.cmu.ml.proppr.prove.wam.Query) DprProver(edu.cmu.ml.proppr.prove.DprProver) Prover(edu.cmu.ml.proppr.prove.Prover) DprProver(edu.cmu.ml.proppr.prove.DprProver) WamProgram(edu.cmu.ml.proppr.prove.wam.WamProgram) StateProofGraph(edu.cmu.ml.proppr.prove.wam.StateProofGraph) FactsPlugin(edu.cmu.ml.proppr.prove.wam.plugins.FactsPlugin) APROptions(edu.cmu.ml.proppr.util.APROptions) File(java.io.File) WamBaseProgram(edu.cmu.ml.proppr.prove.wam.WamBaseProgram) Test(org.junit.Test) GrounderTest(edu.cmu.ml.proppr.GrounderTest)

Aggregations

APROptions (edu.cmu.ml.proppr.util.APROptions)19 WamProgram (edu.cmu.ml.proppr.prove.wam.WamProgram)15 Test (org.junit.Test)15 Query (edu.cmu.ml.proppr.prove.wam.Query)14 StateProofGraph (edu.cmu.ml.proppr.prove.wam.StateProofGraph)13 Prover (edu.cmu.ml.proppr.prove.Prover)12 DprProver (edu.cmu.ml.proppr.prove.DprProver)11 File (java.io.File)10 GroundedExample (edu.cmu.ml.proppr.examples.GroundedExample)8 InferenceExample (edu.cmu.ml.proppr.examples.InferenceExample)8 ProofGraph (edu.cmu.ml.proppr.prove.wam.ProofGraph)8 StatusLogger (edu.cmu.ml.proppr.util.StatusLogger)7 WamPlugin (edu.cmu.ml.proppr.prove.wam.plugins.WamPlugin)6 Feature (edu.cmu.ml.proppr.prove.wam.Feature)5 Grounder (edu.cmu.ml.proppr.Grounder)4 State (edu.cmu.ml.proppr.prove.wam.State)3 GrounderTest (edu.cmu.ml.proppr.GrounderTest)2 IdDprProver (edu.cmu.ml.proppr.prove.IdDprProver)2 IdPprProver (edu.cmu.ml.proppr.prove.IdPprProver)2 PprProver (edu.cmu.ml.proppr.prove.PprProver)2