From 05a8b752a251f2d55a9691181b807c300e2b1db6 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 2 Nov 2016 23:28:59 +0100 Subject: [PATCH] Fix Issue #600: Missing setters for Token attribute. --- spacy/tokens/token.pyx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index 4fd24c0e5..91ddc13cb 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -173,6 +173,12 @@ cdef class Token: property tag: def __get__(self): return self.c.tag + def __set__(self, int tag): + # TODO: The behaviour here --- that it fails when we don't have the + # tag in the 'reverse index' --- really sucks. But we can't fix it + # here if we don't fix it elsewhere... + self.vocab.morphology.assign_tag(self.c, + self.vocab.morphology.reverse_index[tag]) property dep: def __get__(self): @@ -537,6 +543,8 @@ cdef class Token: property tag_: def __get__(self): return self.vocab.strings[self.c.tag] + def __set__(self, tag): + self.tag = self.vocab.strings[tag] property dep_: def __get__(self):