Anonymous user
Textonyms: Difference between revisions
→{{header|C++}}: minor modifications
m (corrected a misspelling in the task's preamble.) |
(→{{header|C++}}: minor modifications) |
||
Line 396:
=={{header|C++}}==
<lang cpp>#include <fstream>
#include <iostream>
#include <unordered_map>
Line 434 ⟶ 433:
public:
Textonym_Checker(
~Textonym_Checker(
void add(const std::string &str) {
std::string mapping;
total
if (!get_mapping(mapping, str)) return;
Line 446 ⟶ 445:
const int num_strings = values[mapping].size();
elements
if (num_strings > max_found) {
Line 454 ⟶ 453:
max_found = num_strings;
}
else if (num_strings == max_found)
max_strings.push_back(mapping);
values[mapping].push_back(str);
Line 472 ⟶ 470:
std::cout << max_found + 1 << " words each:\n";
for (auto it1
std::cout << '\t' <<
for (auto it2
std::cout <<
}
std::cout << '\n';
Line 490 ⟶ 487:
else {
std::cout << "Key '" << str << "' matches: ";
for (auto it
std::cout <<
std::cout << '\n';
}
Line 497 ⟶ 494:
};
int main(
{
std::ifstream input(filename);
Textonym_Checker tc;
Line 516 ⟶ 513:
tc.match("27484247");
tc.match("7244967473642");
}</lang>▼
▲</lang>
{{out}}
<pre>Read 25104 words from unixdict.txt▼
▲Read 25104 words from unixdict.txt
There are 24988 words in unixdict.txt which can be represented by the digit key mapping.
|