3

我正在编写一些在 jena 和 sesame2 上运行的查询。它们中的大多数在 sesame2 下都可以正常工作,除非我指定了路径的深度。例如,如果我在 sesame 下运行此查询,它会给出 8 个结果,而 jena 会给出 217(正确的数字)。

PREFIX edge: <http://danielfrentz.com/edge#> 
PREFIX property: <http://danielfrentz.com/property#> 
select  distinct ?start ?reached where{ 
?start property:id \"v1\". 
?start (edge:uses | edge:implements | edge:extends)+ ?reached.
filter(?start != ?reached)}

所以我的问题是,sesame2 对路径深度语法的定义是否不同?还是有其他原因导致我可能会得到不同的结果?

谢谢。

额外细节:

我正在使用 2.6.10 并试用 2.7 beta。

我拥有的最小示例图如下(对不起,太长了):

@prefix edge: <http://danielfrentz.com/edge#>.
@prefix edge: <http://danielfrentz.com/property#>.
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#name> "Class3".
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#abstract> "false".
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#namespace>    "com.example".
<http://danielfrentz.com/v2> <http://danielfrentz.com/property#id> "v2".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#name> "Class2".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#abstract> "false".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#namespace>      "com.example".
<http://danielfrentz.com/v1> <http://danielfrentz.com/property#id> "v1".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#name> "Class4".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#abstract> "false".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#namespace> "com.example".
<http://danielfrentz.com/v3> <http://danielfrentz.com/property#id> "v3".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#name> "AbstractClass1".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#abstract> "true".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#namespace>   "com.example".
<http://danielfrentz.com/v4> <http://danielfrentz.com/property#id> "v4".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#name> "Class1".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#abstract> "false".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#type> "class".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#namespace>  "com.example".
<http://danielfrentz.com/v0> <http://danielfrentz.com/property#id> "v0".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#name> "Interface1".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#abstract> "true".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#type> "interface".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#namespace>    "com.example".
<http://danielfrentz.com/v5> <http://danielfrentz.com/property#id> "v5".
<http://danielfrentz.com/v3> <http://danielfrentz.com/edge#extends>     <http://danielfrentz.com/v4>.
<http://danielfrentz.com/v2> <http://danielfrentz.com/edge#uses>    <http://danielfrentz.com/v3>.
<http://danielfrentz.com/v4> <http://danielfrentz.com/edge#uses> <http://danielfrentz.com/v2>.
<http://danielfrentz.com/v5> <http://danielfrentz.com/edge#uses> <http://danielfrentz.com/v0>.
<http://danielfrentz.com/v1> <http://danielfrentz.com/edge#implements> <http://danielfrentz.com/v5>.
<http://danielfrentz.com/v0> <http://danielfrentz.com/edge#uses> <http://danielfrentz.com/v1>.

查询是:

PREFIX edge: <http://danielfrentz.com/edge#>
PREFIX property: <http://danielfrentz.com/property#>
select  distinct ?start ?reached where{
?start property:id \"v1\". 
?start (edge:uses | edge:implements | edge:extends){1,3} ?reached.
FILTER (?start != ?reached)}

结果是:

start start=http://danielfrentz.com/v1
reached reached=http://danielfrentz.com/v5

应该有 2 个结果而不是 1 个。

我还应该补充一点,当我不使用属性路径(即我使用 + 而不是 {1,3})时,它会给出正确数量的结果。

4

1 回答 1

0

您在路径长度 ( ) 上使用的具有下限和上限的构造{1,3}不再是官方支持的 SPARQL 功能,它已在最近的一次更新中从 SPARQL 规范中删除。

Sesame 的 SPARQL 查询解析器仍然接受构造。我在 Sesame 2.7.0-beta1 上测试了您的查询,您是正确的,它没有产生预期的答案(而 using+仍然SPARQL 的官方功能,确实可以正常工作)。所以这是芝麻的查询解析器中的一个错误。但是,鉴于该{1, 3}构造不再是 SPARQL 的正式组成部分,我不确定它是否会得到修复 - 在下一个 Sesame 版本中,该构造更有可能导致语法错误。

于 2013-01-23T03:27:52.120 回答