Reputation: 708
Using geograpy3 (https://pypi.org/project/geograpy3/):
> import geograpy
> text = "Welcome to beautiful Seattle"
> p = geograpy.get_geoPlace_context(text=text)
> p.cities
['Seattle']
> p.countries
['United States']
> p.regions
[]
Is there a package or dataset I need to download?
Upvotes: 1
Views: 320
Reputation: 15769
I am answering as a committer of geograpy3. There is a new locator interface intended for improvements in disambiguation and location. It is not fully integrated yet with the Natural Language Processing part yet - issues and pull requests are welcome ...
def testStackOverflow64418919(self):
'''
https://stackoverflow.com/questions/64418919/problem-retrieving-region-in-us-with-geograpy3
'''
examples=['Seattle']
for example in examples:
city=geograpy.locateCity(example,debug=False)
print(city)
Result:
Seattle (US-WA(Washington) - US(United States))
Upvotes: 0