Get alias values from wikidata for a given property?

对着背影说爱祢 提交于 2020-01-14 03:25:15

问题


For a given property like 'occupation (P106)', I want to retrieve all its aliases like: profession, job, work, career, employment, craft. All of this is present on the properties wikidata page, under 'Also known as'. How can I go about retrieving this using SPARQL? I tried using the following query.

  SELECT ?predicate ?object WHERE {
  wdt:P106 wdt:P1449 ?predicate .  //Nickname
  wdt:P106 wdt:P734 ?predicate .   //Family Name
  wdt:P106 wdt:P735 ?predicate .  //Given Name
  wdt:P106 skos:altLabel ?predicate . 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

回答1:


SELECT ?altLabel
{
 VALUES (?wd) {(wd:P106)}
 ?wd skos:altLabel ?altLabel .
 FILTER (lang(?altLabel) = "en")
}

or

SELECT ?altLabel
{
 VALUES (?wdt) {(wdt:P106)}
 ?wd wikibase:directClaim ?wdt .
 ?wd skos:altLabel ?altLabel .
 FILTER (lang(?altLabel) = "en")
}

These paragraphs provide some explanation:

  • Truthy statements
  • Properties
  • Predicates

Update

You still could use the label service:

SELECT ?wdAltLabel
{
 VALUES (?wdt) {(wdt:P106)}
 ?wd wikibase:directClaim ?wdt .
 SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}


来源:https://stackoverflow.com/questions/46439553/get-alias-values-from-wikidata-for-a-given-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!