Search code examples
sparqlwikidata

How to get a label of a property from Wikidata?


I can use rdfs:label to get the text value of an object, for instance:

SELECT DISTINCT * WHERE {
  wd:Q19675 rdfs:label ?label . 
  FILTER (langMatches( lang(?label), "ES" ) )  
}

will give me the value Museo del Louvre since it is the label of the object Q19675.

But what if I want to get the label of a property? (Not-working) example:

SELECT * WHERE {
  wdt:P131 rdfs:label ?label . 
}

What should I do to get the text value (label) of the property P131? The label of this property should be located in the administrative territorial entity.


Solution

  • I found the solution myself:

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

    We need SERVICE wikibase:label... only in order to specify the language of our property label.