2020-07-24 15:50:26 +03:00
|
|
|
from typing import Callable
|
2020-07-22 14:42:59 +03:00
|
|
|
from thinc.api import Config
|
|
|
|
|
2019-02-07 23:05:11 +03:00
|
|
|
from .tokenizer_exceptions import TOKENIZER_EXCEPTIONS
|
|
|
|
from .stop_words import STOP_WORDS
|
|
|
|
from .lex_attrs import LEX_ATTRS
|
2020-07-22 23:18:46 +03:00
|
|
|
from ...util import registry
|
2019-02-07 23:05:11 +03:00
|
|
|
from ...language import Language
|
|
|
|
from .lemmatizer import UkrainianLemmatizer
|
|
|
|
|
|
|
|
|
2020-07-22 14:42:59 +03:00
|
|
|
DEFAULT_CONFIG = """
|
|
|
|
[nlp]
|
|
|
|
|
|
|
|
[nlp.lemmatizer]
|
2020-07-24 15:50:26 +03:00
|
|
|
@lemmatizers = "spacy.uk.UkrainianLemmatizer"
|
2020-07-22 14:42:59 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
2020-07-24 15:50:26 +03:00
|
|
|
@registry.lemmatizers("spacy.uk.UkrainianLemmatizer")
|
|
|
|
def create_ukrainian_lemmatizer() -> Callable[[Language], UkrainianLemmatizer]:
|
|
|
|
def lemmatizer_factory(nlp: Language) -> UkrainianLemmatizer:
|
|
|
|
return UkrainianLemmatizer()
|
2020-07-22 14:42:59 +03:00
|
|
|
|
2020-07-24 15:50:26 +03:00
|
|
|
return lemmatizer_factory
|
2020-07-22 14:42:59 +03:00
|
|
|
|
|
|
|
|
2019-02-07 23:05:11 +03:00
|
|
|
class UkrainianDefaults(Language.Defaults):
|
2020-07-24 15:50:26 +03:00
|
|
|
config = Config().from_str(DEFAULT_CONFIG)
|
2020-07-22 23:18:46 +03:00
|
|
|
tokenizer_exceptions = TOKENIZER_EXCEPTIONS
|
2020-07-24 15:50:26 +03:00
|
|
|
lex_attr_getters = LEX_ATTRS
|
|
|
|
stop_words = STOP_WORDS
|
2019-02-07 23:05:11 +03:00
|
|
|
|
|
|
|
|
|
|
|
class Ukrainian(Language):
|
2019-02-08 16:14:49 +03:00
|
|
|
lang = "uk"
|
|
|
|
Defaults = UkrainianDefaults
|
2019-02-07 23:05:11 +03:00
|
|
|
|
|
|
|
|
2019-02-08 16:14:49 +03:00
|
|
|
__all__ = ["Ukrainian"]
|