From f37d078d6a840db1a47066c97d4ec01ba966a2b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bournhonesque?= Date: Thu, 18 May 2017 09:59:38 +0200 Subject: [PATCH 1/2] Fix issue #1069 with custom hook `Doc.sents` definition --- spacy/tokens/doc.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 2089199a0..cfc146e6a 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -431,7 +431,9 @@ cdef class Doc: """ def __get__(self): if 'sents' in self.user_hooks: - return self.user_hooks['sents'](self) + for sent in self.user_hooks['sents'](self): + yield sent + return if not self.is_parsed: raise ValueError( From 6381ebfb14c537c5525e3a240c8d3b2bd6f3cc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bournhonesque?= Date: Thu, 18 May 2017 10:42:35 +0200 Subject: [PATCH 2/2] Use yield from syntax --- spacy/tokens/doc.pyx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index cfc146e6a..ca5a3d696 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -431,8 +431,7 @@ cdef class Doc: """ def __get__(self): if 'sents' in self.user_hooks: - for sent in self.user_hooks['sents'](self): - yield sent + yield from self.user_hooks['sents'](self) return if not self.is_parsed: