From 60c26b2dfa804553b0f6b73671026325e7561834 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 15 Sep 2015 14:43:10 +1000 Subject: [PATCH] * Fix slicing when start or stop is None --- spacy/tokens/doc.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 6878793ab..0c3c0a2f7 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -88,6 +88,10 @@ cdef class Doc: if i.step is not None: raise ValueError("Stepped slices not supported in Span objects." "Try: list(doc)[start:stop:step] instead.") + if i.start is None: + i.start = 0 + if i.stop is None: + i.stop = len(self) return Span(self, i.start, i.stop, label=0) if i < 0: