According to the documentation "there is no guarantee of the order in
which matching rules will fire". So is the general approach to
instantiate two RuleReasoners when certain rules require, that other
rules have been tested before?
For example, let's say there is rule, that adds a statement when certain
conditions are met:
| [rule1: (?x rdf:type :X) (?x :hasValue ?y) greaterThan(?y, 123)
-> (?x :hasSpecialValue ?y) ]
|
Furthermore there is a rule, that adds a different statement, when a
resource doesn't contain a statement with the predicate 'hasSpecialValue':
| [rule2: (?x rdf:type :X) noValue(?x, :hasSpecialValue)
-> (?x :hasNoSpecialValue ?y) ]
|
This rule, however, should only be executed, when the former has been
tried. In the rules file the second rule has been placed below the first
one, but according to the documentation this is no guarantee it won't be
executed first.
For the example provided I could simply |noValue(?x, :hasSpecialValue)|
with |le(?y, 123)| to get the same result. However, in my rules file
there rules with a lot more conditions and reasoning performance
currently not satisfying, so by adding further rules for checking
negations, that are implied due to the absence of data (noValue), will
probably further decrease performance.
So would it be best to use the output of RuleReasoner, that applies a
set of basic rules, as input for another with rules based on the first set?
| Reasoner reasoner = new GenericRuleReasoner(rules);
Model model2 = ModelFactory.createInfModel(reasoner, model);
Reasoner reasoner2 = new GenericRuleReasoner(rules2);
return reasoners.createInfModel(reasoner2, model2);
|