From dda86118bd04f4b653e6e9e612998273a6011f4d Mon Sep 17 00:00:00 2001 From: adrianeboyd Date: Wed, 2 Oct 2019 12:04:06 +0200 Subject: [PATCH] Update Ukrainian lemmatizer with new lookups (#4359) * Update Ukrainian lemmatizer with new lookups * Add missing import Co-authored-by: Ines Montani --- spacy/lang/uk/__init__.py | 7 +++++-- spacy/lang/uk/lemmatizer.py | 17 ++--------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/spacy/lang/uk/__init__.py b/spacy/lang/uk/__init__.py index 6a4ed546d..e74ff2d86 100644 --- a/spacy/lang/uk/__init__.py +++ b/spacy/lang/uk/__init__.py @@ -9,6 +9,7 @@ from ..tokenizer_exceptions import BASE_EXCEPTIONS from ..norm_exceptions import BASE_NORMS from ...util import update_exc, add_lookups from ...language import Language +from ...lookups import Lookups from ...attrs import LANG, NORM from .lemmatizer import UkrainianLemmatizer @@ -24,8 +25,10 @@ class UkrainianDefaults(Language.Defaults): stop_words = STOP_WORDS @classmethod - def create_lemmatizer(cls, nlp=None, **kwargs): - return UkrainianLemmatizer() + def create_lemmatizer(cls, nlp=None, lookups=None): + if lookups is None: + lookups = Lookups() + return UkrainianLemmatizer(lookups) class Ukrainian(Language): diff --git a/spacy/lang/uk/lemmatizer.py b/spacy/lang/uk/lemmatizer.py index d40bdf2df..3eeed5dd4 100644 --- a/spacy/lang/uk/lemmatizer.py +++ b/spacy/lang/uk/lemmatizer.py @@ -6,8 +6,8 @@ from ...lemmatizer import Lemmatizer class UkrainianLemmatizer(Lemmatizer): _morph = None - def __init__(self): - super(UkrainianLemmatizer, self).__init__() + def __init__(self, lookups=None): + super(UkrainianLemmatizer, self).__init__(lookups) try: from pymorphy2 import MorphAnalyzer @@ -99,19 +99,6 @@ class UkrainianLemmatizer(Lemmatizer): return symbols_to_str[univ_pos] return None - def is_base_form(self, univ_pos, morphology=None): - # TODO - raise NotImplementedError - - def det(self, string, morphology=None): - return self(string, "det", morphology) - - def num(self, string, morphology=None): - return self(string, "num", morphology) - - def pron(self, string, morphology=None): - return self(string, "pron", morphology) - def lookup(self, string, orth=None): analyses = self._morph.parse(string) if len(analyses) == 1: