Handle non-callable gold_tuples in parser begin_training

This commit is contained in:
Matthew Honnibal 2018-03-27 21:08:41 +02:00
parent 1f7229f40f
commit 18da89e04c

View File

@ -837,6 +837,9 @@ cdef class Parser:
def begin_training(self, get_gold_tuples, pipeline=None, sgd=None, **cfg):
if 'model' in cfg:
self.model = cfg['model']
if not hasattr(get_gold_tuples, '__call__'):
gold_tuples = get_gold_tuples
get_gold_tuples = lambda: gold_tuples
cfg.setdefault('min_action_freq', 30)
actions = self.moves.get_actions(gold_parses=get_gold_tuples(),
min_freq=cfg.get('min_action_freq', 30))