LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
mwt_dict.h
Go to the documentation of this file.
1// Copyright 2021 CEA LIST
2// SPDX-FileCopyrightText: 2026 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#ifndef DEEPLIMA_CONLLU_MWT_DICT_H
7#define DEEPLIMA_CONLLU_MWT_DICT_H
8
9#include <cstdint>
10#include <ostream>
11#include <string>
12#include <vector>
13
14namespace deeplima
15{
16namespace CoNLLU
17{
18
19// Extract a multiword-token (MWT) expansion dictionary from CoNLL-U files.
20//
21// For every "N-M" range line, the surface form maps to the forms of the
22// following (M-N+1) real-word lines (e.g. French "du" -> ["de", "le"]).
23// Surfaces seen with several distinct expansions are resolved by frequency
24// (the most frequent expansion wins); discarded alternatives are logged to
25// std::cerr. The output has one line per surface:
26//
27// surface <TAB> count <TAB> word1 <TAB> word2 [<TAB> ...]
28//
29// where `count` is the frequency of the chosen expansion (usable downstream to
30// drop rare/noisy entries). Returns the number of distinct surfaces written.
31// Writes the multiword-token dictionary of the conllu files (each surface with
32// its most frequent expansion) then the affix rules learned from it, kept when
33// at least min_rule_support entries give them (0: no rules). See
34// deeplima/mwt_lexicon.h for the format. Returns the number of entries.
35size_t extract_mwt_dict(const std::vector<std::string>& conllu_files, std::ostream& out,
36 uint32_t min_rule_support = 2, size_t* rules_written = nullptr);
37
38} // namespace CoNLLU
39} // namespace deeplima
40
41#endif
size_t extract_mwt_dict(const vector< string > &conllu_files, ostream &out, uint32_t min_rule_support, size_t *rules_written)
Definition mwt_dict.cpp:23
Edit rules for lemmatizing words absent from the lemma dictionary.