I'm trying to retrieve all labels and descriptions in different languages from a instances of a specific class from Wikidata.
I have followed the answer to a similar question (https://stackoverflow.com/a/49129274/3873799), which proposes the following approach:
SELECT DISTINCT *
WHERE
{
?item (ps:P31) wd:Q92275707
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".
?item rdfs:label ?label_EN.
?item schema:description ?desc_EN .
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "it".
?item rdfs:label ?label_IT.
?item schema:description ?desc_IT .
} hint:Prior hint:runLast false.
SERVICE wikibase:label { bd:serviceParam wikibase:language "de".
?item rdfs:label ?label_DE.
?item schema:description ?desc_DE .
} hint:Prior hint:runLast false.
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr".
?item rdfs:label ?label_FR.
?item schema:description ?desc_FR .
} hint:Prior hint:runLast false.
} LIMIT 100
Try full query here.
The problem with this query is that it returns nothing for descriptions; more importantly, I do not get the label that I would expect, but I always get a label in the form of statement/Q681554-7152e1c3-43a8-0b46-824d-62fd44d480ca
; why is that?
The result that I would expect is, for example taking Q681554:
- Label =
Toron
[English];Toron
[Italian]; nothing for the other languages. - Description =
castle ruin
[English]; nothing for the other languages.
Alternatively, the following approach (try query here):
SELECT DISTINCT *
{
?item wdt:P31 wd:Q92275707;
rdfs:label ?label;
schema:description ?desc
filter(lang(?label) = 'en' && lang(?desc) = 'en' || lang(?label) = 'it' && lang(?desc) = 'it' || lang(?label) = 'fr' && lang(?desc) = 'fr') #optional filtering
}
ORDER BY ?item
Does return the labels and descriptions in different languages, but the problem is that multiple rows are given per each of the different languages found for label/description.
How can these queries be corrected, and is there a preferred option, performance-wise?