Yuehai
Yuehai

Reputation: 1243

Get Wikidata entity descriptions via SPARQL, without Wikidata label service

I found this following code snippet on opendata.stackexchange.com, which returns name and description of citizens of the US from Wikidata:

prefix wdt: <http://www.wikidata.org/prop/direct/>
prefix wd: <http://www.wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?Name ?itemDescription WHERE {
  ?item wdt:P27 wd:Q30 .
  ?item rdfs:label ?Name
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
   }
}
LIMIT 3

The query can be evaluated at https://query.wikidata.org/

I am trying to get a description of a particular entity, for example Q3(life). But it in this case, the labelService does not return anything.

prefix wdt: <http://www.wikidata.org/prop/direct/>
prefix wd: <http://www.wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?Name ?itemDescription WHERE {
    wd:Q3 rdfs:label ?Name
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

LIMIT 3

EDIT: I am using Virtuoso and therefore cannot rely on Wikidata Label Service.

Upvotes: 3

Views: 2134

Answers (1)

Yuehai
Yuehai

Reputation: 1243

I am using

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>

SELECT ?o
WHERE 
{
  wd:Q3 schema:description ?o.
  FILTER ( lang(?o) = "en" )
}

now, since I am querying a Virtuoso Server with Full-Text-Search capabilities, and it would be better to retrieve the description with other properties in one go.

Upvotes: 4

Related Questions