4

I would like to use rules in my ontology so that at the moment of the inference I can retrieve some information not explicitly expressed in the triplestore. I created a basic ontology and I want to add this rule:

Person(?p) ^ hasSibling(?p, ?s) ^ Man(?s) → hasBrother(?p, ?s)

The SPARQL query I would like to perform is

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX prova: <http://www.example.it/prova/>
SELECT ?subject ?object
    WHERE { ?subject prova:hasBrother ?object }

Running this does not return anything. Of course, I have created the individuals for each class, but I have not created the instance that involves hasBrother, as this is what I want the intelligence to retrieve by itself. So, my question is: is it possible to use SPARQL queries to achieve inference described by rules? Or these kind of inferences are only possible with a dedicated query system? In protegè I learn about the SQWRL tab for instance.

I am using the last version of Protegè (5.5.0) and the last version of the SWRL Rules plugin (2.11). I have defined the rule in the SWRL Tab. Then I tried the SQWRL tab to perform the query, but I get a strange error related to "invalid query name", which I don't really understand. Any suggestion about this second point would be helpful.

Luca
  • 51
  • 4
  • which query exactly do you run? I mean, the SQWRL tab is not for the SPARQL query shown above but for an SQWRL query (as the tab name indicates). For SPARQL with inference you have to a) add the SWRL rule, b) run a Pellet or HermiT reasoner and c) use the Snap SPARQL plugin view – UninformedUser Feb 22 '22 at 13:10
  • Thanks! In that way it works. However, my end goal is to use it with the Apache Jena Fuseki server for SPARQL queries, not just using Protegè. Is that possible? If so, how? – Luca Feb 22 '22 at 13:47
  • in that case you would either have to write this rule in the Jena's own rule language and use their custom rule based reasoner or find a recent Pellet fork that works with Jena 4.x. Openllet would be one fork that works with latest Jena: https://github.com/Galigator/openllet – UninformedUser Feb 22 '22 at 15:16
  • thanks, I also found openllet I will give a try – Luca Feb 22 '22 at 15:23

0 Answers0