2021-08-10 16:13:39 +03:00
|
|
|
from typing import Optional, Callable
|
2021-07-14 15:01:02 +03:00
|
|
|
|
2020-08-07 16:27:13 +03:00
|
|
|
from thinc.api import Model
|
2020-07-22 14:42:59 +03:00
|
|
|
|
2021-07-14 15:01:02 +03:00
|
|
|
from .lemmatizer import DutchLemmatizer
|
2017-09-26 17:39:15 +03:00
|
|
|
from .lex_attrs import LEX_ATTRS
|
2020-04-06 14:18:07 +03:00
|
|
|
from .punctuation import TOKENIZER_PREFIXES, TOKENIZER_INFIXES
|
|
|
|
from .punctuation import TOKENIZER_SUFFIXES
|
2021-07-14 15:01:02 +03:00
|
|
|
from .stop_words import STOP_WORDS
|
|
|
|
from .syntax_iterators import SYNTAX_ITERATORS
|
|
|
|
from .tokenizer_exceptions import TOKENIZER_EXCEPTIONS
|
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
|
2021-07-14 15:01:02 +03:00
|
|
|
syntax_iterators = SYNTAX_ITERATORS
|
2020-07-24 15:50:26 +03:00
|
|
|
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"],
|
2021-08-10 16:13:39 +03:00
|
|
|
default_config={
|
|
|
|
"model": None,
|
|
|
|
"mode": "rule",
|
|
|
|
"overwrite": False,
|
|
|
|
"scorer": {"@scorers": "spacy.lemmatizer_scorer.v1"},
|
|
|
|
},
|
2020-08-07 16:27:13 +03:00
|
|
|
default_score_weights={"lemma_acc": 1.0},
|
|
|
|
)
|
2021-01-26 06:53:43 +03:00
|
|
|
def make_lemmatizer(
|
2021-08-10 16:13:39 +03:00
|
|
|
nlp: Language,
|
|
|
|
model: Optional[Model],
|
|
|
|
name: str,
|
|
|
|
mode: str,
|
|
|
|
overwrite: bool,
|
|
|
|
scorer: Optional[Callable],
|
2021-01-26 06:53:43 +03:00
|
|
|
):
|
2021-08-10 16:13:39 +03:00
|
|
|
return DutchLemmatizer(
|
|
|
|
nlp.vocab, model, name, mode=mode, overwrite=overwrite, scorer=scorer
|
|
|
|
)
|
2020-08-07 16:27:13 +03:00
|
|
|
|
|
|
|
|
2019-04-09 12:40:19 +03:00
|
|
|
__all__ = ["Dutch"]
|