diff --git a/spacy/gold.pyx b/spacy/gold.pyx index 1d7f80c92..3884e1cba 100644 --- a/spacy/gold.pyx +++ b/spacy/gold.pyx @@ -694,6 +694,11 @@ cdef class GoldParse: self.cats = {} if cats is None else dict(cats) self.links = links + # orig_annot is used as an iterator in `nlp.evalate` even if self.length == 0, + # so set a empty list to avoid error. + # if self.lenght > 0, this is modified latter. + self.orig_annot = [] + # avoid allocating memory if the doc does not contain any tokens if self.length > 0: if words is None: diff --git a/spacy/tests/regression/test_issue4924.py b/spacy/tests/regression/test_issue4924.py new file mode 100644 index 000000000..8aea2c3d5 --- /dev/null +++ b/spacy/tests/regression/test_issue4924.py @@ -0,0 +1,16 @@ +# coding: utf8 +from __future__ import unicode_literals + +import pytest + +import spacy + + +@pytest.fixture +def nlp(): + return spacy.blank("en") + + +def test_evaluate(nlp): + docs_golds = [("", {})] + nlp.evaluate(docs_golds)