mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 17:06:29 +03:00
Fix Ukrainian lemmatizer init (#7127)
Fix class variable and init for `UkrainianLemmatizer` so that it loads the `uk` dictionaries rather than having the parent `RussianLemmatizer` override with the `ru` settings.
This commit is contained in:
parent
ba5a50f62b
commit
264862c67a
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user