q-wiki / q-wiki-server

Q-Wiki is a Wikidata based game (Unity front-end with ASP.NET Core back-end) developed by HTW Berlin students in cooperation with Wikimedia Germany.
GNU General Public License v3.0
2 stars 0 forks source link

Query wrong: Which continent has 11 countries? #69

Closed davidmllr closed 4 years ago

davidmllr commented 4 years ago

According to the query, the right answer would be South America, which happens to have 12 sovereign states and 3 non-sovereign territories.

https://en.wikipedia.org/wiki/South_America

rrrnld commented 4 years ago

Comparing this list to this query result it shows that Suriname is missing. I'll take a look at what's missing.

rrrnld commented 4 years ago

Ugh… this is quite messy. Here's what I found out (incomplete but illuminating nonetheless):

List of countries per continent as per Wikipedia (EN is english wiki, DE is german wiki):

Sovereign states per continent

SELECT ?continent ?answer (COUNT(?country) as ?countries) WHERE {
  ?country p:P31/ps:P31 wd:Q3624078.
  MINUS { ?country p:P31 [pq:P582 ?endTime]. }
  ?country wdt:P30 ?continent.
  ?continent wdt:P31 wd:Q5107.
  # FILTER(?continent = wd:Q18).
  MINUS {VALUES ?continent {wd:Q51}}. # w/o Antarctica
  OPTIONAL {?continent rdfs:label ?answer ;
                       filter(lang(?answer) = 'en').
           ?country rdfs:label ?countryLabel ; filter (lang(?countryLabel) = 'en')}
}
GROUP BY ?continent ?answer
continent answer countries
http://www.wikidata.org/entity/Q15 Africa 51
http://www.wikidata.org/entity/Q18 South America 12
http://www.wikidata.org/entity/Q46 Europe 50
http://www.wikidata.org/entity/Q48 Asia 47
http://www.wikidata.org/entity/Q49 North America 23
http://www.wikidata.org/entity/Q538 Oceania 12

Countries per continent

SELECT DISTINCT ?continent ?answer (COUNT(?country) as ?countries) WHERE {
  ?country p:P31/ps:P31 wd:Q6256.
  ?country wdt:P30 ?continent.
  ?continent wdt:P31 wd:Q5107.
  MINUS {VALUES ?continent {wd:Q51}}. # w/o Antarctica
  OPTIONAL {?continent rdfs:label ?answer ;
                       filter(lang(?answer) = 'en').
            ?country rdfs:label ?countryLabel; filter(lang(?countryLabel) = 'en')}
}
GROUP BY ?continent ?answer
continent answer countries
http://www.wikidata.org/entity/Q15 Africa 55
http://www.wikidata.org/entity/Q48 Asia 53
http://www.wikidata.org/entity/Q538 Oceania 18
http://www.wikidata.org/entity/Q18 South America 13
http://www.wikidata.org/entity/Q46 Europe 56
http://www.wikidata.org/entity/Q49 North America 25

Current

SELECT ?continent ?answer (COUNT(?item) AS ?question) WHERE {
  ?item wdt:P31 wd:Q6256.
  ?item wdt:P30 ?continent.
  ?continent wdt:P31 wd:Q5107.
  MINUS {VALUES ?continent {wd:Q51}}. # w/o Antarctica
  OPTIONAL {?continent rdfs:label ?answer ;
                       filter(lang(?answer) = 'en')
           }
} GROUP BY ?continent ?answer
ORDER BY ?answer
continent answer question
http://www.wikidata.org/entity/Q15 Africa 53
http://www.wikidata.org/entity/Q48 Asia 46
http://www.wikidata.org/entity/Q46 Europe 21
http://www.wikidata.org/entity/Q49 North America 21
http://www.wikidata.org/entity/Q538 Oceania 17
http://www.wikidata.org/entity/Q18 South America 11

This makes me think we might be asking the wrong question.