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_associated-images.sparql
Author aspect: associated images
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://wikidata.org/entity/>
#defaultView:ImageGrid
PREFIX target: <http://www.wikidata.org/entity/Q97270>
SELECT DISTINCT ?image WHERE {
{
# Images of the person
target: wdt:P18 ?image .
}
UNION {
# Images from whatever property value is linked.
# Excluded "different from" property and take all other properties
target: !wdt:P1889 ?item .
?item wdt:P18 ?image .
# All people are humans, so these images are excluded.
FILTER (?item != wd:Q5)
}
UNION {
# Images associated with works of the author, both direct images,
# images of topics of the works and images of coauthors.
target: ^wdt:P50 / (wdt:P921* | wdt:P50) / wdt:P18 ?image .
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?image"):::projected
v2("?item")
a1((" "))
a2((" "))
a3((" "))
c1(["wd:Q97270"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
a2 --"p:direct/P50"--> c1
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
a2 --"p:direct/P50"--> a3
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
a2 --"p:direct/P921"--> a3
end
union2r <== or ==> union2l
end
a3 --"p:direct/P18"--> v1
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
f0[["?item != http://wikidata.org/entity/Q5"]]
f0 --> v2
f1[[" != 'p:direct/P1889'"]]
f1 --> a1
c1 -->a1--> v2
v2 --"p:direct/P18"--> v1
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
c1 --"p:direct/P18"--> v1
end
union0r <== or ==> union0l
end