How to select only direct subClassOf element in a GraphDB custom ruleset?

44 views Asked by At

In a GraphDB custom ruleset, I need to access only the explicitly declared superclass of an element, but I can't find any predicate (like sesame:directSubClassOf), nor use the implicit/explicit context (onto:explicit / onto:implicit). Any workaround I've tried so far has failed.

To illustrate the issue, say I have the following triples:

:x :rdf:type :a.
:y :rdf:type :b.
:z :rdf:type :c.
:a rdfs:subClassOf :b.
:b rdfs:subClassOf :c.

Because of transitivity, after inference (I ignored reflexivity here):

:x :rdf:type :a.
:x :rdf:type :b.
:x :rdf:type :c.
:y :rdf:type :b.
:y :rdf:type :c.
:z :rdf:type :c.
:a rdfs:subClassOf :b.
:b rdfs:subClassOf :c.
:a rdfs:subClassOf :c.

With this custom rule:

Id: hasDirectLinkTo
    c1 <rdfs:subClassOf> c2
    i1 <rdf:type> c1
    i2 <rdf:type> c2
    -------------------------------
    i1 <:hasdirectlinkto> i2

I obtain all the instances of c1 and its superclasses linked to all the instances of c2 and its superclasses, by the predicate :hasdirectlinkto, while in this case, I don't want the superclasses. Here:

1. :x :hasdirectlinkto :y
2. :x :hasdirectlinkto :z
3. :y :hasdirectlinkto :z

Where I don't want to get line 2 :x :hasdirectlinkto :z.

Any suggestion would be greatly appreciated, thanks!

0

There are 0 answers