mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 13:47:13 +03:00
264862c67a
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.
32 lines
936 B
Python
32 lines
936 B
Python
from typing import Optional
|
|
|
|
from thinc.api import Model
|
|
|
|
from ..ru.lemmatizer import RussianLemmatizer
|
|
from ...vocab import Vocab
|
|
|
|
|
|
class UkrainianLemmatizer(RussianLemmatizer):
|
|
_morph = None
|
|
|
|
def __init__(
|
|
self,
|
|
vocab: Vocab,
|
|
model: Optional[Model],
|
|
name: str = "lemmatizer",
|
|
*,
|
|
mode: str = "pymorphy2",
|
|
overwrite: bool = False,
|
|
) -> None:
|
|
try:
|
|
from pymorphy2 import MorphAnalyzer
|
|
except ImportError:
|
|
raise ImportError(
|
|
"The Ukrainian lemmatizer requires the pymorphy2 library and "
|
|
"dictionaries: try to fix it with "
|
|
'"pip install pymorphy2 pymorphy2-dicts-uk"'
|
|
) from None
|
|
if UkrainianLemmatizer._morph is None:
|
|
UkrainianLemmatizer._morph = MorphAnalyzer(lang="uk")
|
|
super().__init__(vocab, model, name, mode=mode, overwrite=overwrite)
|