Wednesday, June 24, 2015

Wikidata queries

Wikidata logo
With more and more data collected at Wikidata, it becomes possible to query the data and thereby find information normally hidden in the big pile of data, or hardly machine-readable in the text of the Wikipedia articles. The query "biggest cities with a female mayor" is the standard example on what Wikidata could allow once it becomes more complete, though it still is just beginning to return useful data.

As I already added more than 7700 of the Thai administrative units to Wikidata, far more than there are articles on these entities, querying them can start to return useful information even with the still limited query functionality. The following are some easy queries which already return useful results, there could be much more interesting queries after I added more functions to my bot filling Wikidata from my XML, or when when the long-awaited property type "value with unit" becomes available, e.g. for the area.
  • Entities named after a person
    The query right now returns 16 results, e.g. the subdistrict Suranari in Nakhon Ratchasima which is named after the local heroine Thao Suranari. The query of course relies on the property "named after", which I had set manually - I probably missed several more which could be added.
  • Entities created since 2000
    As I haven't yet finished the code to fill in the creation date, the query only shows those two entities where I had added it manually so far.
  • Entities with a population of more than one million
    returns 20 provinces and Bangkok - the second largest city Nonthaburi has just 256,000, and there's also no district large enough to be returned by this query.
Once such queries includeList of cities in Thailand much easier, which right now contains lots of bogus data. Also right now the queries run on a separate server using the data from Wikidata, hopefully soon queries will be natively supported on the Wikidata server itself.
the possibility to sort the results - right now they are just sorted by the item number - it would become possible to create Wikipedia list articles like

And there's also the "female mayors" query for Thailand which only returns Phuket city - simply because almost no entity has its head of government set.

No comments: