3

ペレットを使用して sparql クエリを作成していますが、クエリ内のトリプルの順序に従って異なる結果が得られます。それは正しいですか?

たとえば、次の N-Triples データ入力があるとします。

<http://example.com/thing1> <http://example.com/hasDefinition> <http://example.com/def_thing1> .
<http://example.com/thing1> <http://www.w3.org/2000/01/rdf-schema#label> "Thing 1" .
<http://example.com/def_thing1> <http://www.w3.org/2000/01/rdf-schema#comment> "thing 1 it's awesome".

<http://example.com/thing2> <http://example.com/hasDefinition> <http://example.com/def_thing2> .
<http://example.com/thing2> <http://www.w3.org/2000/01/rdf-schema#label> "Thing 2" .
<http://example.com/def_thing2> <http://www.w3.org/2000/01/rdf-schema#comment> "thing 1 it's cool".

<http://example.com/thing3> <http://example.com/hasDefinition> <http://example.com/def_thing3> .
<http://example.com/thing3> <http://www.w3.org/2000/01/rdf-schema#label> "Thing 3" .
<http://example.com/def_thing3> <http://www.w3.org/2000/01/rdf-schema#comment> "thing 3 it's fine".

<http://example.com/thing4> <http://example.com/hasDefinition> <http://example.com/def_thing4> .
<http://example.com/thing4> <http://www.w3.org/2000/01/rdf-schema#label> "Thing 4" .
<http://example.com/def_thing4> <http://www.w3.org/2000/01/rdf-schema#comment> "thing 4 it's exactly what i need".

次のクエリ:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX example: <http://example.com/>

SELECT * WHERE {
    ?thing ?rel "Thing 4".
    ?thing example:hasDefinition ?def.
    ?def rdfs:comment ?definition.
}

戻り値:

Query Results (1 answers): 
thing  | rel   | def        | definition                        
================================================================
thing4 | label | def_thing4 | "thing 4 it's exactly what i need"

ただし、次のクエリ (前のものを変更しただけ):

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX example: <http://example.com/>

SELECT * WHERE {
    ?thing example:hasDefinition ?def.
    ?def rdfs:comment ?definition.
    ?thing ?rel "Thing 4".
}

次の答えが得られます。

Query Results (5 answers): 
thing  | def        | definition                         | rel                
==============================================================================
thing4 | def_thing4 | "thing 4 it's exactly what i need" | _TOP_DATA_PROPERTY_
thing4 | def_thing4 | "thing 4 it's exactly what i need" | label              
thing1 | def_thing1 | "thing 1 it's awesome"             | _TOP_DATA_PROPERTY_
thing2 | def_thing2 | "thing 1 it's cool"                | _TOP_DATA_PROPERTY_
thing3 | def_thing3 | "thing 3 it's fine"                | _TOP_DATA_PROPERTY_

私はこの動作を予期していませんでした。それが正しいかどうかもわかりません。間違ったクエリを作成したのは私です。誰かが私にこれを説明できますか?

4

3 に答える 3

4

これらの2つのクエリでも間違いなく同じ結果が得られるはずです。そのようにトリプルパターンの順序を変更しても、違いはありません。これは、クエリエンジンのバグである可能性があります。

于 2012-08-06T19:41:06.970 に答える
3

Jan が示唆しているように、純粋な SPARQL エンジンは、そのデータとそのクエリが与えられた場合に異なる結果を与えるべきではありません。

ただし、推論機能が組み込まれた SPARQL エンジンを搭載した Pellet を使用しています (ただし、どのバージョンかはわかりません)。これは、SPARQL エンジンが理由付け機能を介して結果を導出できる場合、追加の結果を正当に返す可能性があることを意味します (仕様の「 SPARQL 基本グラフ パターン マッチングの拡張」を参照)。

あるバージョンのクエリでは推論が開始され、別のバージョンでは開始されないという事実は、やや奇妙であり、Pellet 開発者に尋ねる必要があるでしょう。

于 2012-08-06T21:54:45.967 に答える
1

トリプル パターンの順序によって結果が変わることはありません。

あなたのクエリで珍しいのは?rel、プロパティの位置での使用です。

_TOP_DATA_PROPERTY_ペレットエンジンが内部的に抑制する可能性がありますが、?thing ?rel "Thing 4".最後のパターンの場合、データはペレットを再度通過せず、データベースから取得されます。

于 2012-08-07T08:59:31.253 に答える