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/printer_works.sparql
Printer aspect: works
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
# List of printed works by date
PREFIX target: <http://www.wikidata.org/entity/Q85200459>
SELECT
?date
?work ?workLabel (CONCAT("/work/", SUBSTR(STR(?work), 32)) AS ?workUrl)
?example_author ?example_authorLabel (CONCAT("/author/", SUBSTR(STR(?example_author), 32)) AS ?example_authorUrl)
WHERE {
{
SELECT
(MIN(?date_) AS ?date)
?work
(SAMPLE(?author) AS ?example_author)
WHERE {
?work wdt:P872 target: .
OPTIONAL { ?work wdt:P577 ?datetime . BIND(xsd:date(?datetime) AS ?date_) }
OPTIONAL { ?work wdt:P50 ?author }
}
GROUP BY ?work
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
}
ORDER BY DESC(?date)
LIMIT 1000
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?author")
v6("?date"):::projected
v4("?date_")
v3("?datetime")
v6("?example_author"):::projected
v8("?example_authorUrl")
v2("?work"):::projected
v7("?workUrl")
c6([http://www.bigdata.com/rdf#serviceParam]):::iri
c2([http://www.wikidata.org/entity/Q85200459]):::iri
c8(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
v2 --"p:direct/P872"--> c2
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P577".-> v3
bind0[/"http://www.w3.org/2001/XMLSchema#date(?datetime)"/]
v3 --o bind0
bind0 --as--o v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P50".-> v5
end
bind3[/"min(?date_)"/]
v4 --o bind3
bind3 --as--o v6
bind4[/"sample(?author)"/]
v5 --o bind4
bind4 --as--o v6
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c6 --"wikibase:language"--> c8
end
bind5[/"concat('/work/',substring(str(?work),'32^^xsd:integer'))"/]
v2 --o bind5
bind5 --as--o v7
bind6[/"concat('/author/',substring(str(?example_author),'32^^xsd:integer'))"/]
v6 --o bind6
bind6 --as--o v8