Wikidata LabelService的行为与预期不符 [英] Wikidata LabelService does not behave as expected

查看:15
本文介绍了Wikidata LabelService的行为与预期不符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下Wikidata查询没有按照我的预期工作:

# 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)。

Wikidatalabel service可以包装此情况,但它doesn't

SERVICE wikibase:label仅为wd中的实体提供标签: 名称空间。

因此,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". }
} 

这篇关于Wikidata LabelService的行为与预期不符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆