use of edu.cmu.ml.proppr.util.APROptions in project ProPPR by TeamCohen.
the class GrounderTest method noNegativeExamplesTest.
@Test
public void noNegativeExamplesTest() throws IOException, LogicProgramException {
APROptions apr = new APROptions();
WamProgram program = WamBaseProgram.load(new File(RULES));
WamPlugin[] plugins = new WamPlugin[] { FactsPlugin.load(apr, new File(FACTS), false) };
Prover p = new DprProver(apr);
Grounder grounder = new Grounder(apr, p, program, plugins);
InferenceExample ix = new InferenceExample(Query.parse("predict(howard,Y)"), new Query[] { Query.parse("predict(howard,bird)") }, new Query[] {});
GroundedExample ex = grounder.groundExample(p, ix);
makeAssertions(ex, "dpr+", 10, 23, 1.0, 1, "7", 0, "");
ix = new InferenceExample(Query.parse("predict(howard,Y)"), new Query[] { Query.parse("predict(howard,bird)") }, new Query[] {});
ProofGraph pg = p.makeProofGraph(ix, apr, program, plugins);
State pos = null;
Map<State, Double> sols = p.prove(pg, new StatusLogger());
System.out.println(pg.serialize(ex));
}
use of edu.cmu.ml.proppr.util.APROptions in project ProPPR by TeamCohen.
the class GrounderTest method unboundLabelsTest.
@Test(expected = IllegalArgumentException.class)
public void unboundLabelsTest() throws IOException, LogicProgramException {
APROptions apr = new APROptions();
WamProgram program = WamBaseProgram.load(new File(RULES));
WamPlugin[] plugins = new WamPlugin[] { FactsPlugin.load(apr, new File(FACTS), false) };
Prover p = new DprProver(apr);
Grounder grounder = new Grounder(apr, p, program, plugins);
InferenceExample ix = new InferenceExample(Query.parse("predict(howard,Bird)"), new Query[] { Query.parse("predict(howard,Bird)") }, new Query[] {});
GroundedExample ex = grounder.groundExample(p, ix);
}
use of edu.cmu.ml.proppr.util.APROptions in project ProPPR by TeamCohen.
the class DprProverTest method setup.
@Override
public void setup() throws IOException {
super.setup();
this.prover = new DprProver(new APROptions(new String[] { "eps=.00001", "alph=.03" }));
// Logger.getLogger(DprProver.class).setLevel(Level.DEBUG);
}
use of edu.cmu.ml.proppr.util.APROptions in project ProPPR by TeamCohen.
the class EqualityTest method test.
@Test
public void test() throws LogicProgramException, IOException {
WamProgram program = WamBaseProgram.load(new File(EQUALITY_PROGRAM));
Prover prover = new DprProver();
ProofGraph moral = new StateProofGraph(Query.parse("moral(X)"), new APROptions(), program);
Collection<Query> bobs = prover.solvedQueries(moral, new StatusLogger()).keySet();
// Map<State,Double> ans = prover.prove(moral);
// ArrayList<Query> bobs = new ArrayList<Query>();
// for (Map.Entry<State,Double> e : ans.entrySet()) {
// if (e.getKey().isCompleted()) bobs.add(moral.fill(e.getKey()));
// }
assertEquals(1, bobs.size());
Query bob = bobs.iterator().next();
assertEquals(1, bob.getRhs().length);
assertEquals("Answer should be bob", "bob", bob.getRhs()[0].getArg(0).getName());
}
Aggregations