theQman
theQman

Reputation: 1780

How to get "Description" from wikidata entry with SPARQL query?

How can I extract the description for a given item label? For example, for Barack Obama (Q76) link there is a listed description: "44th president of the United States". How do I retreive this? I am able to extract the "label" using this:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX wd: <http://www.wikidata.org/entity/> 
#Cats
SELECT ?label
WHERE 
{
  wd:Q76 rdfs:label ?label .
  FILTER (langMatches( lang(?label), "EN" ) )
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

(Although this gives me the same result 3 times...) How do I get the description as well?

Upvotes: 2

Views: 1953

Answers (1)

Karima Rafes
Karima Rafes

Reputation: 1108

In the manual mode of Wikidata label service, you explicitly bind the label variables within the service call.

For example, with Barack Obama (Q76) entry, we can bind the label and the description.

PREFIX bd: <http://www.bigdata.com/rdf#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX schema: <http://schema.org/> 
PREFIX wd: <http://www.wikidata.org/entity/> 
PREFIX wikibase: <http://wikiba.se/ontology#> 

SELECT ?obamaLabel ?obamaDesc
WHERE {
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
    wd:Q76 rdfs:label ?obamaLabel .
    wd:Q76 schema:description ?obamaDesc .
  }
}

Demo

Upvotes: 5

Related Questions