简体   繁体   中英

Infer data with SPARQL in Protege

I'm trying to get my head around inferring RDF data. Say that I have these triples (RDF Turtle), which I created using Protege:

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

:hasSpouse rdf:type owl:ObjectProperty ,
                    owl:SymmetricProperty ;
           rdfs:domain :People ;
           rdfs:range :People .

:People rdf:type owl:Class .

:Jane_Doe rdf:type owl:NamedIndividual ,
                   :People .

:John_Doe rdf:type owl:NamedIndividual ,
                   :People ;
          :hasSpouse :Jane_Doe .

The reasoner in Protege will kindly highlight the expected inference, that is :Jane_Doe :hasSpouse :John_Doe .

门生截图

How can I see that inference with SPARQL? If I run this query in Protege (SPARQL tab):

SELECT ?subject
    WHERE {?subject hasSpouse ?object .}

It shows the asserted triple, not the inferred one. I understand how to do it manually, eg :

CONSTRUCT {?object ?prop ?subject }
    WHERE { ?prop rdf:type owl:SymmetricProperty .
            ?subject ?prop ?object .}

I'd see now the inferred data I'm expecting but 1) that would be losing the point imho (ie; reinventing the wheel) 2) I cannot have 2 queries in this tab (construct, then select). There's got to be a way to do this automatically, just like the reasoner did.

I read in Stack Overflow a post saying to use 'Snap SPARQL' plugin in Protege. I tried but simple queries don't work (like the first one above). It's like it's a different language. How does it work?

So, how can I get the benefit of these owl properties with SPARQL? How can I have an OWL-aware SPARQL in Protege? Am I taking this the wrong way? What's the right way?

thanks for your help. Nicolas

You need to make your inferences a part of your knowledge.

To do so, go to the SWRL Tab and click successively on the button

在此处输入图片说明

at the bottom of that Tab, start from the left to the right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM