diff --git a/spacy/lang/ru/lemmatizer.py b/spacy/lang/ru/lemmatizer.py index b7a2fc8e4..e4689815e 100644 --- a/spacy/lang/ru/lemmatizer.py +++ b/spacy/lang/ru/lemmatizer.py @@ -23,8 +23,6 @@ class RussianLemmatizer(Lemmatizer): mode: str = "pymorphy2", overwrite: bool = False, ) -> None: - super().__init__(vocab, model, name, mode=mode, overwrite=overwrite) - try: from pymorphy2 import MorphAnalyzer except ImportError: @@ -34,6 +32,7 @@ class RussianLemmatizer(Lemmatizer): ) from None if RussianLemmatizer._morph is None: RussianLemmatizer._morph = MorphAnalyzer() + super().__init__(vocab, model, name, mode=mode, overwrite=overwrite) def pymorphy2_lemmatize(self, token: Token) -> List[str]: string = token.text diff --git a/spacy/lang/uk/lemmatizer.py b/spacy/lang/uk/lemmatizer.py index 56d9c75c0..0b4435a21 100644 --- a/spacy/lang/uk/lemmatizer.py +++ b/spacy/lang/uk/lemmatizer.py @@ -7,6 +7,8 @@ from ...vocab import Vocab class UkrainianLemmatizer(RussianLemmatizer): + _morph = None + def __init__( self, vocab: Vocab, @@ -16,7 +18,6 @@ class UkrainianLemmatizer(RussianLemmatizer): mode: str = "pymorphy2", overwrite: bool = False, ) -> None: - super().__init__(vocab, model, name, mode=mode, overwrite=overwrite) try: from pymorphy2 import MorphAnalyzer except ImportError: @@ -27,3 +28,4 @@ class UkrainianLemmatizer(RussianLemmatizer): ) from None if UkrainianLemmatizer._morph is None: UkrainianLemmatizer._morph = MorphAnalyzer(lang="uk") + super().__init__(vocab, model, name, mode=mode, overwrite=overwrite)