0

I have a list of Wikipedia pages related to some entities and I want to select only geographical places and locations (cities, provinces, but also regions, mountains, rivers and so on).

I can easily select pages with coordinates but this is not enough since many places actually in Wikipedia are not associated to their coordinates. I guess I should use labels from Wikidata, but I never used them and I am a bit lost with Python API. For example, if I use wptools:

import wptools
page = wptools.page('Indianapolis')
print(page.get_wikidata())

I obtain this:

www.wikidata.org (wikidata) Indianapolis
www.wikidata.org (labels) Q1000136|P1830|P421|Q1093829|P163|Q2579...
www.wikidata.org (labels) Q537853|P281|P949|Q2494513|Q3166162|Q18...
www.wikidata.org (labels) P1036|Q499547|P1997|P31|P17|P268|Q62049...
en.wikipedia.org (imageinfo) File:IndianapolisC12.png
Indianapolis (en) data
{
  aliases: <list(10)> Circle City, Indy, Naptown, Crossroads of Am...
  claims: <dict(61)> P1082, P227, P1151, P31, P17, P131, P163, P41...
  description: <str(109)> city in and county seat of Marion County...
  image: <list(1)> {'file': 'File:IndianapolisC12.png', 'kind': 'w...
  label: Indianapolis
  labels: <dict(145)> Q1000136, P1830, P421, Q1093829, P163, Q2579...
  modified: <dict(1)> wikidata
  requests: <list(5)> wikidata, labels, labels, labels, imageinfo
  title: Indianapolis
  what: county seat
  wikibase: Q6346
  wikidata: <dict(61)> population (P1082), GND ID (P227), topic's ...
  wikidata_pageid: 7459
  wikidata_url: https://www.wikidata.org/wiki/Q6346
}

How can I extract only the labels? I suppose there exists a label "THIS IS A LOCATION" but how to use it? Thanks in advance

amy
  • 9
  • 1

0 Answers0