2020-08-07 16:27:13 +03:00
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
from thinc.api import Model
|
2020-07-22 14:42:59 +03:00
|
|
|
|
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-08-07 16:27:13 +03:00
|
|
|
from ...lookups import Lookups
|
2017-05-08 23:29:04 +03:00
|
|
|
from ...language import Language
|
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-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
|
|
|
|
|
|
|
|
2020-08-07 16:27:13 +03:00
|
|
|
@Dutch.factory(
|
|
|
|
"lemmatizer",
|
|
|
|
assigns=["token.lemma"],
|
|
|
|
default_config={"model": None, "mode": "rule", "lookups": None},
|
|
|
|
scores=["lemma_acc"],
|
|
|
|
default_score_weights={"lemma_acc": 1.0},
|
|
|
|
)
|
|
|
|
def make_lemmatizer(
|
|
|
|
nlp: Language,
|
|
|
|
model: Optional[Model],
|
|
|
|
name: str,
|
|
|
|
mode: str,
|
|
|
|
lookups: Optional[Lookups],
|
|
|
|
):
|
|
|
|
lookups = DutchLemmatizer.load_lookups(nlp.lang, mode, lookups)
|
|
|
|
return DutchLemmatizer(nlp.vocab, model, name, mode=mode, lookups=lookups)
|
|
|
|
|
|
|
|
|
2019-04-09 12:40:19 +03:00
|
|
|
__all__ = ["Dutch"]
|