query-77032902a47360079788c2778b42f4ca
Find multiple labels with exact values in multiple languages SELECT ?s ?label ?lc ?lang ?desc WITH { SELECT DISTINCT ?lc WHERE { [] wdt:P424 ?lc . FILTER (!wikibase:isSomeValue(?lc)) } } AS %lcs WHERE { INCLUDE %lcs # Efficiency might degrade rapidly with the amount of strings to search for, so just do a few at a time VALUES ?thing { "Allegory of the Cave" "Gertrude Stein" } BIND (STRLANG(?thing, ?lc) AS ?label) ?s rdfs:label ?label . OPTIONAL { ?lang_ wdt:P424 ?lc ; wdt:P305 ?lc . ?lang_ rdfs:label ?lang . FILTER(LANG(?lang)="en") } OPTIONAL { ?s schema:description ?desc. FILTER(LANG(?desc)=?lc) } FILTER NOT EXISTS { ?s wdt:P821 []. } # Doesn't already have a P821 statement } ORDER BY ?s
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
# Find multiple labels with exact values in multiple languages
SELECT ?s ?label ?lc ?lang ?desc
WHERE {
{ SELECT DISTINCT ?lc WHERE {
[] wdt:P424 ?lc . FILTER (!wikibase:isSomeValue(?lc))
} } # Efficiency might degrade rapidly with the amount of strings to search for, so just do a few at a time
VALUES ?thing { "Allegory of the Cave" "Gertrude Stein" }
BIND (STRLANG(?thing, ?lc) AS ?label)
?s rdfs:label ?label .
OPTIONAL {
?lang_ wdt:P424 ?lc ;
wdt:P305 ?lc .
?lang_ rdfs:label ?lang . FILTER(LANG(?lang)="en")
}
OPTIONAL { ?s schema:description ?desc. FILTER(LANG(?desc)=?lc) }
FILTER NOT EXISTS { ?s wdt:P821 []. } # Doesn't already have a P821 statement
}
ORDER BY ?s
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?desc"):::projected
v6("?label"):::projected
v4("?lang"):::projected
v7("?lang_")
v3("?lc"):::projected
v1("?s"):::projected
v5("?thing")
a2((" "))
a1((" "))
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"wdt:P821"--> e0a1
e0v1("?s"):::projected
e0a1((" ")):::projected
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> c1
f0 --> a1
v1 --"wdt:P821"--> a1
f1[["not http://wikiba.se/ontology#isSomeValue(?lc)"]]
f1 --> v3
a2 --"wdt:P424"--> v3
bind2[/VALUES ?thing/]
bind2-->v5
bind20(["Allegory of the Cave"])
bind20 --> bind2
bind21(["Gertrude Stein"])
bind21 --> bind2
bind3[/"STRLANG(?thing,?lc)"/]
v5 --o bind3
v3 --o bind3
bind3 --as--o v6
v1 --"rdfs:label"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v7 -."wdt:P424".-> v3
v7 --"wdt:P305"--> v3
v7 --"rdfs:label"--> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."schema:description".-> v2
end