Search code examples
pythonmachine-learningnlpspacynamed-entity-recognition

Is it possible to subclass a spacy entity type?


I'd like to subclass the existing GPE, so that it differentiates between GPE-Nation, USA, and GPE-City, New York. I see in the docs how to create new entity types, but not how to subclass what's already there. Can this be done, and if so, how? Thanks.


Solution

  • You cannot subclass an NER type. You have to train custom NER types for that. In my opinion, I would get the GPE entities, and then separate them into Nation and City based on a dictionary lookup. There are finite number of major cities and nations in the world, therefore a dictionary lookup would be more suitable here than creating a generalization.