Ankit
Ankit

Reputation: 86

Spacy NER inferring GPE type

When using Spacy for NER, is there a way to extract information if the entity type is city, country or state when entity type returned is GPE ?

Upvotes: 0

Views: 1943

Answers (2)

jhl
jhl

Reputation: 691

I don't know of SpaCy models for this, but you can use geotext to add some more detail.

from geotext import GeoText

places = GeoText("London is a great city")
places.cities
# ["London"]

# filter by country code
GeoText('I loved Rio de Janeiro and Havana', 'BR').cities
# ['Rio de Janeiro']

GeoText('New York, Texas, and also China').country_mentions
# OrderedDict([(u'US', 2), (u'CN', 1)])

For some more flexible uses (such as detecting states), you can also try the geograpy package

Upvotes: 3

aab
aab

Reputation: 11484

No, the default spacy models do not include more fine-grained categories for GPE.

Upvotes: 1

Related Questions