Trying WikiData

I just finished a small personal data project. Once it was done. I wanted to modify it to use data from WikiData, and I wanted the labels in Kannada. So I tried to get a list of districts and wards from WikiData. That lead me to learn SPARQL. I can't say I am an expert, but I understood and got the queries running. The below query should give you the Wards of Bangalore with labels in Kannada.

SELECT DISTINCT ?SLabel ?SDescription WHERE {
  # where S is instance of 
  # 'electoral ward of the Bruhat Bengaluru Mahanagara Palike' 
  ?S wdt:P31 wd:Q58232822.
  FILTER(NOT EXISTS { ?S wdt:P576 ?dt. })
  #lets get the label in Kannada
  SERVICE wikibase:label { bd:serviceParam wikibase:language "kn". }
}

The below query should give you the districts of India. You can to the page with the results directly. Or run the queries at WikiData Query Service.

SELECT DISTINCT ?S ?SLabel ?SDescription WHERE {
  # where S is instance of 'district of India' 
  ?S wdt:P31 wd:Q1149652.
  # remove the ones with
  # S has the dissolved property, lets call it dt
  FILTER(NOT EXISTS { ?S wdt:P576 ?dt. })
  #lets get the label in Kannada
  SERVICE wikibase:label { bd:serviceParam wikibase:language "kn". }
}

It was lot fun to learn about triplets , how they work together and how to query them. Next step is to contribute :)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.