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/event_past-events.sparql
Event aspect: past events
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?time ?short_name
?event ?eventLabel (CONCAT("/event/", SUBSTR(STR(?event), 32)) AS ?eventUrl)
?location ?locationLabel (CONCAT("/location/", SUBSTR(STR(?location), 32)) AS ?locationUrl)
WITH {
SELECT DISTINCT ?event WHERE {
# This union seems to be faster than a VALUES-based query
{ ?event wdt:P31 / wdt:P279* wd:Q52260246 . }
UNION
{ ?event wdt:P31 / wdt:P279* wd:Q46855 . }
}
} AS %events
WITH {
SELECT
?event
(xsd:date(MIN(?times)) AS ?time)
(SAMPLE(?locations) AS ?location)
(SAMPLE(?short_names) AS ?short_name)
WHERE {
INCLUDE %events
?event wdt:P580 | wdt:P585 ?times .
FILTER (?times < NOW())
OPTIONAL { ?event wdt:P276 ?locations }
OPTIONAL { ?event wdt:P1813 ?short_names }
}
GROUP BY ?event
} AS %result
WHERE {
INCLUDE %result
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en,da,de,fr,jp,nl,no,pl,ru,sv,zh". }
}
ORDER BY DESC(?time)
LIMIT 200
graph TD