Pokémon, as Wikipedia tells us, is a multi-billion dollar media franchise controlled by video game giant Nintendo, and created by Satoshi Tajiri around 1995. Interestingly enough, Pokémon has had quite an impact on the Wikipedia project, with the completeness of Pokémon characters resulting in the Pokémon test, so named after editors used similar arguments to try to “keep” other articles—if [named Pokemon character] has an article, why shouldn’t this topic? For example, in arguing against the deletion of an article in 2005, one editor wrote “Wikipedia is not paper; if we can have articles for every minor character in Star Wars, Star Trek, and each of those pesky Pokémon, we can have an article about Professor Hopper.” (See the article on the Wikimedia blog for the full story).
I played around with the Wikidata Query Service and SPARQL queries recently. As one of the first projects on Wikidata was WikiProject Pokémon (initially known as the Pokémon Task Force), information on the fictional Pokémon species and their numbers (the Pokédex numbers) is rather complete. A query with SPARQL for all Pokémon is easy:
But I wanted a query that was a little more complex: Find all Pokémon with a number in the Pokédex that is prime. My first try didn’t work. The mistake I made: I wanted to compare the Pokédex number with the label of a prime number. Unfortunately, the label service in the Wikidata Query Service fills in labels too late to use them in a subquery. But the community was helpful as ever. User:Nikki pointed me in the correct direction: Use
Here’s the solution:
But there’s an even simpler solution without a subquery that is obvious once you wrape your head around the fact that query doesn’t work like
map in functional languages but is rather closer to declarative programming. It’s basically: “Find a solution that satisfies all the triples given above”.
See it here:
Thanks again, User:Nikki!