2

I've just started using the triple store RDF4J (I am using its workbench, version 2.3.1, run on Windows 10 with Tomcat 9.0)

I want to use the SPIN rules in RDF4J. Therefore, I created a new repository (In memory with RDFS+SPIN support).

I wanted to start with the SPIN example in RDF4J documentation concerning how to add SPIN rules. That is, I added the data (in Turtle, and imported to RDF4J)

@prefix ex: <http://example.org/>.
        ex:John a ex:Father ;
ex:parentOf ex:Lucy .
ex:Lucy a ex:Person .

And the rule:

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix sp: <http://spinrdf.org/sp#>.
@prefix spin: <http://spinrdf.org/spin#>.
@prefix ex: <http://example.org/>.
ex:Person a rdfs:Class ;
    spin:rule [
        a sp:Construct ;
    sp:text """PREFIX ex: <http://example.org/>
               CONSTRUCT { ?this ex:childOf ?parent . }
               WHERE { ?parent ex:parentOf ?this . }"""
] .

And as instructed in the documentation, I exposed the query (with the checkbox 'Include inferred statements' checked),

PREFIX ex: <http://example.org/>
SELECT ?child 
WHERE { ?child ex:childOf ?parent }

However, no result returned:

no result

Could someone, please tell me am I doing something wrong, why the SPIN rule doesn't work in my RDF4J workbench, have I missed something?

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
W.Huang
  • 21
  • 2
  • First: the SPIN reasoner currently assumes that all data is in the default context, I think. Can you verify that your data was not added to a named graph? Second: check that you add the rules first, and the data second. I'm not 100% sure about this but from the top of my head it doesn't apply newly added rules to existing data. – Jeen Broekstra Apr 20 '18 at 03:29
  • 1
    Thanks a lot! Your suggestions are valid and now the rule works. However, such limitations impair the usefulness of SPIN rule inference in RDF4J, particularly the data cannot be in a named graph. Would this be fixed? – W.Huang Apr 20 '18 at 23:06
  • to be honest, development has shifted to SHACL, which is the successor to SPIN. It's unlikely the SPIN functionality itself will be improved, but on the other hand SHACL should support everything you need once it's out of beta. – Jeen Broekstra Apr 22 '18 at 23:12
  • Good to know, look forward to progress in SHACL. – W.Huang May 08 '18 at 15:21

1 Answers1

1

(reposting my comment as an answer for future readers)

The SPIN reasoner currently assumes that all data is in the default context, I think. Make sure that your data was not added to a named graph.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73