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