query-6580e15483b95a82ccd31699240228db
find items that have:
1 - only one alias in fralias
AND
2 - labels in en AND fr AND de
SELECT ?item (COUNT(?aliases) AS ?aliases_count) WHERE { ?item wdt:P31 wd:Q55488 . ?item skos:altLabel ?aliases . # this gets the aliases BIND(LANG(?aliases) AS ?aliases_lg) { SELECT ?item (COUNT(?labels_lg) AS ?labels_lg_count) WHERE { VALUES ?lg {"fr" "en" "de"} ?item wdt:P31 wd:Q55488 . ?item rdfs:label ?labels . # this gets the labels BIND(LANG(?labels) AS ?labels_lg)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
FILTER(?labels_lg IN (?lg)) }
GROUP BY ?item HAVING(?labels_lg_count = 3) }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
FILTER(?aliases_lg = "fr") } GROUP BY (?item) HAVING(?aliases_count = 1)
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# find items that have:
# 1 - only one alias in fralias
# AND
# 2 - labels in en AND fr AND de
SELECT
?item
(COUNT(?aliases) AS ?aliases_count)
WHERE {
?item wdt:P31 wd:Q55488 .
?item skos:altLabel ?aliases . # this gets the *aliases*
BIND(LANG(?aliases) AS ?aliases_lg)
{
SELECT ?item (COUNT(?labels_lg) AS ?labels_lg_count)
WHERE {
VALUES ?lg {"fr" "en" "de"}
?item wdt:P31 wd:Q55488 .
?item rdfs:label ?labels . # this gets the *labels*
BIND(LANG(?labels) AS ?labels_lg)
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
FILTER(?labels_lg IN (?lg)) }
GROUP BY ?item
HAVING(?labels_lg_count = 3)
}
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
FILTER(?aliases_lg = "fr")
}
GROUP BY (?item)
HAVING(?aliases_count = 1)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?aliases"):::projected
v9("?aliases_count")
v5("?aliases_lg")
v3("?item"):::projected
v8("?labels")
v9("?labels_lg")
v9("?labels_lg_count")
v8("?lg")
c4(["wd:Q55488"]):::iri
f0[["?aliases_count = '1^^xsd:integer'"]]
f0 --> v9
f1[["?aliases_lg = 'fr'"]]
f1 --> v5
v3 --"wdt:P31"--> c4
v3 --"skos:altLabel"--> v4
bind2[/"?aliases"/]
v4 --o bind2
bind2 --as--o v5
f3[["?labels_lg_count = '3^^xsd:integer'"]]
f3 --> v9
f4[["?labels_lg = ?lg"]]
f4 --> v9
f4 --> v8
bind5[/VALUES ?lg/]
bind5-->v8
bind50(["fr"])
bind50 --> bind5
bind51(["en"])
bind51 --> bind5
bind52(["de"])
bind52 --> bind5
v3 --"wdt:P31"--> c4
v3 --"rdfs:label"--> v8
bind6[/"?labels"/]
v8 --o bind6
bind6 --as--o v9
bind8[/"count(?labels_lg)"/]
v9 --o bind8
bind8 --as--o v9
bind10[/"count(?aliases)"/]
v4 --o bind10
bind10 --as--o v9