From 080afd49240e4ebdf61321adeed2bd81f054600f Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 8 Oct 2017 23:51:58 +0200 Subject: [PATCH] Add ternary value setting to Token.sent_start --- spacy/tokens/token.pyx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index 7b11d6efa..78ba920dd 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -281,13 +281,21 @@ cdef class Token: def __get__(self): return self.c.sent_start - def __set__(self, bint value): + def __set__(self, value): if self.doc.is_parsed: raise ValueError( 'Refusing to write to token.sent_start if its document is parsed, ' 'because this may cause inconsistent state. ' 'See https://github.com/spacy-io/spaCy/issues/235 for workarounds.') - self.c.sent_start = value + if value is None: + self.c.sent_start = 0 + elif value is True: + self.c.sent_start = 1 + elif value is False: + self.c.sent_start = -1 + else: + raise ValueError("Invalid value for token.sent_start -- must be one of " + "None, True, False") property lefts: def __get__(self):