Hi!
Thanks for your help, James. I'm now attempting
to use a SPARQL query,
and am having trouble returning the property labels. Here's the query
I'm using:
PREFIX entity: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?q ?q_label ?p ?p_label WHERE {
entity:Q170790 ?p ?q .
?q rdfs:label ?q_label FILTER (LANG(?q_label) = "en") .
OPTIONAL {?p rdfs:label ?p_label filter (lang(?p_label) = "en") .}
} LIMIT 100
You are using wrong entity as ?p. It is a bit complex here since what
one would colloquially call "property" is actually expressed as one
object and several relationships (see more here:
https://www.mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format#Properties).
Basically, ?p is something like wdt:P22 or p:P22, depending on which
properties of the object you look for. In your case probably wdt: since
statements have no labels. So you do something like this:
prefix wikibase: <http://wikiba.se/ontology#>
PREFIX entity: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?q ?q_label ?p ?p_label WHERE {
entity:Q170790 ?p ?q .
?q rdfs:label ?q_label FILTER (LANG(?q_label) = "en") .
?prop wikibase:directClaim ?p .
OPTIONAL {?prop rdfs:label ?p_label filter (lang(?p_label) = "en") .}
} LIMIT 100
i.e. you need an additional step from relationship represented by wdt:*
to the property object itself.
HTH,
--
Stas Malyshev
smalyshev(a)wikimedia.org