问题描述
我正试图从Wikipedia API中获取仍然活着的人,但我还没有弄清楚该怎么做.
I'm trying to fetch people who are still alive from Wikipedia API but I haven't figured out how to do it.
我发现了这个问题据我了解,唯一的方法是搜索仅具有birth_date参数的人,实际上我该怎么做?
I found this question which is the same as mine and as far as I understood the only way is to search for people who only have the birth_date parameter, how do I actually do that?
例如,如果我想搜索罗纳尔多",我应该得到一个名单,列出所有仍在世的罗纳尔多人.我唯一关心的数据是出生日期,姓名和姓氏,以及如果死亡的最终死亡日期.
For instance, if I wanted to search for "Ronaldo", I should get a list of all people called Ronaldo who are still alive. The only data I care about are date of birth, name and surname, and eventually date of death if they die.
我唯一想到的是:
https://en.wikipedia.org/w/api.php?action=opensearch&search=%22Ronaldo%22&format=json
但是它并没有完成我想要的工作,因为它只获取传记和链接.
But it doesn't do the job that I'd like it to do because it only gets the biography and link.
推荐答案
请查看以下查询:
SELECT distinct ?item ?itemLabel ?itemDescription (SAMPLE(?DR) as ?DR) (SAMPLE(?RIP) as ?RIP) (SAMPLE(?image)as ?image) (SAMPLE(?article)as ?article) WHERE {
?item wdt:P31 wd:Q5.
?item ?label "Ronaldo"@en.
?article schema:about ?item .
?article schema:inLanguage "en" .
?article schema:isPartOf <https://en.wikipedia.org/>.
OPTIONAL{?item wdt:P569 ?DR .} # P569 : Date of birth
OPTIONAL{?item wdt:P570 ?RIP .} # P570 : Date of death
OPTIONAL{?item wdt:P18 ?image .} # P18 : image
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?item ?itemLabel ?itemDescription
您可以在死亡日期添加过滤器",以仅查看活着的人.
You can add Filter on death date to see only alive people.
这篇关于从Wikipedia API获取名人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!