From 1a98e48b8e34d8a03cf8c91603a0a8c13e9e3381 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 15 Apr 2017 13:35:01 +0200 Subject: [PATCH] Fix Stepwisestate' --- spacy/syntax/parser.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index 79969d1f4..b3281fe14 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -383,7 +383,7 @@ cdef class StepwiseState: def __init__(self, Parser parser, Doc doc, GoldParse gold=None): self.parser = parser self.doc = doc - if gold: + if gold is not None: self.gold = gold else: self.gold = GoldParse(doc) @@ -427,6 +427,8 @@ cdef class StepwiseState: """ Find the action-costs for the current state. """ + if not self.gold: + raise ValueError("Can't set costs: No GoldParse provided") self.parser.moves.set_costs(self.eg.c.is_valid, self.eg.c.costs, self.stcls, self.gold) costs = {}