query-dc617efe237c348b3b3d521588ae8ca2
Get label in any language if it's not available in predefined languagesI currently have such query:
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item (IF(REGEX(STR(?itemLabel), "^Q[0-9]+$"),?label,?itemLabel) as ?final_label) WHERE {
values ?item {wd:Q40006707 wd:Q30345737 }
SERVICE wikibase:label { bd:serviceParam wikibase:language "lv, fr" . }
?item rdfs:label ?label .
}
#group by ?item
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?final_label")
v1("?item"):::projected
v2("?label"):::projected
c2(["bd:serviceParam"]):::iri
c4(["lv, fr"]):::literal
bind0[/VALUES ?item/]
bind0-->v1
bind00(["wd:Q40006707"])
bind00 --> bind0
bind01(["wd:Q30345737"])
bind01 --> bind0
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v1 --"rdfs:label"--> v2
bind1[/"if(regex(str(?itemLabel),'^Q#91;0-9#93;+$'),?label,?itemLabel)"/]
null --o bind1
v2 --o bind1
bind1 --as--o v3