Fix label-clobber bug in parser.begin_training()

The parser.begin_training() method was rewritten in v2.1. The rewrite
introduced a regression, where if you added labels prior to
begin_training(), these labels were discarded. This patch fixes that.
This commit is contained in:
Matthew Honnibal 2018-08-14 13:20:19 +02:00
parent 02c5c114d0
commit 6ec236ab08
1 changed files with 4 additions and 0 deletions

View File

@ -493,7 +493,11 @@ cdef class Parser:
cfg.setdefault('min_action_freq', 30)
actions = self.moves.get_actions(gold_parses=get_gold_tuples(),
min_freq=cfg.get('min_action_freq', 30))
previous_labels = dict(self.moves.labels)
self.moves.initialize_actions(actions)
for action, label_freqs in previous_labels.items():
for label in label_freqs:
self.moves.add_action(action, label)
cfg.setdefault('token_vector_width', 128)
if self.model is True:
self.model, cfg = self.Model(self.moves.n_moves, **cfg)