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

Word list for the segmenter's lexicon feature (ngram_descr_t::lexicon_ngram). More...

#include <deeplima/segmentation/impl/segm_lexicon.h>

Public Member Functions

 SegmLexicon ()=default
 SegmLexicon (const std::string &fn)
void load (const std::string &fn)
size_t size () const
uint32_t mask (const char32_t *history, size_t n) const

Static Public Member Functions

static std::u32string utf8_to_u32 (const std::string &s)

Static Public Attributes

static constexpr size_t MAX_LEN = 8
static constexpr uint8_t BITS = 6

Detailed Description

Word list for the segmenter's lexicon feature (ngram_descr_t::lexicon_ngram).

For each character, the feature is a 6-bit mask: bit k (k = 0..4) is set when a word of the list of length k + 2 ends at this character, bit 5 when one of length 7 or 8 does. It only looks back (at most MAX_LEN characters), so the streaming reader computes it when it reads the character, with no lookahead; the segmenter's backward RNN carries it to the word's start. Meant for scripts written without spaces (Chinese, Japanese) and for Vietnamese: an external dictionary (CC-CEDICT for Chinese) gives the segmenter the words its treebank lacks (Chinese GSDSimp, a prototype: word F1 89 -> 93).

File: UTF-8, one word per line, the first tab-separated field (a count or other columns may follow); words shorter than 2 or longer than MAX_LEN characters are ignored. Words are matched as written, spaces included (the reader sees every character): a Vietnamese "bắt chuyện" matches its text.

Definition at line 39 of file segm_lexicon.h.

Constructor & Destructor Documentation

◆ SegmLexicon() [1/2]

deeplima::segmentation::impl::SegmLexicon::SegmLexicon ( )
default

◆ SegmLexicon() [2/2]

deeplima::segmentation::impl::SegmLexicon::SegmLexicon ( const std::string & fn)
inlineexplicit

Definition at line 47 of file segm_lexicon.h.

Member Function Documentation

◆ load()

void deeplima::segmentation::impl::SegmLexicon::load ( const std::string & fn)
inline

Definition at line 52 of file segm_lexicon.h.

◆ mask()

uint32_t deeplima::segmentation::impl::SegmLexicon::mask ( const char32_t * history,
size_t n ) const
inline

Definition at line 82 of file segm_lexicon.h.

◆ size()

size_t deeplima::segmentation::impl::SegmLexicon::size ( ) const
inline

Definition at line 75 of file segm_lexicon.h.

◆ utf8_to_u32()

std::u32string deeplima::segmentation::impl::SegmLexicon::utf8_to_u32 ( const std::string & s)
inlinestatic

Definition at line 98 of file segm_lexicon.h.

Member Data Documentation

◆ BITS

uint8_t deeplima::segmentation::impl::SegmLexicon::BITS = 6
staticconstexpr

Definition at line 43 of file segm_lexicon.h.

◆ MAX_LEN

size_t deeplima::segmentation::impl::SegmLexicon::MAX_LEN = 8
staticconstexpr

Definition at line 42 of file segm_lexicon.h.


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