[英]Infer data with SPARQL in Protege
I'm trying to get my head around inferring RDF data.我正在尝试推断 RDF 数据。 Say that I have these triples (RDF Turtle), which I created using Protege:假设我有使用 Protege 创建的这些三元组 (RDF Turtle):
@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
. Protege 中的推理器会很好地突出预期的推理,即:Jane_Doe :hasSpouse :John_Doe
。
How can I see that inference with SPARQL?我怎样才能看到 SPARQL 的推断? If I run this query in Protege (SPARQL tab):如果我在 Protege(SPARQL 选项卡)中运行此查询:
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).我现在会看到我期待的推断数据,但是 1) 恕我直言,这将失去意义(即重新发明轮子)2)我不能在此选项卡中进行 2 个查询(构建,然后选择)。 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.我在 Stack Overflow 上读到一篇文章,说要在 Protege 中使用“Snap SPARQL”插件。 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?那么,我怎样才能通过 SPARQL 获得这些 owl 属性的好处呢? How can I have an OWL-aware SPARQL in Protege?如何在 Protege 中拥有支持 OWL 的 SPARQL? Am I taking this the wrong way?我是否以错误的方式看待这个问题? What's the right way?什么是正确的方法?
thanks for your help.谢谢你的帮助。 Nicolas尼古拉斯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.