owl:查询中的传递属性
我做了一个家谱。我还定义了传递属性:childOf。现在我想做一个 SPARQL 查询,它可以给我一个家庭成员的所有后代。我该怎么做呢?谢谢
I have done a family tree. I also defined transitive property: childOf. Now I want to make SPARQL Query which give me all descendants of one of members of family. How can I do it? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的三重存储支持 OWL 推理并且您已将
childOf
属性定义为可传递的(顺便说一下,它不应该被称为descendantOf
!),那么它应该推断直接在所有相关节点之间使用childOf
属性。因此,像这样查询就足够了(为简洁起见,省略了前缀):但是,如果您的三元组存储不执行 OWL 推理,则可以通过使用 SPARQL 1.1 属性路径查询间接关系来获得相同的结果
:
childOf
后的“+”表示该谓词可以匹配 1 次或多次。有关 SPARQL 1.1 属性路径的更多详细信息,请访问 http://www.w3.org/TR /sparql11-property-paths/。If your triple store supports OWL reasoning and you've defined your
childOf
property to be transitive (shouldn't it be calleddescendantOf
by the way!), then it should inferchildOf
properties directly between all related nodes. So, it should be enough to query it like this (prefixes omitted for brevity):However, if your triple store doesn't do OWL reasoning, you can achieve the same result by using SPARQL 1.1 property paths to query for indirect relationships:
Note the '+' after the
childOf
, this means that the predicate may be matched 1 or more times. More details about SPARQL 1.1 property paths are at http://www.w3.org/TR/sparql11-property-paths/.