Search in sources :

Example 16 with APROptions

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));
}
Also used : StatusLogger(edu.cmu.ml.proppr.util.StatusLogger) 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) IdDprProver(edu.cmu.ml.proppr.prove.IdDprProver) PprProver(edu.cmu.ml.proppr.prove.PprProver) DprProver(edu.cmu.ml.proppr.prove.DprProver) IdPprProver(edu.cmu.ml.proppr.prove.IdPprProver) Prover(edu.cmu.ml.proppr.prove.Prover) IdDprProver(edu.cmu.ml.proppr.prove.IdDprProver) DprProver(edu.cmu.ml.proppr.prove.DprProver) WamProgram(edu.cmu.ml.proppr.prove.wam.WamProgram) InferenceExample(edu.cmu.ml.proppr.examples.InferenceExample) WamPlugin(edu.cmu.ml.proppr.prove.wam.plugins.WamPlugin) State(edu.cmu.ml.proppr.prove.wam.State) APROptions(edu.cmu.ml.proppr.util.APROptions) File(java.io.File) Test(org.junit.Test)

Example 17 with APROptions

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);
}
Also used : WamPlugin(edu.cmu.ml.proppr.prove.wam.plugins.WamPlugin) GroundedExample(edu.cmu.ml.proppr.examples.GroundedExample) IdDprProver(edu.cmu.ml.proppr.prove.IdDprProver) PprProver(edu.cmu.ml.proppr.prove.PprProver) DprProver(edu.cmu.ml.proppr.prove.DprProver) IdPprProver(edu.cmu.ml.proppr.prove.IdPprProver) Prover(edu.cmu.ml.proppr.prove.Prover) IdDprProver(edu.cmu.ml.proppr.prove.IdDprProver) DprProver(edu.cmu.ml.proppr.prove.DprProver) WamProgram(edu.cmu.ml.proppr.prove.wam.WamProgram) APROptions(edu.cmu.ml.proppr.util.APROptions) File(java.io.File) InferenceExample(edu.cmu.ml.proppr.examples.InferenceExample) Test(org.junit.Test)

Example 18 with APROptions

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);
}
Also used : DprProver(edu.cmu.ml.proppr.prove.DprProver) APROptions(edu.cmu.ml.proppr.util.APROptions)

Example 19 with APROptions

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());
}
Also used : 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) 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) APROptions(edu.cmu.ml.proppr.util.APROptions) File(java.io.File) Test(org.junit.Test)

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