[英]SPARQL how to get all triples with Individuals?
我刚刚开始使用 SPARQL。 我不确定错误在哪里。 我在测试推理器时遇到了错误。
我使用 Stardog 作为数据库,推理器肯定是打开的。
我有一个简单的 model,有两个类:Building 和 Room,每个类有 1 个:building001 和 room001。
我有两个 ObjectProperties hasLocation 和 isLocationOf。 两个 ObjectProperties 彼此相反。
三元组:Building001 hasLocation Room001 我已经预定义了,推理者实际上应该认识到三元组 Room001 isLocationOf Building001 本身。
我现在想要 output 所有属于个人的三元组。 所以我应该得到刚才描述的两个三元组作为结果。
随着查询:
select * where {
?subject ?property ?object.
?subject a owl:NamedIndividual.
?property a owl:ObjectProperty.
?object a owl:NamedIndividual.
}
结果我只得到三重 Building001 hasLocation Room001。
与查询:
select * where {
?subject ?property ?object
}
结果我得到以下三元组:
Building001 hasLocation Room001
Room001 isLocationOf Building001
Building001 rdf:type Building
Building001 rdf:type owl:Thing
Room001 rdf:type Room
Room001 rdf:type owl:Thing
我如何获得属于个人的所有三元组? 没有得到 rdf:type 结果?
提前谢谢了!!
您可以过滤掉rdf:type
:
SELECT * {
?s ?p ?o
FILTER (?p != rdf:type)
}
您会注意到,当您打开推理时,不会返回与您的模式关联的三元组,但会返回rdf:type
三元组。 那是因为这些三元组被认为是您个人断言的一部分,而不是您的模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.