2

次のウィキデータ クエリは、期待どおりに機能しません。

# WikiData SPARQL Query
#
# Wolfgang Fahl 2018-01-06
#
# get father of queen victoria
SELECT ?queenVictoria ?queenVictoriaLabel ?fatherProperty ?fatherPropertyLabel ?father ?fatherLabel
WHERE {
#  
# father
# https://www.wikidata.org/wiki/Property:P42
# Queen Victoria
# https://www.wikidata.org/wiki/Q9439
  BIND (wdt:P22 AS ?fatherProperty).
  BIND (wd:Q9439 AS ?queenVictoria).
  ?queenVictoria ?fatherProperty ?father.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

それを試してみてください!

結果は

queenVictoria queenVictoriaLabel fatherProperty fatherPropertyLabel                     father.      fatherLabel   
wd:Q9439      Queen Victoria     wdt:P22        http://www.wikidata.org/prop/direct/P22 wd:Q157009   Prince Edward Augustus, Duke of Kent and Strathearn

ラベルはヴィクトリア女王、父、そして「エドワード・アウグストゥス王子」だと思っていました。

クエリの何が問題になっていますか? それともこれはバグですか?

4

1 に答える 1

3

http://www.wikidata.org/prop/direct/P22代わりに が返される理由はfather、ウィキデータの真実の述語にラベルがないためです (試してくださいDESCRIBE wdt:P22)。適切なプロパティのみにラベルが付いています (試してくださいDESCRIBE wd:P22)。

ウィキデータラベル サービスはこの状況を包むことができますが、そうではありません:

SERVICE wikibase:labelwd: 名前空間のエンティティのラベルのみを提供します。

したがって、次のクエリを試してください。

SELECT ?queenLabel ?realpropertyLabel ?fatherLabel
WHERE {
  VALUES (?queen) {(wd:Q9439)}
  VALUES (?property) {(wdt:P22)}
  ?queen ?property ?father .
  ?realproperty wikibase:directClaim ?property
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} 
于 2018-01-19T12:49:01.493 に答える