query-d9a34e8688cafda108bbc9dfe80456db
17:08, 20 October 2020 (UTC)) talk (Shisma--I think I've got it:
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?item ?anidb WHERE {
{ ?item wdt:P31 wd:Q80447738. }
UNION
{ ?item wdt:P31 wd:Q87576284. }
OPTIONAL { ?item wdt:P5648 ?_anidb. }
?item rdfs:label ?itemLabel.
FILTER (lang(?itemLabel) = 'en')
BIND(
IF(!BOUND(?_anidb),
CONCAT("[https://anidb.net/character/?do.search=1&adb.search=",REPLACE(?itemLabel, " ", "%20", "i")," 🔎]"),
CONCAT("[https://anidb.net/character/",?_anidb," ",?_anidb,"]")
)
AS ?anidb)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?_anidb")
v4("?anidb"):::projected
v2("?item"):::projected
v1("?itemLabel")
c4(["wd:Q87576284"]):::iri
c3(["wd:Q80447738"]):::iri
f0[["?itemLabel = 'en'"]]
f0 --> v1
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P31"--> c4
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P31"--> c3
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P5648".-> v3
end
v2 --"rdfs:label"--> v1
bind1[/"if(not bound(?_anidb),concat('#91;https://anidb.net/character/?do.search=1&adb.search=',replace(?itemLabel,' ','%20','i'),' 🔎#93;'),concat('#91;https://anidb.net/character/',?_anidb,' ',?_anidb,'#93;'))"/]
v3 --o bind1
v1 --o bind1
bind1 --as--o v4