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/complex_articles-recent.sparql
Complex aspect: articles recent
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 wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX target: <http://www.wikidata.org/entity/Q90012272>
SELECT ?date ?work ?workLabel
?topicsUrl ?topics
WITH {
SELECT DISTINCT ?work WHERE {
VALUES ?complex { target: }
?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) ?complex .
}
} AS %works
WITH {
SELECT (MAX(?dates) as ?datetime) ?work (GROUP_CONCAT(DISTINCT ?topic_label; separator=" // ") AS ?topics)
(CONCAT("../topics/", GROUP_CONCAT(DISTINCT SUBSTR(STR(?topic), 32); separator=",")) AS ?topicsUrl)
WHERE {
INCLUDE %works
?work wdt:P921 ?topic .
OPTIONAL { ?work wdt:P577 ?dates . }
?topic rdfs:label ?topic_label . FILTER (lang(?topic_label) = 'en')
}
GROUP BY ?work
} AS %result
WHERE {
INCLUDE %result
# There is a problem with BC dates
# BIND(xsd:date(?datetime) AS ?date)
BIND(REPLACE(STR(?datetime), 'T.*', '') AS ?date)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
}
GROUP BY ?date ?work ?workLabel ?topicsUrl ?topics
ORDER BY DESC(?date)
LIMIT 500
graph TD