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

Namespaces

namespace  eigen_impl
namespace  impl
namespace  train

Classes

struct  edit_rule_t
struct  affix_rule_t
 A whole word's edit: a prefix rule (never lowercasing) and a suffix rule. More...
class  lemm_rules_builder_t
 Learns rules from (form, UPOS, FEATS, lemma) observations and writes them. More...
struct  rule_line_t
 One line of a rules file, as read_rules() hands it over. More...
class  lemm_rules_t
 Rules ready for lookup, keyed by K, the analyzer's encoding of UPOS(+FEATS) (morph_feats_t in TokenSequenceAnalyzer, strings in tests). More...

Functions

std::u32string to_lower (const std::u32string &src)
 Lowercases code point by code point (ICU simple case mapping, any script).
std::u32string utf8_to_u32 (const std::string &src)
std::string u32_to_utf8 (const std::u32string &src)
edit_rule_t extract_rule (const std::u32string &form, const std::u32string &lemma)
 The rule turning form into lemma that keeps the longest common prefix: lowercasing is part of the rule only when it shortens the edit ("Princes" -> "prince" is {true, 1, ""}, "Paris" -> "Paris" is {false, 0, ""}).
size_t edit_cost (const affix_rule_t &r)
 The length of the edit: characters stripped and added at both ends.
affix_rule_t extract_substring_rule (const std::u32string &form, const std::u32string &lemma, bool lower)
 The edit turning form into lemma around their longest common substring, the earliest one in form, then in lemma, on equal lengths.
affix_rule_t extract_affix_rule (const std::u32string &form, const std::u32string &lemma, size_t max_prefix)
 The rule turning form into lemma with a prefix edit stripping at most max_prefix characters: the suffix rule of extract_rule unless an edit around the longest common substring is strictly shorter.
bool apply_rule (const std::u32string &form, const edit_rule_t &prefix, const edit_rule_t &suffix, std::u32string &lemma)
 Applies the prefix and suffix rules to form.
bool apply_rule (const std::u32string &form, const edit_rule_t &rule, std::u32string &lemma)
 Applies a suffix rule alone (see above).
const std::string & any_feats ()
 The feats value of the rule used when no rule matches the exact features.
std::vector< std::string > split_tabs (const std::string &line)
 Splits on tabs, keeping empty fields (utils::split drops them).
void read_rules (std::istream &in, const std::function< void(const rule_line_t &)> &fn)
 Reads a rules file, calling fn(const rule_line_t&) on each rule.

Function Documentation

◆ any_feats()

const std::string & deeplima::lemmatization::any_feats ( )
inline

The feats value of the rule used when no rule matches the exact features.

Definition at line 253 of file lemm_rules.h.

◆ apply_rule() [1/2]

bool deeplima::lemmatization::apply_rule ( const std::u32string & form,
const edit_rule_t & prefix,
const edit_rule_t & suffix,
std::u32string & lemma )
inline

Applies the prefix and suffix rules to form.

False when they do not apply (they strip more than the form) or would give an empty lemma.

Definition at line 227 of file lemm_rules.h.

◆ apply_rule() [2/2]

bool deeplima::lemmatization::apply_rule ( const std::u32string & form,
const edit_rule_t & rule,
std::u32string & lemma )
inline

Applies a suffix rule alone (see above).

Definition at line 247 of file lemm_rules.h.

◆ edit_cost()

size_t deeplima::lemmatization::edit_cost ( const affix_rule_t & r)
inline

The length of the edit: characters stripped and added at both ends.

Definition at line 153 of file lemm_rules.h.

◆ extract_affix_rule()

affix_rule_t deeplima::lemmatization::extract_affix_rule ( const std::u32string & form,
const std::u32string & lemma,
size_t max_prefix )
inline

The rule turning form into lemma with a prefix edit stripping at most max_prefix characters: the suffix rule of extract_rule unless an edit around the longest common substring is strictly shorter.

max_prefix 0 gives the suffix rule alone.

Definition at line 203 of file lemm_rules.h.

◆ extract_rule()

edit_rule_t deeplima::lemmatization::extract_rule ( const std::u32string & form,
const std::u32string & lemma )
inline

The rule turning form into lemma that keeps the longest common prefix: lowercasing is part of the rule only when it shortens the edit ("Princes" -> "prince" is {true, 1, ""}, "Paris" -> "Paris" is {false, 0, ""}).

Definition at line 128 of file lemm_rules.h.

◆ extract_substring_rule()

affix_rule_t deeplima::lemmatization::extract_substring_rule ( const std::u32string & form,
const std::u32string & lemma,
bool lower )
inline

The edit turning form into lemma around their longest common substring, the earliest one in form, then in lemma, on equal lengths.

Definition at line 162 of file lemm_rules.h.

◆ read_rules()

void deeplima::lemmatization::read_rules ( std::istream & in,
const std::function< void(const rule_line_t &)> & fn )
inline

Reads a rules file, calling fn(const rule_line_t&) on each rule.

Throws on a malformed line.

Definition at line 376 of file lemm_rules.h.

◆ split_tabs()

std::vector< std::string > deeplima::lemmatization::split_tabs ( const std::string & line)
inline

Splits on tabs, keeping empty fields (utils::split drops them).

Definition at line 359 of file lemm_rules.h.

◆ to_lower()

std::u32string deeplima::lemmatization::to_lower ( const std::u32string & src)
inline

Lowercases code point by code point (ICU simple case mapping, any script).

Definition at line 72 of file lemm_rules.h.

◆ u32_to_utf8()

std::string deeplima::lemmatization::u32_to_utf8 ( const std::u32string & src)
inline

Definition at line 95 of file lemm_rules.h.

◆ utf8_to_u32()

std::u32string deeplima::lemmatization::utf8_to_u32 ( const std::string & src)
inline

Definition at line 82 of file lemm_rules.h.