Skip to content

Instantly share code, notes, and snippets.

@sbma44
Last active May 10, 2016 01:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbma44/b6f1c25a074ece5757349b413c78162c to your computer and use it in GitHub Desktop.
Save sbma44/b6f1c25a074ece5757349b413c78162c to your computer and use it in GitHub Desktop.
wikidata SPARQL queries, both for the USA (Q30)
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?flag ?seal ?coatofarms ?population ?website ?anthem ?article
WHERE {
OPTIONAL { ?location wdt:P1082 ?population . }
OPTIONAL { ?location wdt:P41 ?flag . }
OPTIONAL { ?location wdt:P94 ?coatofarms . }
OPTIONAL { ?location wdt:P158 ?seal . }
OPTIONAL { ?location wdt:P856 ?website }
OPTIONAL { ?location wdt:P85 ?anthem . }
{
?article schema:about ?location .
?article schema:inLanguage "en" .
FILTER (SUBSTR(str(?article), 1, 25) = "https://en.wikipedia.org/")
}
FILTER (?location IN (wd:Q30)) .
}
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?movie ?movieLabel ?netflix ?imdb
WHERE {
?movie wdt:P840 ?location .
?movie wdt:P345 ?imdb .
?movie wdt:P31 wd:Q11424 .
OPTIONAL {
?movie wdt:P1874 ?netflix .
}
FILTER (?location IN (wd:Q30)) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY DESC(?imdb) ASC(?movieLabel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment