Add EntityRecognizer.label property

This commit is contained in:
Ines Montani 2018-11-18 00:06:26 +01:00
parent 017bc2ef2f
commit 350c8d25b0

View File

@ -1201,5 +1201,12 @@ cdef class EntityRecognizer(Parser):
return (EntityRecognizer, (self.vocab, self.moves, self.model),
None, None)
@property
def labels(self):
# Get the labels from the model by looking at the available moves, e.g.
# B-PERSON, I-PERSON, L-PERSON, U-PERSON
return [move.split('-')[1] for move in self.move_names
if move[0] in ('B', 'I', 'L', 'U')]
__all__ = ['Tagger', 'DependencyParser', 'EntityRecognizer', 'Tensorizer', 'TextCategorizer']