query-e276c961cfff93bc1733cf6ba92c6dc7
"Overlay" Wikidata items with skos:broader relations imported from STW
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX bd: <http://www.bigdata.com/rdf#>
select ?wd ?wdLabel ?wdBroader ?wdBroaderLabel
where {
# seems to do not work with query optimization
# sparql endpoint of external thesaurus
service <http://zbw.eu/beta/sparql/stw/query> {
select ?stwId ?stwBroaderId
where {
?stw skos:broader ?stwBroader .
filter(strstarts(str(?stw), 'http://zbw.eu/stw/descriptor/'))
filter(strstarts(str(?stwBroader), 'http://zbw.eu/stw/descriptor/'))
bind(strafter(str(?stw), 'http://zbw.eu/stw/descriptor/') as ?stwId)
bind(strafter(str(?stwBroader), 'http://zbw.eu/stw/descriptor/') as ?stwBroaderId)
}
}
?wd wdt:P3911 ?stwId .
?wdBroader wdt:P3911 ?stwBroaderId .
service wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?stw")
v1("?stwBroader")
v4("?stwBroaderId")
v3("?stwId")
v5("?wd"):::projected
v6("?wdBroader"):::projected
c6(["bd:serviceParam"]):::iri
c8(["en"]):::literal
subgraph s1["http://zbw.eu/beta/sparql/stw/query"]
style s1 stroke-width:4px;
f0[["starts-with(str(?stwBroader),'http://zbw.eu/stw/descriptor/')"]]
f0 --> v1
f1[["starts-with(str(?stw),'http://zbw.eu/stw/descriptor/')"]]
f1 --> v2
v2 --"skos:broader"--> v1
bind2[/"substring-after(str(?stw),'http://zbw.eu/stw/descriptor/')"/]
v2 --o bind2
bind2 --as--o v3
bind3[/"substring-after(str(?stwBroader),'http://zbw.eu/stw/descriptor/')"/]
v1 --o bind3
bind3 --as--o v4
end
v5 --"wdt:P3911"--> v3
v6 --"wdt:P3911"--> v4
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c6 --"wikibase:language"--> c8
end