Discussion:
Extending a Reasoner (optimized for subclass traversal)
Martynas Jusevičius
2016-11-27 20:24:08 UTC
Permalink
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/%***@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
Dave Reynolds
2016-11-29 09:06:43 UTC
Permalink
Hi Martynas,
Post by Martynas Jusevičius
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,
[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
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.
Post by Martynas Jusevičius
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

Loading...