I have following problem which I explain on an example:
I want to retrieve the object Berlin
from the triplet Germany - capital - object
.
I must use labels, because those are inputs in my program.
Following query gives me back the propertyLabel capital
:
prefix wdt: <http://www.wikidata.org/prop/direct/>
prefix wikibase: <http://wikiba.se/ontology#>
prefix bd: <http://www.bigdata.com/rdf#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?propertyLabel WHERE {
?property a wikibase:Property .
?property rdfs:label "capital"@en
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .}
}
Following query with the label Germany
and URI P36 (capital)
gives me back the desired information Berlin
:
prefix wdt: <http://www.wikidata.org/prop/direct/>
prefix wikibase: <http://wikiba.se/ontology#>
prefix bd: <http://www.bigdata.com/rdf#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?objectLabel WHERE {
?subject wdt:P36 ?object .
?subject rdfs:label "Germany"@en .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .}
}
But I want to use P36
as a label. I tried various ways with two Selects or a Union, but i get thousands of results or none. The query should look like this (although this one doesn't work):
prefix wdt: <http://www.wikidata.org/prop/direct/>
prefix wikibase: <http://wikiba.se/ontology#>
prefix bd: <http://www.bigdata.com/rdf#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?objectLabel WHERE {
?subject ?property ?object .
?subject rdfs:label "Germany"@en .
?property a wikibase:Property .
?property rdfs:label "capital"@en
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .}
}
The query as already mentioned above has to return Berlin
and nothing else. Thanks in advance.