On Thu, 2011-07-21 at 17:21 +0200, Xabriel J Collazo-Mojica wrote:
> Hi jena-users,
>
> I have an RDF model, and I want to infer new triples from a chain of Jena
> Custom Rules Reasoners.
>
> I'm currently doing the following:
>
>
> // def. of the reasoners goes here..
> private static Reasoner firstReasoner =
> RuleReasonerFactory.createRulesReasoner("first_service.rules");
> private static Reasoner secondReasoner =
> RuleReasonerFactory.createRulesReasoner("second_service.rules");
> private static Reasoner thirdReasoner =
> RuleReasonerFactory.createRulesReasoner("third_service.rules");
> ...
Are the rules forward or hybrid?
If forward, why not just put them all in one reasoner?
> public Model createMapping(Model model) {
>
> // first, use the incoming RDF deva model
> Model infmodel = ModelFactory.createInfModel(firstReasoner, model);
>
> // all subsequent calls just take the previously created infmodel and reason
> over it
> infmodel = ModelFactory.createInfModel(secondReasoner, infmodel);
> infmodel = ModelFactory.createInfModel(thirdReasoner, infmodel);
> ...
>
> return infmodel;
>
> }
>
>
>
> To get the best performance:
>
> Should I call infmodel.prepare() before the call to the next reasoner?
Doesn't make any difference to the total cost, just changes when the
work gets done.
> Is there an efficient way to strip the infmodel from the reasoner (I.e. get
> a simple Model again) so that the next inference is faster? (I think I'm
> getting way too many rules fired..)
If you mean you a plain non-inference model containing the full set of
inference results then you can create a memory model and use add() to
add the inference model into that.
Alternatively, if you are using pure forward rules you can use
getRawModel and getDeductionsModel which are essentially plain models
and create a (dynamic or static) union of those.
Dave