Search code examples
sparqlwikidata

Wikidata do not return me itemLabel sometimes


I am looking for people of french nationality born in 1900 (and still living). I do not well understand the behaviour of wikidata in response to my following request:

SELECT ?item ?itemLabel ?itemDescription
WHERE {
  ?item wdt:P31 wd:Q5.
  ?item wdt:P569 ?dateOfBirth.
  ?item  wdt:P27 wd:Q142.
  FILTER NOT EXISTS {?item wdt:P570|wdt:P509|wdt:P20 ?o}
  FILTER("1900-00-00"^^xsd:dateTime <= ?dateOfBirth &&  ?dateOfBirth < "1901-00-00"^^xsd:dateTime)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr". }
}
  1. I do not understand why the folowing request do not return itemLabel for some rows; for example the itemlabel returned for https://www.wikidata.org/wiki/Q47508624 is its "id": Q47508624

Solution

  • By using the wikibase:language option, you're asking for Wikidata to provide you with the labels for each ?item in the ?itemLabel variable. You've requested that it provide you labels in either the language preferred by your browser ([AUTO_LANGUAGE]) or French (fr). I would guess that your browser's default language is French also. With a browser set with English as the default, I get "Hugues Esquerre" as the ?itemLabel value for wd:Q47508624 (this record has labels defined in English and Spanish).

    You can add additional acceptable languages in the comma-separated list in the query to increase the liklihood of getting label values back:

    SELECT ?item ?itemLabel ?itemDescription
    WHERE {
      ?item wdt:P31 wd:Q5.
      ?item wdt:P569 ?dateOfBirth.
      ?item  wdt:P27 wd:Q142.
      FILTER NOT EXISTS {?item wdt:P570|wdt:P509|wdt:P20 ?o}
      FILTER("1900-00-00"^^xsd:dateTime <= ?dateOfBirth &&  ?dateOfBirth < "1901-00-00"^^xsd:dateTime)
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr,en,es". }
    }