LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
lemm_rules.h File Reference
#include <algorithm>
#include <cstdint>
#include <functional>
#include <istream>
#include <map>
#include <ostream>
#include <stdexcept>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#include <unicode/uchar.h>
#include <unicode/unistr.h>

Go to the source code of this file.

Classes

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

Namespaces

namespace  deeplima
 Edit rules for lemmatizing words absent from the lemma dictionary.
namespace  deeplima::lemmatization

Functions

std::u32string deeplima::lemmatization::to_lower (const std::u32string &src)
 Lowercases code point by code point (ICU simple case mapping, any script).
std::u32string deeplima::lemmatization::utf8_to_u32 (const std::string &src)
std::string deeplima::lemmatization::u32_to_utf8 (const std::u32string &src)
edit_rule_t deeplima::lemmatization::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 deeplima::lemmatization::edit_cost (const affix_rule_t &r)
 The length of the edit: characters stripped and added at both ends.
affix_rule_t deeplima::lemmatization::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 deeplima::lemmatization::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 deeplima::lemmatization::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 deeplima::lemmatization::apply_rule (const std::u32string &form, const edit_rule_t &rule, std::u32string &lemma)
 Applies a suffix rule alone (see above).
const std::string & deeplima::lemmatization::any_feats ()
 The feats value of the rule used when no rule matches the exact features.
std::vector< std::string > deeplima::lemmatization::split_tabs (const std::string &line)
 Splits on tabs, keeping empty fields (utils::split drops them).
void deeplima::lemmatization::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.