Search in sources :

Example 21 with WamProgram

use of edu.cmu.ml.proppr.prove.wam.WamProgram 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

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