From fb26b2cb12e3f00acd92e2a037dff36ff6d994cc Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 18 Nov 2017 03:33:31 +0100 Subject: [PATCH] Use lookup lemmatizer if lemma unset --- spacy/tokens/token.pyx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index 6715c5098..c0ff8c845 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -257,7 +257,11 @@ cdef class Token: inflectional suffixes. """ def __get__(self): - return self.c.lemma + if self.c.lemma == 0: + lemma = self.vocab.morphology.lemmatizer.lookup(self.orth_) + return lemma + else: + return self.c.lemma def __set__(self, attr_t lemma): self.c.lemma = lemma @@ -724,7 +728,10 @@ cdef class Token: with no inflectional suffixes. """ def __get__(self): - return self.vocab.strings[self.c.lemma] + if self.c.lemma == 0: + return self.vocab.morphology.lemmatizer.lookup(self.orth_) + else: + return self.vocab.strings[self.c.lemma] def __set__(self, unicode lemma_): self.c.lemma = self.vocab.strings.add(lemma_)