From 97018de33b3004f8411d13b2efef369bdf540d05 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 29 Mar 2023 15:22:27 +0200 Subject: [PATCH] Fix Span.sents issue. --- spacy/tokens/span.pyx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spacy/tokens/span.pyx b/spacy/tokens/span.pyx index 15e5422aa..75ef5df5b 100644 --- a/spacy/tokens/span.pyx +++ b/spacy/tokens/span.pyx @@ -463,6 +463,11 @@ cdef class Span: elif i == self.doc.length - 1: yield Span(self.doc, start, self.doc.length) + # Ensure that trailing parts of the Span instance are included in last element of .sents. + if start == self.doc.length - 1: + yield Span(self.doc, start, self.doc.length) + + @property def ents(self): """The named entities that fall completely within the span. Returns