Multiword-token (MWT) lexicon: how to expand a surface token (French "du") into its syntactic words ("de", "le").
More...
Multiword-token (MWT) lexicon: how to expand a surface token (French "du") into its syntactic words ("de", "le").
Shared by deeplima's MwtExpander, by deeplima-mwt-dict, which builds it from training CoNLL-U files, and by LIMA's RnnTokenizer.
Two layers:
- a dictionary of the surfaces seen in training, with their most frequent expansion;
- affix rules, the fallback for a surface the segmenter flags as multiword but that the dictionary does not know. A suffix rule cuts a surface ending, rewrites the end of the remaining stem and adds fixed words: Polish "zrobiłem" = "zrobił" + "em" (suffix "em", no rewrite, word "em"); a Tamil surface may end with a fused form of the clitic, the rule's rewrite restores the stem's last letters. A prefix rule is the mirror (Arabic "و" + stem). Rules are learned from the dictionary itself: each entry gives one suffix rule (from its longest common prefix with its first word) and one prefix rule (from its longest common suffix with its last word); a rule is kept when at least min_support entries give it, and, for each affix, only the best rule. Rules are scored by their precision on the dictionary, support / (entries having the affix + 1), smoothed so that a rare affix does not win over a frequent one.
- optionally, a character seq2seq model (MwtSeq2Seq, <file>.s2s beside the dictionary file), for flagged surfaces whose split is not a concatenation (Amharic, Tamil); the model file says whether it is tried before or after the affix rules.
Rules and the seq2seq are only meant for surfaces the segmenter flagged: applied to every token, they would split most words.
File format (UTF-8, one entry per line, tab-separated): surface count word1 word2 ... dictionary #rule suffix|prefix affix rewrite support applicable word1 ... A line starting with '#' is a comment to older readers, which thus keep reading the dictionary and ignore the rules.
Definition at line 63 of file mwt_lexicon.h.