fix nlp.evaluate (#4924) (#4925)

* new file:   test_issue4924.py

* modified:   spacy/gold.pyx

* modified:   test_issue4924.py for python2
This commit is contained in:
Yohei Tamura 2020-01-20 20:17:46 +09:00 committed by Matthew Honnibal
parent b9afcd56e3
commit 708a4d27eb
2 changed files with 21 additions and 0 deletions

View File

@ -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:

View File

@ -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)