From 2f63806ddb336800f26c04e29a7ecdc4d12be13f Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 25 Mar 2017 22:35:44 +0100 Subject: [PATCH] Update config when adding label. Re #910 --- spacy/pipeline.pyx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spacy/pipeline.pyx b/spacy/pipeline.pyx index b2d622329..ea8221cff 100644 --- a/spacy/pipeline.pyx +++ b/spacy/pipeline.pyx @@ -19,6 +19,9 @@ cdef class EntityRecognizer(Parser): def add_label(self, label): for action in self.moves.action_types: self.moves.add_action(action, label) + if 'actions' in self.cfg: + self.cfg['actions'].setdefault(action, + {}).setdefault(label, True) if isinstance(label, basestring): label = self.vocab.strings[label] for attr, freqs in self.vocab.serializer_freqs: @@ -37,6 +40,9 @@ cdef class BeamEntityRecognizer(BeamParser): def add_label(self, label): for action in self.moves.action_types: self.moves.add_action(action, label) + if 'actions' in self.cfg: + self.cfg['actions'].setdefault(action, + {}).setdefault(label, True) if isinstance(label, basestring): label = self.vocab.strings[label] for attr, freqs in self.vocab.serializer_freqs: @@ -54,6 +60,9 @@ cdef class DependencyParser(Parser): def add_label(self, label): for action in self.moves.action_types: self.moves.add_action(action, label) + if 'actions' in self.cfg: + self.cfg['actions'].setdefault(action, + {}).setdefault(label, True) if isinstance(label, basestring): label = self.vocab.strings[label] for attr, freqs in self.vocab.serializer_freqs: @@ -71,6 +80,9 @@ cdef class BeamDependencyParser(BeamParser): def add_label(self, label): for action in self.moves.action_types: self.moves.add_action(action, label) + if 'actions' in self.cfg: + self.cfg['actions'].setdefault(action, + {}).setdefault(label, True) if isinstance(label, basestring): label = self.vocab.strings[label] for attr, freqs in self.vocab.serializer_freqs: