sparql-examples

A set of SPARQL examples that are used in different TGX resources

View the Project on GitHub BiGCAT-UM/sparql-examples

061

rq turtle/ttl

Country aspect: Narrative locations for a specific country

Use at

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