USA not recognized
"USA" is not being detected. I have to replace "USA" to "United States" in order the country to be detected.
I'm also not able to extract a country for "USA" using geotext. It looks like "UK" also does not produce a match:
import geotext
text = "UK"
geo_text = geotext.GeoText(text)
dict(geo_text.country_mentions)
returns {} (an empty dict). @elyase would these be easy fixes?
Check the demo data carefully. GeoText does not use synonyms in its lookup.
Check the demo data carefully
Are you talking about the data in geotext/data? I do see data that would seem to allow for mapping USA and UK to countries:
https://github.com/elyase/geotext/blob/21a8a7f5eebea40f270beef9ede4d9a57e3c81c3/geotext/data/countryInfo.txt#L285
https://github.com/elyase/geotext/blob/21a8a7f5eebea40f270beef9ede4d9a57e3c81c3/geotext/data/countryInfo.txt#L8
https://github.com/elyase/geotext/blob/21a8a7f5eebea40f270beef9ede4d9a57e3c81c3/geotext/data/countryInfo.txt#L128
GeoText does not use synonyms in its lookup
First, isn't USA the official ISO 3166 3-letter code for the United States? So not a synonym. Also if this issue is caused by excluding synonyms, perhaps that's the wrong design decision?
The data in geotext/data does not reflect what GeoText is looking for in a text. It only takes a small part of it for the lookup. So yes, the data allows for more, but GeoText is prohibiting it.
I talked about it briefly in issue-22. If you want synonyms, I tried another approach over at flashgeotext. Not sure I cover all the synonyms for country names, but some. And, I leave it to you to bring your own data/add data if something is missing.
Hi guys, we don't include ISO because the approach used in Geotext (rule based regex) is based on high precision rules (so you can almost be certain that it is correct when it works). The drawback is that we lose some recall. While there are several ways this can be improved there is always a fine line in the precision / recall tradeoff. For example, if you take a look at the ISO list you will see many of them are token that are found everywhere even when they don't represent a country. Even some of them like USA, have meanings in others languages (USA means "to use" in Spanish). I have long wanted to improve the regex using a data based approach but I am missing data with representative negative examples (like extracting USA when it shouldn't be the case).
So I prefer the approach of providing basic functionality with high precision and leaving the responsibility of extending recall to users ex what @lisiq did (preprocessing the data). What we could do is improve the API to make it easier to add your own exceptions.
That said flashgeotext from @iwpnd looks great. Please try it out and let me know if we should join efforts there.