* Automatically register any entity types pre-set on the tokens, so that the NER works with user-given entity types.

This commit is contained in:
Matthew Honnibal 2016-01-19 20:09:26 +01:00
parent f0f92793f6
commit c4a89d56bd

View File

@ -262,6 +262,10 @@ class Language(object):
if self.parser and parse:
self.parser(tokens)
if self.entity and entity:
# Add any of the entity labels already set, in case we don't have them.
for tok in tokens:
if tok.ent_type != 0:
self.entity.add_label(tok.ent_type)
self.entity(tokens)
return tokens