'Wikidata Query Service: lookup property label
How do I form the query to look up the English label of a property on a given entity.
This query provides the ID of P31:
SELECT ?item ?itemLabel ?instance_of WHERE {
?item wdt:P646 "/m/09c7w0".
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
OPTIONAL {
?item wdt:P31 ?instance_of.}
}
}
LIMIT 1
How can I get the label of P31 instead?
Also, is there a smart way to get the "best" value of P31, possibly the one with the lowest numeric ID? Some detailed entities have very noisy values. For example, for Q30, "United States" I would prefer to see "country" as my instance_of instead of "member state of the United Nations".
Solution 1:[1]
Thanks AKSW. label service applies to the property given a variable with the matching suffix Label:
SELECT ?item ?itemLabel ?instance_of ?instance_ofLabel WHERE {
?item wdt:P646 "/m/09c7w0".
OPTIONAL {
?item wdt:P31 ?instance_of.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
LIMIT 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bhan |
