use of edu.cmu.ml.proppr.prove.wam.plugins.WamPlugin 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.prove.wam.plugins.WamPlugin 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.prove.wam.plugins.WamPlugin in project ProPPR by TeamCohen.
the class ProofGraph method addBuiltinPlugins.
private WamPlugin[] addBuiltinPlugins(WamPlugin... plugins) {
WamPlugin[] result = Arrays.copyOf(plugins, plugins.length + 1);
FilterPluginCollection filters = new FilterPluginCollection(this.apr);
result[plugins.length] = filters;
filters.register("neq/2", new PluginFunction() {
@Override
public boolean run(WamInterpreter wamInterp) throws LogicProgramException {
String arg1 = wamInterp.getConstantArg(2, 1);
String arg2 = wamInterp.getConstantArg(2, 2);
if (arg1 == null || arg2 == null)
throw new LogicProgramException("cannot call neq/2 unless both variables are bound");
return arg1 != arg2;
}
});
return result;
}
Aggregations