From 34651c8ddf06b3087151167bd269d21b6b546225 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 7 Mar 2019 12:13:47 +0100 Subject: [PATCH] Fix lemmatizer --- spacy/lemmatizer.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spacy/lemmatizer.py b/spacy/lemmatizer.py index 69f5c8d20..c708800e9 100644 --- a/spacy/lemmatizer.py +++ b/spacy/lemmatizer.py @@ -48,6 +48,11 @@ class Lemmatizer(object): avoid lemmatization entirely. """ morphology = {} if morphology is None else morphology + morphology = dict(morphology) + for key, value in list(morphology.items()): + if value is True: + feat, value = key.split('_') + morphology[feat] = value others = [ key for key in morphology @@ -68,13 +73,13 @@ class Lemmatizer(object): return True elif univ_pos == "adj" and morphology.get("Degree") == "pos": return True - elif VerbForm_inf in morphology or 'VerbForm_inf' in morphology: + elif morphology.get('VerbForm') == 'inf': return True - elif VerbForm_none in morphology or 'VerbForm_none' in morphology: + elif morphology.get('VerbForm') == 'none': return True - elif Number_sing in morphology or 'Number_sing' in morphology: + elif morphology.get('VerbForm') == 'inf': return True - elif Degree_pos in morphology or 'Degree_pos' in morphology: + elif morphology.get('Degree') == 'pos': return True else: return False