use of edu.cmu.ml.proppr.prove.wam.Query 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());
}
use of edu.cmu.ml.proppr.prove.wam.Query 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.Query 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