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-series_timeline.sparql
Event-series aspect: timeline
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
#defaultView:Timeline
PREFIX target: <http://www.wikidata.org/entity/Q47501052>
SELECT
?time ?endtime ?event ?eventLabel ?image
?description
WITH {
SELECT DISTINCT ?event ?time ?endtime WHERE {
# It seems to be necessary to have this line together with the
# optional event time triples here.
?event wdt:P179 | wdt:P31 target: .
OPTIONAL { ?event wdt:P580 ?starttime . }
# If the endtime is not set, then use now as the end time
# However this does not show well if the event is in the future
# and no end date has been set.
OPTIONAL { ?event wdt:P582 ?endtime . }
# BIND(COALESCE(?endtime_, NOW()) AS ?endtime)
OPTIONAL { ?event wdt:P585 ?timepoint . }
# If start time is defined the disregard timepoint
BIND(COALESCE(?starttime, ?timepoint) AS ?time)
}
} AS %events1
WITH {
# Include significant events
SELECT ?event ?time ?description WHERE {
?event wdt:P179 | wdt:P31 target: .
?event p:P793 [ ps:P793 ?item ; pq:P585 ?time ] .
OPTIONAL {
?item rdfs:label ?description .
FILTER (LANG(?description) = "en")
}
}
} AS %events2
WHERE {
{ INCLUDE %events1 }
UNION
{ INCLUDE %events2 }
OPTIONAL { ?event wdt:P18 ?image . }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" .
}
}
graph TD