Wikidata Sparql:如何从一个人那里获取奖励时间和工作
Wikidata Sparql: how to access award point of time and work from a person
自从 Freebase 关闭后,我尝试将基于 Freebase 的测验生成器改编为 Wikidata。
我这样做有很多麻烦,现在我遇到了一个简单的问题:
如何获得获奖日期和从一个人开始?
示例:我想要 2016
和 The Revenant
用于 Leonardo Dicaprio
。
我尝试了几个这样的请求:
SELECT ?id ?idLabel ?date ?forWork
WHERE {
wd:Q38111 wdt:P166 ?id .
?id wdt:P585 ?date .
?id wdt:1411 ?forWork .
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" }
}
问题是日期点 (wdt:P58
) 与收到的奖项 (P166
) 相关联,而不是 Leonardo DiCaprio
或 Academy Award for Best Actor
。
这些信息可在 Leonardo DiCaprio page 上获得(作为所获奖励的子部分)
我遇到的另一个问题是从他的名字作为字符串而不是 id 访问 Leonardo
的所有数据。
由于所有数据似乎都在预选赛中,所以我想到了这样的事情:
SELECT ?actor ?actorLabel ?award ?awardLabel ?date ?forWork ?forWorkLabel
WHERE
{
# find a human
?actor wdt:P31 wd:Q5 .
# with English label "Leonardo DiCaprio"
?actor rdfs:label "Leonardo DiCaprio"@en .
# Now comes the statements/qualifiers magic:
# just applying what the documentation says https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries#Working_with_qualifiers
# using this query as example https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries#US_presidents_and_their_spouses.2C_in_date_order
?actor p:P166 ?awardstatement .
?awardstatement ps:P166 ?award .
?awardstatement pq:P585 ?date .
?awardstatement pq:P1686 ?forWork .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr" . }
}
你可以try it here and get the data there
自从 Freebase 关闭后,我尝试将基于 Freebase 的测验生成器改编为 Wikidata。 我这样做有很多麻烦,现在我遇到了一个简单的问题:
如何获得获奖日期和从一个人开始?
示例:我想要 2016
和 The Revenant
用于 Leonardo Dicaprio
。
我尝试了几个这样的请求:
SELECT ?id ?idLabel ?date ?forWork
WHERE {
wd:Q38111 wdt:P166 ?id .
?id wdt:P585 ?date .
?id wdt:1411 ?forWork .
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" }
}
问题是日期点 (wdt:P58
) 与收到的奖项 (P166
) 相关联,而不是 Leonardo DiCaprio
或 Academy Award for Best Actor
。
这些信息可在 Leonardo DiCaprio page 上获得(作为所获奖励的子部分)
我遇到的另一个问题是从他的名字作为字符串而不是 id 访问 Leonardo
的所有数据。
由于所有数据似乎都在预选赛中,所以我想到了这样的事情:
SELECT ?actor ?actorLabel ?award ?awardLabel ?date ?forWork ?forWorkLabel
WHERE
{
# find a human
?actor wdt:P31 wd:Q5 .
# with English label "Leonardo DiCaprio"
?actor rdfs:label "Leonardo DiCaprio"@en .
# Now comes the statements/qualifiers magic:
# just applying what the documentation says https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries#Working_with_qualifiers
# using this query as example https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries#US_presidents_and_their_spouses.2C_in_date_order
?actor p:P166 ?awardstatement .
?awardstatement ps:P166 ?award .
?awardstatement pq:P585 ?date .
?awardstatement pq:P1686 ?forWork .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr" . }
}
你可以try it here and get the data there