Search in sources :

Example 1 with PluginFunction

use of edu.cmu.ml.proppr.prove.wam.plugins.builtin.PluginFunction 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;
}
Also used : PluginFunction(edu.cmu.ml.proppr.prove.wam.plugins.builtin.PluginFunction) WamPlugin(edu.cmu.ml.proppr.prove.wam.plugins.WamPlugin) FilterPluginCollection(edu.cmu.ml.proppr.prove.wam.plugins.builtin.FilterPluginCollection)

Aggregations

WamPlugin (edu.cmu.ml.proppr.prove.wam.plugins.WamPlugin)1 FilterPluginCollection (edu.cmu.ml.proppr.prove.wam.plugins.builtin.FilterPluginCollection)1 PluginFunction (edu.cmu.ml.proppr.prove.wam.plugins.builtin.PluginFunction)1