SPARQL查询传递 [英] SPARQL Querying Transitive

查看:98
本文介绍了SPARQL查询传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是SPARQL的初学者,想知道是否存在可以帮助我返回传递关系的查询.例如,下面的n3文件我想要一个查询,该查询将返回"a is as same as c"或类似的内容.谢谢

I am a beginner to SPARQL and was wondering if there was a query which could help me return transitive relations. For example the n3 file below I would want a query that would return "a is the sameas c" or something along those lines. Thanks

@prefix : <http://websitename.com/links/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .

:a owl:sameas :b.
:b owl:sameas :c.

推荐答案

如果您使用的是适当启用的SPARQL 1.1引擎,则可以使用属性路径,并且已经标记了问题Jena,所以我假设您使用的是它的ARQ引擎支持此功能.

You can use property paths if you are using a suitably enabled SPARQL 1.1 engine, you've tagged your question Jena so I assume you are using its ARQ engine which supports this feature.

因此,您可以编写如下查询:

So you can write a query like the following:

PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT *
WHERE
{
  ?x owl:sameAs+ ?y
}

请注意谓词后的+,用于表示它应查找由一个/多个步骤组成的关系.

Note the + after the predicate, used to indicate that it should look for relationships composed of one/more steps.

可以在此处找到属性路径的语法,该语法非常常规表达喜欢.使用此查询的唯一缺点是,您不会获得有关路径有多长时间或中间节点是什么的任何信息.

The syntax for property paths can be found here and is very regular expression like. The only downside of queries using this is that you don't get any information about how long the paths are or what the intermediate nodes are.

这篇关于SPARQL查询传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆