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

Function LoadPreferredValues

data/dictionary/DictionaryVariantRevPhrasesTest.cpp:82–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82std::unordered_map<std::string, std::string> LoadPreferredValues(
83 const std::string& path) {
84 std::ifstream stream(path);
85 EXPECT_TRUE(stream.is_open()) << path;
86
87 std::unordered_map<std::string, std::string> preferredValues;
88 std::string line;
89 while (std::getline(stream, line)) {
90 if (!IsDictionaryEntry(line)) {
91 continue;
92 }
93
94 const size_t tab = line.find('\t');
95 if (tab == std::string::npos) {
96 ADD_FAILURE() << line;
97 continue;
98 }
99 const std::string key = line.substr(0, tab);
100 const std::vector<std::string> values = SplitValues(line.substr(tab + 1));
101 if (!values.empty()) {
102 preferredValues[key] = values.front();
103 }
104 }
105 return preferredValues;
106}
107
108std::unordered_set<std::string> LoadReverseExceptionCharacters(
109 const std::string& variantsPath, const std::string& variantsRevPath,

Callers 1

Calls 6

findMethod · 0.80
IsDictionaryEntryFunction · 0.70
SplitValuesFunction · 0.70
is_openMethod · 0.45
substrMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected