geotext

raw JSON →
0.4.0 verified Fri May 01 auth: no python maintenance

Geotext extracts country and city mentions from text using a simple word-matching approach (not ML). Current version 0.4.0, last updated 2018, project effectively in maintenance mode. Does not support Python 3.6+ out of the box.

pip install geotext
error ModuleNotFoundError: No module named 'geotext'
cause Wrong import: import geotext instead of from geotext import GeoText
fix
Use: from geotext import GeoText
error ImportError: No module named enum
cause Python 2.7 environment missing enum backport. geotext uses enum.
fix
Install enum34: pip install enum34, or switch to Python 3.4+.
deprecated Project unmaintained since 2018, no Python 3.6+ compatibility fixes. Use Python 2.7 or backport yourself.
fix Consider alternatives: geonamescache, countryinfo, or spacy geo components.
gotcha GeoText does lowercase matching by default, so 'PARIS' or 'Paris' work, but mixed case may cause misses.
fix Normalize input text to lowercase before passing to GeoText if needed.
pip install git+https://github.com/elyase/geotext.git

Extract city and country mentions from text.

from geotext import GeoText

places = GeoText("I live in Paris and work in Berlin")
print(places.cities)  # ['Paris', 'Berlin']
print(places.countries)  # []