/** * Returns a derivations model. The rule reasoners typically create a * graph containing those triples added to the base graph due to rule firings. * In some applications it can useful to be able to access those deductions * directly, without seeing the raw data which triggered them. In particular, * this allows the forward rules to be used as if they were rewrite transformation * rules. * @return the deductions model, if relevant for this class of inference * engine or null if not. */ @Override public Model getDeductionsModel() { Graph deductionsGraph = getInfGraph().getDeductionsGraph(); if (deductionsGraph != null) { if (deductionsModel == null || (deductionsModel.getGraph() != deductionsGraph) ) { deductionsModel = new ModelCom(deductionsGraph); } } return deductionsModel; }
/** * Returns a derivations model. The rule reasoners typically create a * graph containing those triples added to the base graph due to rule firings. * In some applications it can useful to be able to access those deductions * directly, without seeing the raw data which triggered them. In particular, * this allows the forward rules to be used as if they were rewrite transformation * rules. * @return the deductions model, if relevant for this class of inference * engine or null if not. */ @Override public Model getDeductionsModel() { Graph deductionsGraph = getInfGraph().getDeductionsGraph(); if (deductionsGraph != null) { if (deductionsModel == null || (deductionsModel.getGraph() != deductionsGraph) ) { deductionsModel = new ModelCom(deductionsGraph); } } return deductionsModel; }
/** * <p>Returns a derivations model. The rule reasoners typically create a * graph containing those triples added to the base graph due to rule firings. * In some applications it can useful to be able to access those deductions * directly, without seeing the raw data which triggered them. In particular, * this allows the forward rules to be used as if they were rewrite transformation * rules.</p> * * @return The derivations model, if one is defined, or else null */ @Override public Model getDeductionsModel() { if (m_deductionsModel == null) { InfGraph infGraph = getInfGraph(); if (infGraph != null) { Graph deductionsGraph = infGraph.getDeductionsGraph(); if (deductionsGraph != null) { m_deductionsModel = ModelFactory.createModelForGraph( deductionsGraph ); } } } else { // ensure that the cached model sees the updated changes from the // underlying reasoner graph getInfGraph().prepare(); } return m_deductionsModel; }
/** * <p>Returns a derivations model. The rule reasoners typically create a * graph containing those triples added to the base graph due to rule firings. * In some applications it can useful to be able to access those deductions * directly, without seeing the raw data which triggered them. In particular, * this allows the forward rules to be used as if they were rewrite transformation * rules.</p> * * @return The derivations model, if one is defined, or else null */ @Override public Model getDeductionsModel() { if (m_deductionsModel == null) { InfGraph infGraph = getInfGraph(); if (infGraph != null) { Graph deductionsGraph = infGraph.getDeductionsGraph(); if (deductionsGraph != null) { m_deductionsModel = ModelFactory.createModelForGraph( deductionsGraph ); } } } else { // ensure that the cached model sees the updated changes from the // underlying reasoner graph getInfGraph().prepare(); } return m_deductionsModel; }
InfGraph inf = context.getGraph(); Graph raw = inf.getRawGraph(); Graph deductions = inf.getDeductionsGraph(); for (int i = 0; i < length; i++) { Node clauseN = getArg(i, args, context);
InfGraph inf = context.getGraph(); Graph raw = inf.getRawGraph(); Graph deductions = inf.getDeductionsGraph(); for (int i = 0; i < length; i++) { Node clauseN = getArg(i, args, context);
/** * Test regex handling of null groups */ public void testRegexNulls() { String rules = "[r2: (?x p ?y) regex(?y, '((Boys)|(Girls))(.*)', ?m1, ?m2, ?m3, ?m4) -> (?x q ?m2) (?x r ?m3) (?x s ?m4) ] \n" + ""; Graph data = Factory.createGraphMem(); data.add(new Triple(n1, p, NodeFactory.createLiteral("Girls44")) ); InfGraph infgraph = createInfGraph(rules, data); infgraph.prepare(); TestUtil.assertIteratorValues(this, infgraph.getDeductionsGraph().find(null, null, null), new Triple[] { new Triple(n1, q, NodeFactory.createLiteral("")), new Triple(n1, r, NodeFactory.createLiteral("Girls")), new Triple(n1, s, NodeFactory.createLiteral("44")), }); }
/** * Test regex handling of null groups */ public void testRegexNulls() { String rules = "[r2: (?x p ?y) regex(?y, '((Boys)|(Girls))(.*)', ?m1, ?m2, ?m3, ?m4) -> (?x q ?m2) (?x r ?m3) (?x s ?m4) ] \n" + ""; Graph data = Factory.createGraphMem(); data.add(new Triple(n1, p, NodeFactory.createLiteral("Girls44")) ); InfGraph infgraph = createInfGraph(rules, data); infgraph.prepare(); TestUtil.assertIteratorValues(this, infgraph.getDeductionsGraph().find(null, null, null), new Triple[] { new Triple(n1, q, NodeFactory.createLiteral("")), new Triple(n1, r, NodeFactory.createLiteral("Girls")), new Triple(n1, s, NodeFactory.createLiteral("44")), }); }
infgraph = createInfGraph(rules); infgraph.prepare(); Graph result = infgraph.getDeductionsGraph(); assertEquals(1, result.size()); Triple tr = result.find(null, null, null).next();
infgraph = createInfGraph(rules); infgraph.prepare(); Graph result = infgraph.getDeductionsGraph(); assertEquals(1, result.size()); Triple tr = result.find(null, null, null).next();