/** * Add a single rule to the store. * N.B. This will invalidate current partial results and the engine * should be reset() before future queries. */ public synchronized void addRule(Rule rule) { checkSafeToUpdate(); if (rule.headLength() > 1) { throw new ReasonerException("Backward rules only allowed one head clause"); } ruleStore.addRule(rule); }
/** * Add a single rule to the store. * N.B. This will invalidate current partial results and the engine * should be reset() before future queries. */ public synchronized void addRule(Rule rule) { checkSafeToUpdate(); if (rule.headLength() > 1) { throw new ReasonerException("Backward rules only allowed one head clause"); } ruleStore.addRule(rule); }
/** * Add a single/remove a compound rule from the store. * @param rule the rule, may have multiple heads * @param isAdd true to add, false to remove */ private void addRemoveRule(Rule rule, boolean isAdd) { if (rule.headLength() != 1) { for (int j = 0; j < rule.headLength(); j++) { Rule newRule = new Rule(rule.getName(), new ClauseEntry[] {rule.getHeadElement(j)}, rule.getBody() ); newRule.setNumVars(rule.getNumVars()); doAddRemoveRule(newRule, isAdd); } } else { doAddRemoveRule(rule, isAdd); } }
/** * Add a single/remove a compound rule from the store. * @param rule the rule, may have multiple heads * @param isAdd true to add, false to remove */ private void addRemoveRule(Rule rule, boolean isAdd) { if (rule.headLength() != 1) { for (int j = 0; j < rule.headLength(); j++) { Rule newRule = new Rule(rule.getName(), new ClauseEntry[] {rule.getHeadElement(j)}, rule.getBody() ); newRule.setNumVars(rule.getNumVars()); doAddRemoveRule(newRule, isAdd); } } else { doAddRemoveRule(rule, isAdd); } }
/** * Scan the rules for any axioms and insert those */ protected void findAndProcessAxioms() { BFRuleContext context = new BFRuleContext(infGraph); for ( Rule r : rules ) { if ( r.bodyLength() == 0 ) { // An axiom for ( int j = 0; j < r.headLength(); j++ ) { Object head = r.getHeadElement( j ); if ( head instanceof TriplePattern ) { TriplePattern h = (TriplePattern) head; Triple t = new Triple( h.getSubject(), h.getPredicate(), h.getObject() ); context.addTriple( t ); infGraph.getDeductionsGraph().add( t ); } } } } addSet(context); processedAxioms = true; }
/** * Scan the rules for any axioms and insert those */ protected void findAndProcessAxioms() { BFRuleContext context = new BFRuleContext(infGraph); for ( Rule r : rules ) { if ( r.bodyLength() == 0 ) { // An axiom for ( int j = 0; j < r.headLength(); j++ ) { Object head = r.getHeadElement( j ); if ( head instanceof TriplePattern ) { TriplePattern h = (TriplePattern) head; Triple t = new Triple( h.getSubject(), h.getPredicate(), h.getObject() ); context.addTriple( t ); infGraph.getDeductionsGraph().add( t ); } } } } addSet(context); processedAxioms = true; }
for ( int j = 0; j < r.headLength(); j++ )
for ( int j = 0; j < r.headLength(); j++ )
for ( int j = 0; j < r.headLength(); j++ )
for ( int j = 0; j < r.headLength(); j++ )
for ( int j = 0; j < rule.headLength(); j++ )
for (int i = 0; i < rule.headLength(); i++) { Object hClause = rule.getHeadElement(i); if (hClause instanceof TriplePattern) {
for (int i = 0; i < rule.headLength(); i++) { Object hClause = rule.getHeadElement(i); if (hClause instanceof TriplePattern) {
for ( int j = 0; j < rule.headLength(); j++ )
for (int i = 0; i < rule.headLength(); i++) { Object hClause = rule.getHeadElement(i); if (hClause instanceof TriplePattern) {
for (int i = 0; i < rule.headLength(); i++) { Object hClause = rule.getHeadElement(i); if (hClause instanceof TriplePattern) {
for ( int j = 0; j < r.headLength(); j++ )
for ( int j = 0; j < r.headLength(); j++ )