Search code examples
pythonnamed-entity-recognitionspacy

NER types for 'en' model?


Is there a way to get all the built-in and added custom NER types in spaCy? The method suggested here doesn't seem to work anymore. On trying

nlp.entity.cfg 

I get back,

{u'hist_size': 0, u'pretrained_dims': 0L, u'hist_width': 0, u'beam_density': 
0.0, u'cnn_maxout_pieces': 3, u'maxout_pieces': 2, u'hidden_depth': 1, 
u'token_vector_width': 128, u'nr_class': 73, u'beam_width': 1, 
u'hidden_width': 200}

There are no 'actions' and 'extra_labels' keys in this dictionary.


Solution

  • I've found another way. Works for spacy v. 3.0.5:

    ner = nlp.get_pipe('ner')
    print(ner.labels)
    

    it gives the result:

    ('CARDINAL', 'DATE', 'EVENT', 'FAC', 'GPE', 'LANGUAGE', 'LAW', 'LOC', 'MONEY', 'NORP', 'ORDINAL', 'ORG', 'PERCENT', 'PERSON', 'PRODUCT', 'QUANTITY', 'TIME', 'WORK_OF_ART')