You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Benson Margulies <bi...@gmail.com> on 2010/12/27 18:11:22 UTC

Light-duty inference

Given a TDB with a substantial amount of content, and a desire to do a
bit of inference, I'm wondering about how I'd write SPARQL to do my
own inference.

Two examples:

Say that I defined some things like:


    <owl:ObjectProperty rdf:about="&rex;corefLink">
        <rdfs:subPropertyOf rdf:resource="&owl;sameAs"/>
    </owl:ObjectProperty>


How would I write sparql for 'sameAs and all of its subprops?'

Of course, I'm violating a prime directive and perhaps prematurely
optimizing here, feel free to tell me to just fire up the inference
system and see what happens.

Re: Light-duty inference

Posted by Andy Seaborne <an...@epimorphics.com>.

On 27/12/10 17:11, Benson Margulies wrote:
> Given a TDB with a substantial amount of content, and a desire to do a
> bit of inference, I'm wondering about how I'd write SPARQL to do my
> own inference.
>
> Two examples:
>
> Say that I defined some things like:
>
>
>      <owl:ObjectProperty rdf:about="&rex;corefLink">
>          <rdfs:subPropertyOf rdf:resource="&owl;sameAs"/>
>      </owl:ObjectProperty>
>
>
> How would I write sparql for 'sameAs and all of its subprops?'

Subclass is:

?s rdf:type/rdfs:subClassOf* ?T

SubProperty is less pretty:

?s ?p ?o .
?p rdfs:subPropertyOf* ?P

OWL:sameAs
?entity (owl:sameAs|^owl:sameAs)* ?s

This last one needs to be used with care.

> Of course, I'm violating a prime directive and perhaps prematurely
> optimizing here, feel free to tell me to just fire up the inference
> system and see what happens.

It is sometimes better to do this during data preparation, not at query time

See also riot.infer -- this isn't fully integrated into the TDB loader 
yet but ...

infer --rdfs=MyVocab.rdfs ... data files ... | tdbloader -- -

Firing up the inference system is also a good idea - and gives access to 
a lot more inference capabilities.  It is limited to in-memory use.

SPARQL Update could be used to materialize inferences (slowly?) as well:

INSERT { ?s rdf:type ?T } WHERE { ?s rdf:type/rdfs:subClassOf+ ?T }

Note the change from * to +

INSERT { ?s ?P ?o } WHERE { ?p rdfs:subPropertyOf+ ?P . ?s ?p ?o }


	Andy