Update config when adding label. Re #910

This commit is contained in:
Matthew Honnibal 2017-03-25 22:35:44 +01:00
parent b94286de30
commit 2f63806ddb

View File

@ -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: