query-ad845d31e0b231782f7fcb28c472e4dd
Items without geolocation ordered by presence in Wikimedia projects (e.g. n. of Wikipedia pages)
authors: Valerio_Bozzolan, Yiyi
license: CC0
date: 2022
SELECT ?item ?itemLabel ?instanceFilterLabel ?areaLabel ?links WHERE { { SELECT ?item (SAMPLE(?instanceFilter) AS ?instanceFilter) (COUNT(?link) AS ?links) WHERE {
# apply territory filter (Milano)
?item (wdt:P131*) wd:Q490.
# item must be an instance of (of any subclass of) something we want
?item wdt:P31/wdt:P279* ?instanceFilter.
VALUES (?instanceFilter) {
# educational institution
(wd:Q2385804)
# park
(wd:Q22698)
}
# exclude items with coordinates or an headquarter or that are deprecated
MINUS {
?item wdt:P625|wdt:P159|wdt:P576 ?unusedinfo.
}
#OPTIONAL {
# links to Wikimedia projects
?link schema:about ?item.
#}
} # group by item so we can count their links GROUP BY ?item
ORDER BY DESC(?links)
LIMIT 100 }
# allow to read the area (subset of area filter) ?item wdt:P131 ?area.
# apply labels after aggregation SERVICE wikibase:label { bd:serviceParam wikibase:language "en,it,es,fr,de,pt" . } }
ORDER BY DESC(?links)
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 schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Items without geolocation ordered by presence in Wikimedia projects (e.g. n. of Wikipedia pages)
#
# authors: Valerio_Bozzolan, Yiyi
# license: CC0
# date: 2022
SELECT ?item ?itemLabel ?instanceFilterLabel ?areaLabel ?links WHERE { {
SELECT ?item (SAMPLE(?instanceFilter) AS ?instanceFilter) (COUNT(?link) AS ?links) WHERE {
# apply territory filter (Milano)
?item (wdt:P131*) wd:Q490.
# item must be an instance of (of any subclass of) something we want
?item wdt:P31/wdt:P279* ?instanceFilter.
VALUES (?instanceFilter) {
# educational institution
(wd:Q2385804)
# park
(wd:Q22698)
}
# exclude items with coordinates or an headquarter or that are deprecated
MINUS {
?item wdt:P625|wdt:P159|wdt:P576 ?unusedinfo.
}
#OPTIONAL {
# links to Wikimedia projects
?link schema:about ?item.
#}
}
# group by item so we can count their links
GROUP BY ?item
ORDER BY DESC(?links)
LIMIT 100
}
# allow to read the area (subset of area filter)
?item wdt:P131 ?area.
# apply labels after aggregation
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,it,es,fr,de,pt" . }
}
ORDER BY DESC(?links)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?area")
v6("?instanceFilter")
v2("?item"):::projected
v5("?link")
v6("?links"):::projected
v4("?unusedinfo")
a1((" "))
c10(["bd:serviceParam"]):::iri
c12(["en,it,es,fr,de,pt"]):::literal
c2(["wd:Q490"]):::iri
v2 --"wdt:P131"--> c2
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> v6
bind0[/VALUES ?instanceFilter/]
bind0-->v6
bind00(["wd:Q2385804"])
bind00 --> bind0
bind01(["wd:Q22698"])
bind01 --> bind0
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P576"--> v4
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P159"--> v4
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P625"--> v4
end
union0r <== or ==> union0l
end
end
v5 --"schema:about"--> v2
bind4[/"sample(?instanceFilter)"/]
v6 --o bind4
bind4 --as--o v6
bind5[/"count(?link)"/]
v5 --o bind5
bind5 --as--o v6
v2 --"wdt:P131"--> v6
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end