sparql - 维基数据 LabelService 的行为不符合预期

标签 sparql wikidata blazegraph

以下维基数据查询无法按我的预期工作:

# 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". }
}

try it!

结果是

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/

相关文章:

rdf - SPARQL 更新中更新图中的变量

sparql - 获取项目的所有 DISTINCT 标签

python - Spacy 实体链接模型的训练时间

python - 如何使用 Python 解析 WIkidata JSON (.bz2) 文件?

docker - 具有Blazegraph Triple Store的Docker容器可能由于联网而无法正常工作

import - 使用批量数据加载器将三元组加载到 Blazegraph

sparql - SPARQL 中的 IF 语句

sparql - 使用字符串形式的非负整数对 sparql 中的结果进行升序排列

sparql - 在参与者的维基数据查询中应用 group_concat

sparql - SPARQL 中的 lang 函数是什么?