From e2f13ec72232938b8436864dde920b37cb15118f Mon Sep 17 00:00:00 2001 From: Xiaoquan Kong Date: Mon, 9 Apr 2018 05:44:05 +0800 Subject: [PATCH] bugfix: `Doc.noun_chunks` call `Doc.noun_chunks_iterator` without checking (closes #2194) --- spacy/tokens/doc.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index b89d6a1c7..f706fa20e 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -500,8 +500,9 @@ cdef class Doc: # its tokenisation changing, so it's okay once we have the Span # objects. See Issue #375. spans = [] - for start, end, label in self.noun_chunks_iterator(self): - spans.append(Span(self, start, end, label=label)) + if self.noun_chunks_iterator is not None: + for start, end, label in self.noun_chunks_iterator(self): + spans.append(Span(self, start, end, label=label)) for span in spans: yield span