2020-07-22 11:42:59 +00:00
|
|
|
from typing import Set, Dict, Callable, Any
|
|
|
|
from thinc.api import Config
|
|
|
|
|
2018-12-18 12:08:38 +00:00
|
|
|
from .tokenizer_exceptions import TOKENIZER_EXCEPTIONS
|
|
|
|
from .stop_words import STOP_WORDS
|
|
|
|
from .lex_attrs import LEX_ATTRS
|
|
|
|
from ..tokenizer_exceptions import BASE_EXCEPTIONS
|
|
|
|
from ...language import Language
|
2020-07-22 11:42:59 +00:00
|
|
|
from ...util import update_exc, registry
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_CONFIG = """
|
|
|
|
[nlp]
|
|
|
|
lang = "tl"
|
|
|
|
stop_words = {"@language_data": "spacy.tl.stop_words"}
|
|
|
|
lex_attr_getters = {"@language_data": "spacy.tl.lex_attr_getters"}
|
|
|
|
|
|
|
|
[nlp.lemmatizer]
|
|
|
|
@lemmatizers = "spacy.Lemmatizer.v1"
|
|
|
|
|
|
|
|
[nlp.lemmatizer.data_paths]
|
|
|
|
@language_data = "spacy-lookups-data"
|
|
|
|
lang = ${nlp:lang}
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
@registry.language_data("spacy.tl.stop_words")
|
|
|
|
def stop_words() -> Set[str]:
|
|
|
|
return STOP_WORDS
|
2018-12-18 12:08:38 +00:00
|
|
|
|
|
|
|
|
2020-07-22 11:42:59 +00:00
|
|
|
@registry.language_data("spacy.tl.lex_attr_getters")
|
|
|
|
def lex_attr_getters() -> Dict[int, Callable[[str], Any]]:
|
|
|
|
return LEX_ATTRS
|
2018-12-18 12:08:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TagalogDefaults(Language.Defaults):
|
|
|
|
tokenizer_exceptions = update_exc(BASE_EXCEPTIONS, TOKENIZER_EXCEPTIONS)
|
|
|
|
|
|
|
|
|
|
|
|
class Tagalog(Language):
|
2019-02-08 13:14:49 +00:00
|
|
|
lang = "tl"
|
|
|
|
Defaults = TagalogDefaults
|
2020-07-22 11:42:59 +00:00
|
|
|
default_config = Config().from_str(DEFAULT_CONFIG)
|
2018-12-18 12:08:38 +00:00
|
|
|
|
|
|
|
|
2019-02-08 13:14:49 +00:00
|
|
|
__all__ = ["Tagalog"]
|