4 ms·
https://spinach.genie.stanford.edu/ https://spinach.genie.stanford.edu/ Here you are :)
by luguenth 1y ago
https://spinach.genie.stanford.edu/ https://spinach.genie.stanford.edu/
Here you are :)
- deleted 1y ago[deleted]
- yorwba 1y agoI asked "Which country has the most subway stations?" and got the query SELECT ?country (COUNT(*) AS ?stationCount) WHERE { ?station wdt:P31 wd:Q928830. ?station wdt:P17 ?country. } GROUP BY ?country ORDER BY DESC(?stationCount) LIMIT 1 https://query.wikidata.org/#SELECT%20%3Fcountry%20%28COUNT%28%2a%29%20AS%20%3FstationCount%29%20WHERE%20%7B%0A%20%20%3Fstation%20wdt%3AP31%20wd%3AQ928830.%0A%20%20%3Fstation%20wdt%3AP17%20%3Fcountry.%0A%7D%0AGROUP%20BY%20%3Fcountry%0AORDER%20BY%20DESC%28%3FstationCount%29%0ALIMIT%201%0A https://query.wikidata.org/#SELECT%20%3Fcountry%20%28COUNT%2... which is not unreasonable as a quick first attempt, but doesn't account for the fact that many things on Wikidata aren't tagged directly with a country (P17) and instead you first need to walk up a chain of "located in the administrative territorial entity" (P131) to find it, i.e. I would write SELECT ?country (COUNT(DISTINCT ?station) AS ?stationCount) WHERE { ?station wdt:P31 wd:Q928830. ?station wdt:P131*/wdt:P17 ?country. } GROUP BY ?country ORDER BY DESC(?stationCount) LIMIT 1 https://query.wikidata.org/#SELECT%20%3Fcountry%20%28COUNT%28DISTINCT%20%3Fstation%29%20AS%20%3FstationCount%29%20WHERE%20%7B%0A%20%20%3Fstation%20wdt%3AP31%20wd%3AQ928830.%0A%20%20%3Fstation%20wdt%3AP131%2a%2Fwdt%3AP17%20%3Fcountry.%0A%7D%0AGROUP%20BY%20%3Fcountry%0AORDER%20BY%20DESC%28%3FstationCount%29%0ALIMIT%201%0A https://query.wikidata.org/#SELECT%20%3Fcountry%20%28COUNT%2... In this case it doesn't change the answer (it only finds 3 more subway stations in China), but sometimes it does.