![]() |
LIMA
Libre Multilingual Analyzer — C++ API
|
Multiword-token (MWT) expansion stage. More...
#include <deeplima/mwt_expander.h>
Public Types | |
| typedef std::function< void(const std::vector< segmentation::token_pos > &, uint32_t)> | callback_t |
Public Member Functions | |
| MwtExpander (const std::string &dict_fn) | |
| void | register_handler (const callback_t &fn) |
| size_t | size () const |
| size_t | rules_size () const |
| bool | has_seq2seq () const |
| void | set_require_flag (bool require_flag) |
| void | operator() (const std::vector< segmentation::token_pos > &tokens, uint32_t len) |
Multiword-token (MWT) expansion stage.
Sits between the tokenizer and the TokenSequenceAnalyzer in the inference pipeline: each surface token that matches a dictionary entry (e.g. French "du") is replaced by its syntactic sub-words ("de", "le") before tagging/parsing. The tagger and parser are trained on words (de=ADP/case, le=DET/det), so an unsplit surface token is out-of-distribution; expanding here keeps the neural models in-distribution and lets the CoNLL-U output carry the UD "N-M surface" range line.
The lexicon is the one produced by deeplima-mwt-dict / extract_mwt_dict (see deeplima/mwt_lexicon.h): a dictionary of the training surfaces, then affix rules learned from it. A flagged surface missing from the dictionary is expanded by the best matching rule (productive clitics: Polish "-em", Arabic "و"+, Tamil fused endings). Rules are never used without the segmenter's flag. Non-concatenative MWTs no rule reproduces would need a seq2seq fallback, not implemented here.
Definition at line 42 of file mwt_expander.h.
| typedef std::function<void(const std::vector<segmentation::token_pos>&, uint32_t)> deeplima::MwtExpander::callback_t |
Definition at line 45 of file mwt_expander.h.
|
inlineexplicit |
Definition at line 47 of file mwt_expander.h.
|
inline |
Definition at line 67 of file mwt_expander.h.
|
inline |
Definition at line 82 of file mwt_expander.h.
|
inline |
Definition at line 52 of file mwt_expander.h.
|
inline |
Definition at line 62 of file mwt_expander.h.
|
inline |
Definition at line 77 of file mwt_expander.h.
|
inline |
Definition at line 57 of file mwt_expander.h.