query-75f0b3613e34035485a13d9aebf4522a
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
- https://query.wikidata.org/sparql
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