-1

I have list of strings like this:

["Ola, Uber's India rival, invests $100M in scooter rental startup Vogo","Chattanooga startup Bellhops Moving raises over $31 million in latest", "Boston biotech Entrada launches with $59M to tackle deadly disease"]

I want to identify strings like India, Boston, Chattanooga which is either city, town, country, state or continent from the list of strings and segregate them as per the region.

I am not able to find a proper path or way to achieve this particular output. Any suggestions will be much helpful.

backtrack
  • 7,996
  • 5
  • 52
  • 99
talkdatatome
  • 614
  • 1
  • 10
  • 17

2 Answers2

2

You need to use GeoText library. You can install it by typing the following in your command prompt cmd of your windows.

pip install https://github.com/elyase/geotext/archive/master.zip

Once installed, you can extract cities and countries.

from geotext import GeoText
your_list=["Ola, Uber's India rival, invests $100M in scooter rental startup Vogo","Chattanooga startup Bellhops Moving raises over $31 million in latest", "Boston biotech Entrada launches with $59M to tackle deadly disease"]
complete_string=','.join(map(str,your_list) ) # converting the list 'your_list' to string
locations=GeoText(complete_string)
locations.countries
    ['India']
locations.cities
    ['Chattanooga', 'Boston']
cph_sto
  • 7,189
  • 12
  • 42
  • 78
0

For detecting countries and cities you might use geotext: https://pypi.org/project/geotext/

Daweo
  • 31,313
  • 3
  • 12
  • 25