Skip to content

Instantly share code, notes, and snippets.

@jindrichmynarz
Created January 21, 2016 11:04
Show Gist options
  • Select an option

  • Save jindrichmynarz/9f3ae84588919a17e6aa to your computer and use it in GitHub Desktop.

Select an option

Save jindrichmynarz/9f3ae84588919a17e6aa to your computer and use it in GitHub Desktop.
Prime ministers from Wikidata
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX q: <http://www.wikidata.org/prop/qualifier/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT DISTINCT ?countryLabel ?primeMinisterLabel
WHERE {
?country p:P31 ?countryStatement .
?countryStatement v:P31 wd:Q6256 . # Find all countries
FILTER NOT EXISTS {
?countryStatement q:P582 ?x . # Filter out countries with dissolution date
}
?country p:P6 ?primeMinisterStatement .
?primeMinisterStatement v:P6 ?primeMinister . # Find prime minister for each country
FILTER NOT EXISTS {
?primeMinisterStatement q:P582 ?x . # Filter out prime ministers, whose term ended
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "cs,en" . # Add Czech labels (fallback on English ones)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment