2013-01-21 34 views
3

我正在編寫一些在jena和sesame2上運行的查詢。他們中的大多數在sesame2下正常工作,除非我指定路徑的深度。例如,如果我在芝麻下運行這個查詢,它會給我8個結果,而jena會給出217個(正確的數字)。不同數量的sesame2和jena結果

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測試版。

最小示例圖表我是下述(對不起它只要):

@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})時,它會給出正確數目的結果。

+3

芝麻的人可能會喜歡一個完整的,最小的例子。完成=>一些數據和預期結果;最小=>不大於必要值(不是217結果,因爲查詢儘可能簡單)。 – AndyS

+1

另外,請讓我們知道您正在使用哪種版本的芝麻。屬性路徑是一項新功能。 SPARQL規範中的官方定義和Sesame中的實現在各種版本中都發生了多次變化。 –

回答

0

正在使用的路徑長度上限和下限({1,3})的構造不再是官方支持的SPARQL功能,而是從最新更新之一中的SPARQL規範中刪除。

Sesame的SPARQL查詢解析器仍接受構造。我在Sesame 2.7.0-beta1上測試了你的查詢,你是對的,它不會產生預期的答案(而使用+,其中仍然是一個官方的SPARQL功能,確實工作正常)。所以這是Sesame查詢解析器中的一個錯誤。但是,鑑於{1, 3}構造不再是SPARQL的正式組成部分,我不確定它會被修復 - 更可能的是,在下一次Sesame發佈時,構造會導致語法錯誤。

+0

從SPARQL 1.1的最新版本開始,完成'prop {1,3}'AFAIK的唯一方法就是像'prop |(prop/prop)|(prop/prop/prop)'這樣的表達式。誠然,這並不能真正適應更長的路徑。 – sdesciencelover

+0

謝謝你們倆。 – user1690293

+0

@sdesciencelover 我嘗試過使用道具|(道具/道具)|(道具/道具/道具),可悲的是我再次得到1個結果......雖然它與jena一起工作。 結果IM期待是: 開始http://danielfrentz.com/node#v1 達到http://danielfrentz.com/node#v5 開始http://danielfrentz.com/node#v1 達到http:// danielfrentz。COM /節點#V0 – user1690293