MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / LoadMultiVariantSets

Function LoadMultiVariantSets

data/dictionary/DictionaryVariantRevPhrasesTest.cpp:42–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42std::vector<std::unordered_set<std::string>> LoadMultiVariantSets(
43 const std::string& path) {
44 std::ifstream stream(path);
45 EXPECT_TRUE(stream.is_open()) << path;
46
47 std::vector<std::unordered_set<std::string>> variantSets;
48 std::string line;
49 while (std::getline(stream, line)) {
50 if (!IsDictionaryEntry(line)) {
51 continue;
52 }
53
54 const size_t firstTab = line.find('\t');
55 if (firstTab == std::string::npos) {
56 continue;
57 }
58 const size_t secondTab = line.find('\t', firstTab + 1);
59 const std::string variantsText =
60 line.substr(firstTab + 1, secondTab - firstTab - 1);
61 std::vector<std::string> variants = SplitValues(variantsText);
62 if (variants.size() <= 1) {
63 continue;
64 }
65
66 variantSets.emplace_back(variants.begin(), variants.end());
67 }
68 return variantSets;
69}
70
71bool IsInSameMultiVariantSet(
72 const std::vector<std::unordered_set<std::string>>& variantSets,

Callers 1

Calls 8

findMethod · 0.80
IsDictionaryEntryFunction · 0.70
SplitValuesFunction · 0.70
is_openMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected