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/author_list-of-publications.sparql
Author aspect: list of publications
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#>
#defaultView:Table
PREFIX target: <http://www.wikidata.org/entity/Q97270>
SELECT
(MIN(?dates) AS ?date)
?work ?workLabel
(GROUP_CONCAT(DISTINCT ?type_label; separator=", ") AS ?type)
(SAMPLE(?pages_) AS ?pages)
?venue ?venueLabel
(GROUP_CONCAT(DISTINCT ?author_label; separator=", ") AS ?authors)
(CONCAT("../authors/", GROUP_CONCAT(DISTINCT SUBSTR(STR(?author), 32); separator=",")) AS ?authorsUrl)
WHERE {
?work wdt:P50 target: .
?work wdt:P50 ?author .
OPTIONAL {
?author rdfs:label ?author_label_ . FILTER (LANG(?author_label_) = 'en')
}
BIND(COALESCE(?author_label_, SUBSTR(STR(?author), 32)) AS ?author_label)
OPTIONAL { ?work wdt:P31 ?type_ . ?type_ rdfs:label ?type_label . FILTER (LANG(?type_label) = 'en') }
?work wdt:P577 ?datetimes .
BIND(xsd:date(?datetimes) AS ?dates)
OPTIONAL { ?work wdt:P1104 ?pages_ }
OPTIONAL { ?work wdt:P1433 ?venue }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
}
GROUP BY ?work ?workLabel ?venue ?venueLabel
ORDER BY DESC(?date)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?author")
v6("?author_label"):::projected
v3("?author_label_")
v14("?authors")
v15("?authorsUrl")
v12("?date")
v9("?dates"):::projected
v8("?datetimes")
v13("?pages")
v10("?pages_"):::projected
v12("?type")
v7("?type_")
v2("?type_label"):::projected
v11("?venue"):::projected
v4("?work"):::projected
c3([http://www.wikidata.org/entity/Q97270]):::iri
c12(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
c10([http://www.bigdata.com/rdf#serviceParam]):::iri
v4 --"p:direct/P50"--> c3
v4 --"p:direct/P50"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."rdfs:label".-> v3
end
bind0[/"?author_label_substring(str(?author),'32^^xsd:integer')"/]
v3 --o bind0
v5 --o bind0
bind0 --as--o v6
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P31".-> v7
v7 --"rdfs:label"--> v2
end
v4 --"p:direct/P577"--> v8
bind1[/"http://www.w3.org/2001/XMLSchema#date(?datetimes)"/]
v8 --o bind1
bind1 --as--o v9
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P1104".-> v10
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P1433".-> v11
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end
bind7[/"min(?dates)"/]
v9 --o bind7
bind7 --as--o v12
bind8[/"?type_label"/]
v2 --o bind8
bind8 --as--o v12
bind9[/"sample(?pages_)"/]
v10 --o bind9
bind9 --as--o v13
bind10[/"?author_label"/]
v6 --o bind10
bind10 --as--o v14
bind11[/"concat('../authors/',)"/]
null --o bind11
bind11 --as--o v15