LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
deeplima::MwtExpander Class Reference

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)

Detailed Description

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.

Member Typedef Documentation

◆ callback_t

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.

Constructor & Destructor Documentation

◆ MwtExpander()

deeplima::MwtExpander::MwtExpander ( const std::string & dict_fn)
inlineexplicit

Definition at line 47 of file mwt_expander.h.

Member Function Documentation

◆ has_seq2seq()

bool deeplima::MwtExpander::has_seq2seq ( ) const
inline

Definition at line 67 of file mwt_expander.h.

◆ operator()()

void deeplima::MwtExpander::operator() ( const std::vector< segmentation::token_pos > & tokens,
uint32_t len )
inline

Definition at line 82 of file mwt_expander.h.

◆ register_handler()

void deeplima::MwtExpander::register_handler ( const callback_t & fn)
inline

Definition at line 52 of file mwt_expander.h.

◆ rules_size()

size_t deeplima::MwtExpander::rules_size ( ) const
inline

Definition at line 62 of file mwt_expander.h.

◆ set_require_flag()

void deeplima::MwtExpander::set_require_flag ( bool require_flag)
inline

Definition at line 77 of file mwt_expander.h.

◆ size()

size_t deeplima::MwtExpander::size ( ) const
inline

Definition at line 57 of file mwt_expander.h.


The documentation for this class was generated from the following file: