Is there a method to extract all possible named entity types from a model in spaCy? You can manually figure it out by running on sample text, but I imagine there is a more programmatic way to do this? For example:
import spacy
model=spacy.load("en_core_web_sm")
model.*returns_entity_types*
The statistical pipeline components like ner provide their labels under .labels:
import spacy
nlp = spacy.load("en_core_web_sm")
nlp.get_pipe("ner").labels
This might not be the most general answer, but for en_core_web_sm this returns the named entity types.
model = spacy.load("en_core_web_sm")
list(model.__dict__['_meta']['accuracy']['ents_per_type'].keys())
['ORG', 'CARDINAL', 'DATE', 'GPE', 'PERSON', 'MONEY', 'PRODUCT', 'TIME', 'PERCENT', 'WORK_OF_ART', 'QUANTITY', 'NORP', 'LOC', 'EVENT', 'ORDINAL', 'FAC', 'LAW', 'LANGUAGE']