From 18da89e04c1438a2d65134a604973405e2f31412 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 27 Mar 2018 21:08:41 +0200 Subject: [PATCH] Handle non-callable gold_tuples in parser begin_training --- spacy/syntax/nn_parser.pyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index 8fd870939..7e55a668d 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -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))