25 map<string, map<vector<string>,
size_t>> dict;
27 for (
const auto& fn : conllu_files)
32 throw runtime_error(
"extract_mwt_dict: can't open \"" + fn +
"\"");
36 while (getline(input, line))
38 if (line.empty() || line[0] ==
'#')
50 const string surface = l.
form();
55 vector<string> expansion;
56 expansion.reserve(n_sub);
58 while (collected < n_sub && getline(input, line))
77 expansion.push_back(w.
form());
81 if (collected == n_sub && !surface.empty() && expansion.size() >= 2)
83 dict[surface][expansion]++;
89 for (
const auto& [surface, expansions] : dict)
91 const vector<string>* best =
nullptr;
92 size_t best_count = 0;
94 for (
const auto& [exp, count] : expansions)
97 if (count > best_count)
108 if (expansions.size() > 1)
110 cerr <<
"extract_mwt_dict: ambiguous surface \"" << surface <<
"\" ("
111 << expansions.size() <<
" expansions); keeping the most frequent ("
112 << best_count <<
"/" << total <<
")." << endl;
115 out << surface <<
"\t" << best_count;
116 for (
const auto& w : *best)