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 :)

1 Response

  1. February 2, 2021

    […] started as a simple exercise of querying WikiData database using their SPQRQL query service. That lead me to studying about RDF and Triplets. I found […]