question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to derive city names using Geotext library

See original GitHub issue

Hi,

I have texts extracted from certain contexts of files like:

'. Education : 05/2012 DePaul University Graduate School Master of Science in E-Commerce Technology Morgan in E-Commerce Technology Morgan State University 05/88 BS in Computer Science Technical Training or Certifications ’

‘Information Technology Southern New Hampshire University Expected 2015 Associate of Arts , Graphic Design Penn’

These contain the name of some university along with some city names like ‘Morgan city’ in the first sentence and ‘New Hampshire’ in the second sentence. I am using the code mentioned below to extract the city names from the text using the ‘geotext’ python library:

from geotext import geotext
places = GeoText(sent1) -- or sent2
        print(places.cities)

I had used pip install geotext for the installation on Python 3 Anaconda 3.0 in Windows 7. The output I am getting is [‘University’] and [‘University’, ‘University’]. These are clearly not city names.

I would like to mention that the post installation I have had some ‘expecting bytes not strings’ errors and ‘cannot find name GeoText’ errors which I corrected manually.

I changed the import statement in init.py to contain geotext instead of GeoText and I changed the string to string.encode() for the byte array errors.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
elyasecommented, Jan 7, 2017

I merged @freezer9 pull request that adds Python 3 support. I have tested it with conda 2 and 3 environments and it seems to work well. Please upgrade with:

pip install geotext -U
1reaction
cdepeutercommented, Dec 21, 2016

You guys are both using Python 3 right? I was having the same issue. My temporary workaround was to move the contents of geotext.py into the init file, change the file reading from ‘rb’ to ‘r’, remove the .decode(encoding), and enclose the print statements. Works as a quick solution but definitely not worthy of a pull request to this repo. @elyase would you be ok with me submitting a pull at some point to try and make this lib both 2 and 3 compatible? Really like the functionality of this module

Read more comments on GitHub >

github_iconTop Results From Across the Web

geotext library is not picking up the correct name of cities in ...
Hi I am new bee in python and we are trying to find the country ,cities name from geotext library of python but...
Read more >
Introducing flashgeotext: extract city and country names from text
Say you are faced with the problem of extracting the name of a location from a text and count their occurrences.
Read more >
Geoparsing with Python - Towards Data Science
Like SpaCy, GeoText recognizes geographically named entities, but calling .cities in GeoText returns just the city names. Note that I am not ......
Read more >
Generating Geographic Terms for Streaming Videos Using ...
At times, the GeoText library correctly identifies a place but can generate false positives by associating a city name with a different ...
Read more >
Top 10 Python libraries to work with geo-spatial data in 2022
As you can guess from the name, reverse_geocoder package takes a (latitude, longitude) coordinate and returns the nearest city, together with its respective ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found