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);
}
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);
}
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);
}
Aggregations