You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Martynas Jusevičius <ma...@graphity.org> on 2016/11/27 20:24:08 UTC

Extending a Reasoner (optimized for subclass traversal)

Hey all,

I have a rule that does what I need using GenericRuleReasoner, but I
am still struggling with performance.

It might not be a problem with the engine but with the rule itself,
which is more OO-like. The latest version goes like this:
[inh:   (?class rdf:type
<http://www.w3.org/2000/01/rdf-schema#Class>), (?class ?p ?o), (?p
rdf:type <http://www.w3.org/ns/ldt#InheritedProperty>), (?subClass
rdfs:subClassOf ?class), (?subClass rdf:type
<http://www.w3.org/2000/01/rdf-schema#Class>), noValue(?subClass ?p)
-> (?subClass ?p ?o) ]

Dave had suggested how to optimize them, but noValue() is the
problematic bit, as I understand:
https://mail-archives.apache.org/mod_mbox/jena-users/201606.mbox/%3C5768FAC2.6020206@gmail.com%3E

I think however instead of optimizing the rule, I will rather write a
standalone optimized Reasoner which hardcodes it, as performance is
crucial at this level.

So the question is: is there some base Reasoner that can be extended
for that purpose? It will need to traverse the subclass hierarchy.
Could it be the TransitiveReasoner?
https://jena.apache.org/documentation/inference/#transitive

Thanks,

Martynas

Re: Extending a Reasoner (optimized for subclass traversal)

Posted by Dave Reynolds <da...@gmail.com>.
Hi Martynas,

On 27/11/16 20:24, Martynas Jusevi\u010dius wrote:
> Hey all,
>
> I have a rule that does what I need using GenericRuleReasoner, but I
> am still struggling with performance.
>
> It might not be a problem with the engine but with the rule itself,
> which is more OO-like. The latest version goes like this:
> [inh:   (?class rdf:type
> <http://www.w3.org/2000/01/rdf-schema#Class>), (?class ?p ?o), (?p
> rdf:type <http://www.w3.org/ns/ldt#InheritedProperty>), (?subClass
> rdfs:subClassOf ?class), (?subClass rdf:type
> <http://www.w3.org/2000/01/rdf-schema#Class>), noValue(?subClass ?p)
> -> (?subClass ?p ?o) ]
>
> Dave had suggested how to optimize them, but noValue() is the
> problematic bit, as I understand:
> https://mail-archives.apache.org/mod_mbox/jena-users/201606.mbox/%3C5768FAC2.6020206@gmail.com%3E

For the forward engine the complete unground term (?class ?p ?o) may 
also be a problem. The engine is quite naive and probably doesn't handle 
that as well as it should.

> I think however instead of optimizing the rule, I will rather write a
> standalone optimized Reasoner which hardcodes it, as performance is
> crucial at this level.
>
> So the question is: is there some base Reasoner that can be extended
> for that purpose? It will need to traverse the subclass hierarchy.
> Could it be the TransitiveReasoner?
> https://jena.apache.org/documentation/inference/#transitive

No, there's no template base reasoner.

I would be inclined to just implement it as a sparql update and either 
do the subclass closure in the sparql query or use a transitive reasoner 
underneath just to compute the subclass closure.

Dave