query-42cbb2618098ff90aac7cb0521f5fd57
This version tries to get script from the article about the wiki, if known, but there is a little overcounting because 2-3 wikis have multiple scripts listed.
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?article ?letter ?name ?lang ?wikiLabel ?scriptLabel WHERE
{
?article schema:about wd:Q16520 . ?article schema:name ?name . ?article schema:inLanguage ?lang . ?article schema:isPartOf ?x .
FILTER CONTAINS(str(?x), "wikipedia") . # only Wikipedias
optional { filter(STRSTARTS(?name, 'B')) . bind('B' as ?letter) } # title starts with B
optional { filter(STRSTARTS(?name, 'P')) . bind('P' as ?letter) } # title starts with P
optional { ?wiki wdt:P856 ?x . optional { ?wiki wdt:P282 ?script . } } # find script of Wikipedia
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?letter ?name
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?article"):::projected
v5("?lang"):::projected
v6("?letter"):::projected
v2("?name"):::projected
v7("?script")
v6("?wiki")
v3("?x")
c12(["bd:serviceParam"]):::iri
c14(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c5(["wd:Q16520"]):::iri
f0[["contains(str(?x),'wikipedia')"]]
f0 --> v3
v4 --"schema:about"--> c5
v4 --"schema:name"--> v2
v4 --"schema:inLanguage"--> v5
v4 --"schema:isPartOf"--> v3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
bind1[/"'B'"/]
bind1 --as--o v6
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
bind2[/"'P'"/]
bind2 --as--o v6
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wdt:P856".-> v3
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wdt:P282".-> v7
end
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c12 --"wikibase:language"--> c14
end