以下维基数据查询无法按我的预期工作:
# 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
我原本以为标签是维多利亚女王、父亲和“爱德华·奥古斯都王子”。
我的查询有什么问题吗?或者这是一个错误?
最佳答案
返回http://www.wikidata.org/prop/direct/P22
而不是father
的原因是维基数据真实predicates没有标签(尝试DESCRIBE wdt:P22
)。只有合适properties有标签(尝试DESCRIBE wd:P22
)。
维基数据 label service可以解决这种情况,但它 doesn't :
SERVICE wikibase:label
only supplies labels for entities in the wd: namepace.
因此,try此查询:
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". }
}
关于sparql - 维基数据 LabelService 的行为不符合预期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48338287/