A set of SPARQL examples that are used in different TGX resources
License: https://www.gnu.org/licenses/gpl-3.0
Uses method in: https://github.com/WDscholia/scholia/tree/master/scholia/app/templates/country_narrative-locations.sparql
Country aspect: Narrative locations for a specific country
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
# title: Narrative locations for a specific country
PREFIX target: <http://www.wikidata.org/entity/Q35>
#defaultView:Map{"markercluster":true}.
SELECT
?location ?locationLabel
?work ?workLabel
?geo
?layer
WITH {
SELECT DISTINCT ?location ?work ?geo ?layer WHERE {
?location wdt:P17 target: .
# Geocoordinates may possible be under a headquarter property
?location wdt:P159? / wdt:P625 ?geo.
?work wdt:P840 ?location .
# Filter encyclopedic articles - that may not be so relevant
FILTER NOT EXISTS { ?work wdt:P31 wd:Q17329259 }
OPTIONAL { ?work wdt:P31 / rdfs:label ?layer . FILTER (LANG(?layer) = 'en') }
}
} AS %results
WHERE {
INCLUDE %results
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en,da,de,es,fr,jp,nl,no,ru,sv,zh". }
}
graph TD