Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return all possible entity types from spaCy model?

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*
like image 342
tbrk Avatar asked Mar 05 '26 14:03

tbrk


1 Answers

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
like image 114
aab Avatar answered Mar 08 '26 02:03

aab