query-75f0b3613e34035485a13d9aebf4522a

rq turtle/ttl

Please help with filtering by non-constant language range 05:43, 4 May 2016 (UTC)) talk (Usien6 Thank you!! -- returning always blank. Sorry if this question sounds stupid, but it's my first SPARQL query and I have been struggling with this issue for several hours... ?stateLabelInLang, you'll see 35 and uncomment line 36 always comes in Portuguese. But, misteriously, if you try to comment out line ?stateLabelInLang is hard-coded, so that "pt", the language code 36 value of each result row. In the code below, line ?lang. I'm struggling, though, with getting the label that corresponds to the in several languages so that I need the label and article URL for every U.S. state or territory bash script for automatic translation of the table of results of the 2016 Democratic Party primariesDear folks, I'm trying to write a

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?stateId ?statehoodLabel ?stateFips ?lang ?stateLabelInLang ?stateArticleInLang WHERE {

    ?stateId wdt:P131 wd:Q30

  .
    ?stateId wdt:P31 ?statehoodId

  OPTIONAL
    {
        ?statehoodId rdfs:label ?statehoodLabel
      .
        FILTER (
          str( lang(?statehoodLabel) ) = str( "en" )
        )
    }

  .
    {
        ?stateId wdt:P883 ?stateFips
      .
        FILTER(
          REGEX(?stateFips, "^[A-Z][A-Z]$")
        )
    }

  .
    VALUES ?lang { "cs" "es" "fi" "fr" "it" "ja" "ko" "mr" "nl" "pl" "pt" "ru" "sv" }

  OPTIONAL
    {
        ?stateId rdfs:label ?stateLabelInLang
      .
        FILTER (
          #str( lang(?stateLabelInLang) ) = str( ?lang ) # <-------- Not working as expected...
          #LANGMATCHES(lang(?stateLabelInLang), str(?lang)) # <----- Won't work either...
          LANGMATCHES(lang(?stateLabelInLang), str("pt"))
        )
    }

  OPTIONAL
    {
        ?stateArticleInLang schema:about ?stateId
      .
        ?stateArticleInLang schema:inLanguage ?lang
      . FILTER (
        STRSTARTS(str(?stateArticleInLang), CONCAT("https://", ?lang, ".wikipedia.org/"))
      )
    }

#} ORDER BY ASC(?lang) DESC(?statehoodId) ASC(?stateFips) LIMIT 800 # Production closing
} ORDER BY DESC(?statehoodId) ASC(?stateFips) ASC(?lang) LIMIT 50 # Debug-friendly closing

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?lang"):::projected v4("?stateArticleInLang"):::projected v2("?stateFips"):::projected v7("?stateId"):::projected v5("?stateLabelInLang"):::projected v1("?statehoodId") v6("?statehoodLabel"):::projected c6(["wd:Q30"]):::iri v7 --"wdt:P131"--> c6 v7 --"wdt:P31"--> v1 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."rdfs:label".-> v6 end f0[["regex(?stateFips,'^#91;A-Z#93;#91;A-Z#93;$')"]] f0 --> v2 v7 --"wdt:P883"--> v2 bind1[/VALUES ?lang/] bind1-->v8 bind10(["cs"]) bind10 --> bind1 bind11(["es"]) bind11 --> bind1 bind12(["fi"]) bind12 --> bind1 bind13(["fr"]) bind13 --> bind1 bind14(["it"]) bind14 --> bind1 bind15(["ja"]) bind15 --> bind1 bind16(["ko"]) bind16 --> bind1 bind17(["mr"]) bind17 --> bind1 bind18(["nl"]) bind18 --> bind1 bind19(["pl"]) bind19 --> bind1 bind110(["pt"]) bind110 --> bind1 bind111(["ru"]) bind111 --> bind1 bind112(["sv"]) bind112 --> bind1 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v7 -."rdfs:label".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v4 -."schema:about".-> v7 v4 --"schema:inLanguage"--> v8 end