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