query-da3abbfa6346107e968b7ffa91f96256

rq turtle/ttl

TODO

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 (
          lang(?statehoodLabel) = "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(?stateLabelInLang, ?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 c5(["wd:Q30"]):::iri v7 --"wdt:P131"--> c5 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