【发布时间】:2013-01-21 03:12:07
【问题描述】:
我正在编写一些在 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})时,它会给出正确数量的结果。
【问题讨论】:
-
芝麻人可能会喜欢一个完整的、最小的例子。 Complete=>一些数据和预期的结果;最小=>不大于必要(不是 217 个结果,尽可能简单的查询)。
-
另外,请告诉我们您使用的是哪个版本的 Sesame。属性路径是一项新功能。 SPARQL 规范中的官方定义和 Sesame 中的实现在各个版本中都发生了多次更改。