芝麻和珍娜的结果数量不同

时间:2013-01-21 03:12:08

标签: sparql jena sesame

我正在编写一些在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}),它会给出正确的结果数。

1 个答案:

答案 0 :(得分:0)

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

Sesame的SPARQL查询解析器仍然接受构造。我测试了你对Sesame 2.7.0-beta1的查询,你是对的,它没有产生预期的答案(而使用+,其中 仍然是官方的SPARQL功能,可以正常工作)。所以这是Sesame查询解析器中的一个错误。但是,鉴于{1, 3}构造不再是SPARQL的正式构造,我不确定它是否会被修复 - 在下一个Sesame版本中,它更可能导致构造将导致而是语法错误。