Summary
- removed the option to show the
span_info
and made it a default instead.
- Additionally
.extract
now returns under what word (or synonym) the keyword was found in the input text.
- As the configuration was implemented a little doofy, I updated how the configuration can be passed on init of
GeoText
.
Refactor
Fix
- Make configuration better (
e57150f
)
from flashgeotext.geotext import GeoText, GeoTextConfiguration
config = GeoTextConfiguration(**{"use_demo_data":True})
geotext = GeoText()
input_text = '''Shanghai. The Chinese Ministry of Finance in Shanghai said that China plans
to cut tariffs on $75 billion worth of goods that the country
imports from the US. Washington welcomes the decision.'''
geotext.extract(input_text=input_text)
>> {
'cities': {
'Shanghai': {
'count': 2,
'span_info': [(0, 8), (45, 53)],
'found_as': ['Shanghai', 'Shanghai'],
},
'Washington, D.C.': {
'count': 1,
'span_info': [(175, 185)],
'found_as': ['Washington'],
}
},
'countries': {
'China': {
'count': 1,
'span_info': [(64, 69)],
'found_as': ['China'],
},
'United States': {
'count': 1,
'span_info': [(171, 173)],
'found_as': ['US'],
}
}
}