2020-07-22 11:42:59 +00:00
|
|
|
from typing import Set, Dict, Callable, Any
|
|
|
|
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]
|
|
|
|
lang = "uk"
|
|
|
|
stop_words = {"@language_data": "spacy.uk.stop_words"}
|
|
|
|
lex_attr_getters = {"@language_data": "spacy.uk.lex_attr_getters"}
|
|
|
|
|
|
|
|
[nlp.lemmatizer]
|
|
|
|
@lemmatizers = "spacy.UkrainianLemmatizer.v1"
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
@registry.language_data("spacy.uk.stop_words")
|
|
|
|
def stop_words() -> Set[str]:
|
|
|
|
return STOP_WORDS
|
|
|
|
|
|
|
|
|
|
|
|
@registry.language_data("spacy.uk.lex_attr_getters")
|
|
|
|
def lex_attr_getters() -> Dict[int, Callable[[str], Any]]:
|
|
|
|
return LEX_ATTRS
|
|
|
|
|
|
|
|
|
|
|
|
@registry.lemmatizers("spacy.UkrainianLemmatizer.v1")
|
|
|
|
def create_ukrainian_lemmatizer() -> UkrainianLemmatizer:
|
|
|
|
return UkrainianLemmatizer()
|
|
|
|
|
|
|
|
|
2019-02-07 20:05:11 +00:00
|
|
|
class UkrainianDefaults(Language.Defaults):
|
2020-07-22 20:18:46 +00:00
|
|
|
tokenizer_exceptions = TOKENIZER_EXCEPTIONS
|
2019-02-07 20:05:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Ukrainian(Language):
|
2019-02-08 13:14:49 +00:00
|
|
|
lang = "uk"
|
|
|
|
Defaults = UkrainianDefaults
|
2020-07-22 11:42:59 +00:00
|
|
|
default_config = Config().from_str(DEFAULT_CONFIG)
|
2019-02-07 20:05:11 +00:00
|
|
|
|
|
|
|
|
2019-02-08 13:14:49 +00:00
|
|
|
__all__ = ["Ukrainian"]
|