query-4afaa8db691fefeb42e3fd2f2be52fc7
Forts with English and any possible foreign names
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#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT DISTINCT ?item ?itemLabel ?en_label ?label WHERE {
SELECT DISTINCT ?item ?en_label (SAMPLE(COALESCE(?en_label, ?item_label)) as ?label) WHERE {
?item p:P31 ?statement0.
?statement0 (ps:P31/(wdt:P279*)) wd:Q1785071.
OPTIONAL {?item rdfs:label ?en_label . FILTER(LANG(?en_label) = "en")}
OPTIONAL {?item rdfs:label ?item_label}
#?item wdt:P17 wd:Q794.
}
GROUP BY ?item ?en_label
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?en_label"):::projected
v2("?item"):::projected
v4("?item_label")
v5("?label"):::projected
v3("?statement0")
a1((" "))
c5(["wd:Q1785071"]):::iri
v2 --"p:P31"--> v3
v3 --"p:statement/P31"--> a1
a1 --"p:direct/P279"--> c5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."rdfs:label".-> v1
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."rdfs:label".-> v4
end
bind1[/"sample(?en_label?item_label)"/]
v1 --o bind1
v4 --o bind1
bind1 --as--o v5