Reputation: 498
I know in the past you could get the list of labels for an EntityRecognizer as follows:
nlp.entity.cfg[u'actions']
(From https://github.com/explosion/spaCy/issues/441)
But, it seems this had been disallowed. Is there any way to do this now?
Upvotes: 8
Views: 9034
Reputation: 393
As of spaCy version 3.7
import spacy
nlp = spacy.load("en_core_web_sm")
ner = nlp.get_pipe("ner")
print(ner.labels)
Outputs:
('CARDINAL', 'DATE', 'EVENT', 'FAC', 'GPE', 'LANGUAGE', 'LAW', 'LOC', 'MONEY', 'NORP', 'ORDINAL', 'ORG', 'PERCENT', 'PERSON', 'PRODUCT', 'QUANTITY', 'TIME', 'WORK_OF_ART')
Upvotes: 1
Reputation: 625
You can do the following :
nlp.entity.labels
It outputs the following tuple :
('CARDINAL',
'DATE',
'EVENT',
'FAC',
'GPE',
'LANGUAGE',
'LAW',
'LOC',
'MONEY',
'NORP',
'ORDINAL',
'ORG',
'PERCENT',
'PERSON',
'PRODUCT',
'QUANTITY',
'TIME',
'WORK_OF_ART')
Upvotes: 6