Search in sources :

Example 16 with StateProofGraph

use of edu.cmu.ml.proppr.prove.wam.StateProofGraph in project ProPPR by TeamCohen.

the class SparseGraphPluginTest method testDegree.

@Test
public void testDegree() throws LogicProgramException {
    Query q = Query.parse("child(pam,X)");
    StateProofGraph pg = new StateProofGraph(q, apr, program, plugin);
    // minus 1 for reset
    assertEquals(3, pg.pgDegree(pg.getStartState()) - 1);
}
Also used : Query(edu.cmu.ml.proppr.prove.wam.Query) StateProofGraph(edu.cmu.ml.proppr.prove.wam.StateProofGraph) Test(org.junit.Test)

Example 17 with StateProofGraph

use of edu.cmu.ml.proppr.prove.wam.StateProofGraph in project ProPPR by TeamCohen.

the class SparseGraphPluginTest method testRowEnd.

@Test
public void testRowEnd() throws LogicProgramException {
    StateProofGraph pg = new StateProofGraph(Query.parse("sister(yvette,X)"), apr, program, plugin);
    // minus 1 for reset
    assertEquals("Yvette should have no sisters\n", 0, pg.pgDegree(pg.getStartState()) - 1);
    pg = new StateProofGraph(Query.parse("sister(theresa,X)"), apr, program, plugin);
    // minus 1 for reset
    assertEquals("Theresa should have 1 sister\n", 1, pg.pgDegree(pg.getStartState()) - 1);
}
Also used : StateProofGraph(edu.cmu.ml.proppr.prove.wam.StateProofGraph) Test(org.junit.Test)

Example 18 with StateProofGraph

use of edu.cmu.ml.proppr.prove.wam.StateProofGraph in project ProPPR by TeamCohen.

the class WeightedFeaturesTest method testAsFacts.

@Test
public void testAsFacts() throws IOException, LogicProgramException {
    APROptions apr = new APROptions();
    Prover p = new DprProver(apr);
    WamProgram program = WamBaseProgram.load(RULES);
    WamPlugin[] plugins = new WamPlugin[] { FactsPlugin.load(apr, LABELS, false), FactsPlugin.load(apr, WORDSFACTS, false) };
    Grounder grounder = new Grounder(apr, p, program, plugins);
    assertTrue(plugins[1].claim("hasWord#/3"));
    Query query = Query.parse("predict(p1,Y)");
    ProofGraph pg = new StateProofGraph(new InferenceExample(query, new Query[] { Query.parse("predict(p1,pos)") }, new Query[] { Query.parse("predict(p1,neg)") }), apr, new SimpleSymbolTable<Feature>(), program, plugins);
    GroundedExample ex = grounder.groundExample(p, pg);
    String serialized = grounder.serializeGroundedExample(pg, ex).replaceAll("\t", "\n");
    System.out.println(serialized);
    // hack
    assertTrue("Word weights must appear in ground graph", serialized.indexOf("0.9") > 0);
    assertTrue("Word weights must appear in ground graph", serialized.indexOf("0.1") > 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)

Aggregations

StateProofGraph (edu.cmu.ml.proppr.prove.wam.StateProofGraph)18 Query (edu.cmu.ml.proppr.prove.wam.Query)17 WamProgram (edu.cmu.ml.proppr.prove.wam.WamProgram)15 Test (org.junit.Test)15 Prover (edu.cmu.ml.proppr.prove.Prover)13 APROptions (edu.cmu.ml.proppr.util.APROptions)13 ProofGraph (edu.cmu.ml.proppr.prove.wam.ProofGraph)10 DprProver (edu.cmu.ml.proppr.prove.DprProver)9 StatusLogger (edu.cmu.ml.proppr.util.StatusLogger)9 File (java.io.File)9 GroundedExample (edu.cmu.ml.proppr.examples.GroundedExample)6 InferenceExample (edu.cmu.ml.proppr.examples.InferenceExample)6 Feature (edu.cmu.ml.proppr.prove.wam.Feature)6 Grounder (edu.cmu.ml.proppr.Grounder)5 ConstantArgument (edu.cmu.ml.proppr.prove.wam.ConstantArgument)4 Goal (edu.cmu.ml.proppr.prove.wam.Goal)4 Map (java.util.Map)4 DfsProver (edu.cmu.ml.proppr.prove.DfsProver)3 State (edu.cmu.ml.proppr.prove.wam.State)3 WamPlugin (edu.cmu.ml.proppr.prove.wam.plugins.WamPlugin)3