User:Danysan/Wiki QA
Useful tools for wikidata=* / wikipedia=* quality assurance
Tools
- Wikidata#Tools
- OSM ↔ Wikidata matcher
- OSM-wikipedia-tag-validator => OSM-wikipedia-tag-validator-reports
Useful Sophox SPARQL queries
Model inside the wrong key
Query to find historic=* elements where the model of an aircarft/vehicle/... is erroneously linked with wikidata=* instead of model:wikidata=* or with wikipedia=* instead of model:wikipedia=* (problem described in Proposed features/Manufacturer and Model#Current_situation).
#defaultView:Map
SELECT
?osm
?model
?modelLabel
?wikipedia
(GROUP_CONCAT(DISTINCT ?classLabel; SEPARATOR=", ") AS ?classLabels)
(?type AS ?layer)
?coordinates
WHERE {
hint:Query hint:optimizer "None" . # Prevent optimizer from querying for everything tagged with wikidata=* before querying the service.
# Filter for historic=*
VALUES ?type { "tank" "vehicle" "aircraft" "ship" "locomotive" "railway_car" "cannon" }
?osm osmt:historic ?type;
osmm:loc ?coordinates.
{
?osm osmt:wikidata ?model.
} UNION {
?osm osmt:wikipedia ?wikipedia.
SERVICE <https://query.wikidata.org/sparql> {
?wikipedia schema:about ?model.
}
}
SERVICE <https://query.wikidata.org/sparql> {
?model wdt:P279 ?class. # Filter for subclasses ( => representing a class, not a single object)
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?model rdfs:label ?modelLabel. # Get model name
?class rdfs:label ?classLabel. # Get class name
}
}
}
GROUP BY ?osm ?type ?model ?modelLabel ?wikipedia ?coordinates
Bad values for wikidata=*:
SELECT DISTINCT ?model
WHERE {
VALUES ?type { "tank" "vehicle" "aircraft" "ship" "locomotive" "railway_car" "cannon" }
?osm osmt:historic ?type;
osmm:loc ?coordinates;
osmt:wikidata ?model.
SERVICE <https://query.wikidata.org/sparql> {
?model wdt:P279 ?class. # Filter for subclasses ( => representing a class, not a single object)
}
}
ORDER BY ?model
Bad values for wikipedia=*:
SELECT DISTINCT ?wikipedia
WHERE {
VALUES ?type { "tank" "vehicle" "aircraft" "ship" "locomotive" "railway_car" "cannon" }
?osm osmt:historic ?type;
osmm:loc ?coordinates;
osmt:wikipedia ?wikipedia.
SERVICE <https://query.wikidata.org/sparql> {
?wikipedia schema:about ?model.
?model wdt:P279 ?class. # Filter for subclasses ( => representing a class, not a single object)
}
}
ORDER BY ?wikipedia
Brand inside the wrong key
Restaurants and fast foods
Query to find restaurants and fast foods where the brand is erroneously linked with wikidata=* instead of brand:wikidata=* or with wikipedia=* instead of brand:wikipedia=* (inspired by Sophox#Current_Challenges).
#defaultView:Map
SELECT DISTINCT ?osm ?chain ?chainLabel ?wikipedia ?loc (?type AS ?layer)
WHERE {
SERVICE <https://query.wikidata.org/sparql> {
VALUES ?chainClass { wd:Q18509232 wd:Q18534542 wd:Q76220181 } # Fast food chain / Restaurant chain / Ice cream chain
?chain wdt:P31 ?chainClass.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?chain rdfs:label ?chainLabel.
}
}
VALUES ?type { "bar" "cafe" "restaurant" "fast_food" "food_court" "ice_cream" }
?osm osmt:amenity ?type;
osmm:loc ?loc .
{
?osm osmt:wikidata ?chain.
} UNION {
?osm osmt:wikipedia ?wikipedia.
SERVICE <https://query.wikidata.org/sparql> {
?wikipedia schema:about ?chain.
}
}
}
Banks and ATMs
Query to find banks and ATMs where the brand is erroneously linked with wikidata=* instead of brand:wikidata=* or with wikipedia=* instead of brand:wikipedia=*. If the wikidata object for the bank has the position set (with P625) the query correctly prevents the headquarters of the bank from showing in the result.
#defaultView:Map
SELECT DISTINCT ?osm ?bank ?bankLabel ?wikipedia ?coordinates (?type AS ?layer)
WHERE {
VALUES ?type { "bank" "atm" }
?osm osmt:amenity ?type;
osmm:loc ?coordinates.
{
?osm osmt:wikidata ?bank.
} UNION {
?osm osmt:wikipedia ?wikipedia.
SERVICE <https://query.wikidata.org/sparql> {
?wikipedia schema:about ?bank.
}
}
SERVICE <https://query.wikidata.org/sparql> {
VALUES ?bankClass { wd:Q650241 wd:Q22687 } # banks / Financial institutions
?bank wdt:P31 ?bankClass.
OPTIONAL {
{
?bank wdt:P625 ?bankHeadquarters.
} UNION {
?bank p:P159/pq:P625 ?bankHeadquarters.
}
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?bank rdfs:label ?bankLabel.
}
}
BIND(geof:distance(COALESCE(?bankHeadquarters,"Point(0 0)"^^geo:wktLiteral), ?coordinates) AS ?distance).
FILTER(?distance > 1). # Exclude the headquarters from the result
}
Subject inside the wrong key
Query to find historic elements where the subject is a person erroneously linked with wikidata=* instead of subject:wikidata=* or with wikipedia=* instead of subject:wikipedia=*.
#defaultView:Map
SELECT DISTINCT ?osm ?person ?personLabel ?wikipedia ?coordinates (?type AS ?layer)
WHERE {
VALUES ?type { "memorial" "monument" }
?osm osmt:historic ?type;
osmm:loc ?coordinates.
{
?osm osmt:wikidata ?person.
} UNION {
?osm osmt:wikipedia ?wikipedia.
SERVICE <https://query.wikidata.org/sparql> {
?wikipedia schema:about ?person.
}
}
SERVICE <https://query.wikidata.org/sparql> {
?person wdt:P31 wd:Q5.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?person rdfs:label ?personLabel.
}
}
}
Etymology inside the wrong key
Primary highways
Query to find primary highways where the etymology of the name is a person erroneously linked with wikidata=* instead of name:etymology:wikidata=*.
#defaultView:Map
SELECT DISTINCT ?osm ?osmLabel ?person ?personLabel ?wikipedia ?coordinates (?type AS ?layer)
WHERE {
?osm osmt:highway "primary";
osmt:wikidata ?person;
osmt:name ?osmLabel;
osmm:loc ?coordinates.
SERVICE <https://query.wikidata.org/sparql> {
?person wdt:P31 wd:Q5.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?person rdfs:label ?personLabel.
}
}
}
All highways - Wikidata
Query to find all highways where the etymology of the name is a person erroneously linked with wikidata=* instead of name:etymology:wikidata=*.
#defaultView:Map
SELECT DISTINCT ?osm ?osmLabel ?person ?personLabel ?coordinates
WHERE {
?osm osmt:highway [];
osmt:wikidata ?person;
osmt:name ?osmLabel;
osmm:loc ?coordinates.
SERVICE <https://query.wikidata.org/sparql> {
?person wdt:P31 wd:Q5.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?person rdfs:label ?personLabel.
}
}
}
All highways - Wikipedia
Query to find all highways where the etymology of the name is a person erroneously linked with wikipedia=* instead of name:etymology:wikipedia=*.
#defaultView:Map
SELECT DISTINCT ?osm ?osmLabel ?person ?personLabel ?wikipedia ?coordinates
WHERE {
?osm osmt:highway [];
osmt:wikipedia ?wikipedia;
osmt:name ?osmLabel;
osmm:loc ?coordinates.
SERVICE <https://query.wikidata.org/sparql> {
?wikipedia schema:about ?person.
?person wdt:P31 wd:Q5.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?person rdfs:label ?personLabel.
}
}
}