本体中双关实体的 SPARQL 查询答案
我在 Protege 中构建了一个小型本体,以使用 SPARQL 查询测试双关语。本体是:
<?xml version="1.0"?>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
xml:base="http://www.semanticweb.org/usr/ontologies/2022/2/untitled-ontology-88"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
ontologyIRI="http://www.semanticweb.org/usr/ontologies/2022/2/untitled-ontology-88">
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
<Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
<Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
<Declaration>
<Class IRI="#B"/>
</Declaration>
<Declaration>
<Class IRI="#CL"/>
</Declaration>
<Declaration>
<Class IRI="#E"/>
</Declaration>
<Declaration>
<Class IRI="#ES"/>
</Declaration>
<Declaration>
<Class IRI="#GE"/>
</Declaration>
<Declaration>
<Class IRI="#RLS"/>
</Declaration>
<Declaration>
<ObjectProperty IRI="#Lives_in"/>
</Declaration>
<Declaration>
<DataProperty IRI="#hasAge"/>
</Declaration>
<Declaration>
<NamedIndividual IRI="#CPZ"/>
</Declaration>
<Declaration>
<NamedIndividual IRI="#ES"/>
</Declaration>
<Declaration>
<NamedIndividual IRI="#GE"/>
</Declaration>
<Declaration>
<NamedIndividual IRI="#Harry"/>
</Declaration>
<SubClassOf>
<Class IRI="#E"/>
<Class IRI="#B"/>
</SubClassOf>
<SubClassOf>
<Class IRI="#ES"/>
<Class IRI="#RLS"/>
</SubClassOf>
<SubClassOf>
<Class IRI="#GE"/>
<Class IRI="#E"/>
</SubClassOf>
<ClassAssertion>
<Class IRI="#ES"/>
<NamedIndividual IRI="#GE"/>
</ClassAssertion>
<ClassAssertion>
<Class IRI="#GE"/>
<NamedIndividual IRI="#Harry"/>
</ClassAssertion>
<ObjectPropertyAssertion>
<ObjectProperty IRI="#Lives_in"/>
<NamedIndividual IRI="#Harry"/>
<NamedIndividual IRI="#CPZ"/>
</ObjectPropertyAssertion>
</Ontology>
<!-- Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi -->
我用来测试双关实体 (GE) 的 SPARQL 查询是:
SELECT ?y ?x ?z
WHERE {
?x a ?y.
?z a ?x.
?z :Lives_in :CPZ.
}
我的问题是为什么我在输出中得到 6 个答案而不是第一个答案? ?y(owl:Class 和 owl:NamedIndividual) 的其他 5 个绑定是什么意思?
谢谢你!
I have built a small ontology in Protege to test punning with a SPARQL query. The Ontology is:
<?xml version="1.0"?>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
xml:base="http://www.semanticweb.org/usr/ontologies/2022/2/untitled-ontology-88"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
ontologyIRI="http://www.semanticweb.org/usr/ontologies/2022/2/untitled-ontology-88">
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
<Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
<Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
<Declaration>
<Class IRI="#B"/>
</Declaration>
<Declaration>
<Class IRI="#CL"/>
</Declaration>
<Declaration>
<Class IRI="#E"/>
</Declaration>
<Declaration>
<Class IRI="#ES"/>
</Declaration>
<Declaration>
<Class IRI="#GE"/>
</Declaration>
<Declaration>
<Class IRI="#RLS"/>
</Declaration>
<Declaration>
<ObjectProperty IRI="#Lives_in"/>
</Declaration>
<Declaration>
<DataProperty IRI="#hasAge"/>
</Declaration>
<Declaration>
<NamedIndividual IRI="#CPZ"/>
</Declaration>
<Declaration>
<NamedIndividual IRI="#ES"/>
</Declaration>
<Declaration>
<NamedIndividual IRI="#GE"/>
</Declaration>
<Declaration>
<NamedIndividual IRI="#Harry"/>
</Declaration>
<SubClassOf>
<Class IRI="#E"/>
<Class IRI="#B"/>
</SubClassOf>
<SubClassOf>
<Class IRI="#ES"/>
<Class IRI="#RLS"/>
</SubClassOf>
<SubClassOf>
<Class IRI="#GE"/>
<Class IRI="#E"/>
</SubClassOf>
<ClassAssertion>
<Class IRI="#ES"/>
<NamedIndividual IRI="#GE"/>
</ClassAssertion>
<ClassAssertion>
<Class IRI="#GE"/>
<NamedIndividual IRI="#Harry"/>
</ClassAssertion>
<ObjectPropertyAssertion>
<ObjectProperty IRI="#Lives_in"/>
<NamedIndividual IRI="#Harry"/>
<NamedIndividual IRI="#CPZ"/>
</ObjectPropertyAssertion>
</Ontology>
<!-- Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi -->
And the SPARQL query that i am using to test the pun entity (GE) is:
SELECT ?y ?x ?z
WHERE {
?x a ?y.
?z a ?x.
?z :Lives_in :CPZ.
}
An the output that i am getting is:
my question is why I am getting 6 answers instead of the first one in output? and what does the other 5 bindings of ?y(owl:Class and owl:NamedIndividual) mean?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从你的断言来看,哈利是一名通用电气。 GE既是一个阶级,又是一个个人;因此,GE 也出现在其他声明中,这使您看到的答案成倍增加。这类似于跨表联接,其中联接值与所涉及的表之一中的多行相匹配。
Harry is a GE, from your assertions. GE is both a class and an individual; so GE appears in other statements as well, and that's multiplying the answers you're seeing. It's analogous as joining across tables where the join value matches multiple rows in one of the tables involved.