LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
deeplima Namespace Reference

Edit rules for lemmatizing words absent from the lemma dictionary. More...

Namespaces

namespace  dumper
namespace  eigen_impl
namespace  eigen_wrp
namespace  graph_dp
namespace  lemmatization
namespace  segmentation
namespace  tagging
namespace  vectorizers
namespace  impl
namespace  utils
namespace  CoNLLU
namespace  convert_from_torch
namespace  morph_model
namespace  nets
namespace  train
namespace  version

Classes

class  DependencyParser
class  DictEmbdVectorizer
class  EmbdDict
class  EmbdDict< std::string, M, I >
class  FeatureVectorizerBase
class  FeatureVectorizerToMatrix
class  DirectDict
class  DirectDict< Eigen::MatrixXf, Eigen::Index >
class  FastTextExt
class  FastTextVectorizer
class  FastTextVectorizer< Eigen::MatrixXf, Eigen::Index >
class  TokenStrFeatExtractor
class  TokenUIntFeatExtractor
class  TokenUIntClsFeatExtractor
class  ConlluFeatExtractor
class  MwtExpander
 Multiword-token (MWT) expansion stage. More...
class  MwtLexicon
 Multiword-token (MWT) lexicon: how to expand a surface token (French "du") into its syntactic words ("de", "le"). More...
class  MwtSeq2Seq
 Character seq2seq fallback of the multiword-token expansion (see MwtLexicon): writes the words of a surface the segmenter flagged as multiword but that neither the dictionary nor the affix rules expand well. More...
class  RnnSeq2Seq
class  RnnSequenceClassifier
 Handles multithreading. More...
class  ITokenSequenceAnalyzer
 Handle multithread processing of token sequence. More...
class  TokenSequenceAnalyzer
struct  token_buffer_t
class  DictVectorizer
class  TorchMatrix
class  DictAdapter
class  TStringIndex
class  ThreadPool
class  ISerializable
class  PathResolver
class  Dict
class  DictBase
class  DictsHolderImpl
class  DictHolderAdapter
class  WordDictBuilderImpl

Typedefs

typedef EmbdDict< uint64_t, Eigen::MatrixXf, Eigen::Index > EmbdUInt64Float
typedef EmbdDict< std::string, Eigen::MatrixXf, Eigen::Index > EmbdStrFloat
typedef DictsHolderImpl< EmbdUInt64Float > EmbdUInt64FloatHolder
typedef DictsHolderImpl< EmbdStrFloat > EmbdStrFloatHolder
typedef TStringIndex< std::string, std::u32string, uint32_t > StringIndex
typedef Dict< std::wstring > WstringDict
typedef Dict< std::string > StringDict
typedef Dict< uint64_t > UInt64Dict
typedef Dict< char32_t > Char32Dict
typedef DictsHolderImpl DictsHolder

Enumerations

enum  token_flags_t : uint8_t {
  none = 0x00 , sentence_brk = 0x01 , paragraph_brk = 0x02 , multiword = 0x04 ,
  max_flags
}

Functions

template<class M, typename vertex_idx_t, typename weight_t>
void arborescence (const M &adj_matrix, std::vector< vertex_idx_t > &heads, size_t offset)
template<typename vertex_idx_t, typename weight_t>
void arborescence (std::vector< uint32_t > &heads, size_t len)
template<typename T>
std::ostream & operator<< (std::ostream &out, const std::vector< T > &v)
std::string pretty_bits_to_string_one_byte (const uint8_t arg)
template<class T>
std::string pretty_bits_to_string (const T arg)
std::vector< std::string > split (const std::string &s, char delim)

Detailed Description

Edit rules for lemmatizing words absent from the lemma dictionary.

A suffix rule turns a form into its lemma: optionally lowercase the form, strip m_strip trailing characters, append m_add ("chantera" -> "chanter" is {false, 1, ""}, "chevaux" -> "cheval" is {false, 2, "l"}). Rules are learned from a treebank by deeplima-gen-lemm-dict –rules, indexed by the word's UPOS (+FEATS) and lowercased ending, and applied by TokenSequenceAnalyzer after a dictionary miss, before the seq2seq model.

Optionally (–rules-max-prefix), a prefix rule edits the beginning of the word the same way, indexed by its lowercased beginning: strip m_strip leading characters, prepend m_add. Suffix rules alone cannot lemmatize the languages that change the start of words (Irish "bhean" -> "bean", Indonesian "membaca" -> "baca", Hebrew and Arabic prefixes). Prefix rules are learned along the longest common substring of form and lemma, the suffix rules along the longest common prefix: a word gets a prefix edit only when that makes its whole edit shorter, and within max_prefix characters.

Unlike a character seq2seq model, a rule cannot scramble letters and costs a few hash lookups. On UD_French-Sequoia it lemmatizes the unseen forms better than the seq2seq model did (87% vs 72% with gold tags).

File format: UTF-8, '#' starts a comment line, one rule per line, 7 tab-separated fields for a suffix rule (suffix and add may be empty): upos feats suffix lower strip add count and 8 for a prefix rule, whose lower is always 0 (lowercasing belongs to the suffix rule, applied before both edits): prefix upos feats beginning lower strip add count feats is the FEATS column ("_" for none) or "*" for the rule used when no rule matches the exact features; suffix and beginning are lowercased; lower is 0 or 1; count is how many training words support the rule (it breaks ties when two spellings of the same features collide at load time). The prefix lines have their own field count so that a reader predating them rejects the file instead of applying them as suffix rules.

All lengths are in code points, and lowercasing is ICU simple case mapping, code point by code point, so that it never changes a length the rules depend on.

Typedef Documentation

◆ Char32Dict

typedef Dict<char32_t> deeplima::Char32Dict

Definition at line 270 of file dict.h.

◆ DictsHolder

Definition at line 42 of file dict_base.h.

◆ EmbdStrFloat

typedef EmbdDict<std::string, Eigen::MatrixXf, Eigen::Index> deeplima::EmbdStrFloat

Definition at line 209 of file embd_dict.h.

◆ EmbdStrFloatHolder

◆ EmbdUInt64Float

typedef EmbdDict<uint64_t, Eigen::MatrixXf, Eigen::Index> deeplima::EmbdUInt64Float

Definition at line 208 of file embd_dict.h.

◆ EmbdUInt64FloatHolder

◆ StringDict

typedef Dict<std::string> deeplima::StringDict

Definition at line 268 of file dict.h.

◆ StringIndex

typedef TStringIndex<std::string, std::u32string, uint32_t> deeplima::StringIndex

Definition at line 119 of file str_index.h.

◆ UInt64Dict

typedef Dict<uint64_t> deeplima::UInt64Dict

Definition at line 269 of file dict.h.

◆ WstringDict

typedef Dict<std::wstring> deeplima::WstringDict

Definition at line 267 of file dict.h.

Enumeration Type Documentation

◆ token_flags_t

enum deeplima::token_flags_t : uint8_t
Enumerator
none 
sentence_brk 
paragraph_brk 
multiword 
max_flags 

Definition at line 18 of file token_type.h.

Function Documentation

◆ arborescence() [1/2]

template<class M, typename vertex_idx_t, typename weight_t>
void deeplima::arborescence ( const M & adj_matrix,
std::vector< vertex_idx_t > & heads,
size_t offset )

Definition at line 1075 of file arborescence.h.

◆ arborescence() [2/2]

template<typename vertex_idx_t, typename weight_t>
void deeplima::arborescence ( std::vector< uint32_t > & heads,
size_t len )

Definition at line 1130 of file arborescence.h.

◆ operator<<()

template<typename T>
std::ostream & deeplima::operator<< ( std::ostream & out,
const std::vector< T > & v )

Definition at line 22 of file birnn_seq_cls.h.

◆ pretty_bits_to_string()

template<class T>
std::string deeplima::pretty_bits_to_string ( const T arg)
inline

Definition at line 28 of file pretty.h.

◆ pretty_bits_to_string_one_byte()

std::string deeplima::pretty_bits_to_string_one_byte ( const uint8_t arg)
inline

Definition at line 16 of file pretty.h.

◆ split()

std::vector< std::string > deeplima::split ( const std::string & s,
char delim )

Definition at line 117 of file path_resolver.cpp.