AD Research Wiki:

Wikidata: various explanations

Obtaining names for entities and predicates

The [[https://query.wikidata.org|Wikidata Query Service (WDQS)] has an automatic mechanism for obtaining the single best name for entity variables in the query. It does not work for predicate names, however. The mechanism is invoked by adding this line to the SPARQL query:

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

To obtain a single name of an entity "manually" (= without the mechanism above), one can add the following two lines to a query (Q90 is Paris). Note that without the language filter, one gets one name for each languages, for which a name has been specified for that entity in Wikidata (for popular entities, these are usually very many):

wd:Q90 rdfs:label ?label .
FILTER(LANG(?label) = "en") 

To obtain a single name for a predicate, one can write (TODO: the followins is not yet correct, currently working on this paragraph):

SELECT ?p (COUNT(?o) as ?count) WHERE {
  wd:Q90 ?p ?o .
}
GROUP BY ?p
ORDER BY DESC(?count)
LIMIT 100

AD Research Wiki: HowTos/WikidataCheatSheet (last edited 2018-04-21 21:13:54 by Hannah Bast)