From c4a89d56bdb77b233c5d76d823f6893b8e7da969 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 19 Jan 2016 20:09:26 +0100 Subject: [PATCH] * Automatically register any entity types pre-set on the tokens, so that the NER works with user-given entity types. --- spacy/language.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spacy/language.py b/spacy/language.py index 454d11126..69abf16b3 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -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