query-aca9e343d364d10ae423948853c7acbb

rq turtle/ttl

18:37, 10 January 2018 (UTC)) talk (Edgars2007 label (of course, there could be some kind of ranking - first from Latin based languages, then some Slavic, Japanase etc. etc.) from rdfs:label. There was once posted answer to such question, but I really can't find it :( --anySo basically: if item doesn't have label in Latvian or French, get Maybe this is a step towards what you ask for. The example objects are bridges with and without lv and fr labels.

Use at

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?item ?lv_label ?fr_label (SAMPLE(?any_label) AS ?any_label) (SAMPLE(?final_label) AS ?final_label) WHERE {
  values ?item {wd:Q125006 wd:Q1394625 wd:Q80593 wd:Q182945}
  OPTIONAL {?item rdfs:label ?lv_label . FILTER(lang(?lv_label)="lv") }
  OPTIONAL {?item rdfs:label ?fr_label . FILTER(lang(?fr_label)="fr") }
  ?item rdfs:label ?any_label . 
  BIND(IF(BOUND(?lv_label),?lv_label,IF(BOUND(?fr_label),?fr_label,?any_label)) AS ?final_label) 
}
GROUP BY ?item ?lv_label ?fr_label

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?any_label"):::projected v6("?final_label"):::projected v1("?fr_label"):::projected v3("?item"):::projected v2("?lv_label"):::projected bind0[/VALUES ?item/] bind0-->v3 bind00(["wd:Q125006"]) bind00 --> bind0 bind01(["wd:Q1394625"]) bind01 --> bind0 bind02(["wd:Q80593"]) bind02 --> bind0 bind03(["wd:Q182945"]) bind03 --> bind0 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."rdfs:label".-> v2 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."rdfs:label".-> v1 end v3 --"rdfs:label"--> v6 bind1[/"if(bound(?lv_label),?lv_label,if(bound(?fr_label),?fr_label,?any_label))"/] v2 --o bind1 v1 --o bind1 v6 --o bind1 bind1 --as--o v6 bind4[/"sample(?any_label)"/] v6 --o bind4 bind4 --as--o v6 bind5[/"sample(?final_label)"/] v6 --o bind5 bind5 --as--o v6