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
|
|
|
|
|
2017-05-08 16:51:39 +03:00
|
|
|
from .stop_words import STOP_WORDS
|
2017-09-26 17:39:15 +03:00
|
|
|
from .lex_attrs import LEX_ATTRS
|
2019-04-03 15:13:26 +03:00
|
|
|
from .tokenizer_exceptions import TOKENIZER_EXCEPTIONS
|
2020-04-06 14:18:07 +03:00
|
|
|
from .punctuation import TOKENIZER_PREFIXES, TOKENIZER_INFIXES
|
|
|
|
from .punctuation import TOKENIZER_SUFFIXES
|
2019-08-22 15:21:32 +03:00
|
|
|
from .lemmatizer import DutchLemmatizer
|
2020-07-24 15:50:26 +03:00
|
|
|
from ...lookups import load_lookups
|
2017-05-08 23:29:04 +03:00
|
|
|
from ...language import Language
|
2020-07-22 23:18:46 +03:00
|
|
|
from ...util import registry
|
2020-07-22 14:42:59 +03:00
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_CONFIG = """
|
|
|
|
[nlp]
|
|
|
|
|
|
|
|
[nlp.lemmatizer]
|
2020-07-24 15:50:26 +03:00
|
|
|
@lemmatizers = "spacy.nl.DutchLemmatizer"
|
2020-07-22 14:42:59 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
2020-07-24 15:50:26 +03:00
|
|
|
@registry.lemmatizers("spacy.nl.DutchLemmatizer")
|
|
|
|
def create_lemmatizer() -> Callable[[Language], DutchLemmatizer]:
|
|
|
|
tables = ["lemma_rules", "lemma_index", "lemma_exc", "lemma_lookup"]
|
2020-07-22 14:42:59 +03:00
|
|
|
|
2020-07-24 15:50:26 +03:00
|
|
|
def lemmatizer_factory(nlp: Language) -> DutchLemmatizer:
|
|
|
|
lookups = load_lookups(lang=nlp.lang, tables=tables)
|
|
|
|
return DutchLemmatizer(lookups=lookups)
|
2020-07-22 14:42:59 +03:00
|
|
|
|
2020-07-24 15:50:26 +03:00
|
|
|
return lemmatizer_factory
|
2017-05-08 16:51:39 +03:00
|
|
|
|
2016-11-24 17:56:38 +03:00
|
|
|
|
2017-05-20 20:02:27 +03:00
|
|
|
class DutchDefaults(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-04-06 14:18:07 +03:00
|
|
|
prefixes = TOKENIZER_PREFIXES
|
2019-04-03 15:13:26 +03:00
|
|
|
infixes = TOKENIZER_INFIXES
|
|
|
|
suffixes = TOKENIZER_SUFFIXES
|
2020-07-24 15:50:26 +03:00
|
|
|
lex_attr_getters = LEX_ATTRS
|
|
|
|
stop_words = STOP_WORDS
|
2019-04-03 15:13:26 +03:00
|
|
|
|
2016-11-24 17:56:38 +03:00
|
|
|
|
2017-05-20 20:02:27 +03:00
|
|
|
class Dutch(Language):
|
2019-04-09 12:40:19 +03:00
|
|
|
lang = "nl"
|
2017-05-20 20:02:27 +03:00
|
|
|
Defaults = DutchDefaults
|
2017-05-03 12:01:42 +03:00
|
|
|
|
|
|
|
|
2019-04-09 12:40:19 +03:00
|
|
|
__all__ = ["Dutch"]
|