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

Function LoadIdentityPhraseKeys

data/dictionary/DictionaryVariantRevPhrasesTest.cpp:193–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193std::unordered_set<std::string> LoadIdentityPhraseKeys(
194 const std::string& phrasesPath) {
195 std::ifstream stream(phrasesPath);
196 EXPECT_TRUE(stream.is_open()) << phrasesPath;
197
198 std::unordered_set<std::string> identityKeys;
199 std::string line;
200 while (std::getline(stream, line)) {
201 if (!IsDictionaryEntry(line)) {
202 continue;
203 }
204
205 const size_t tab = line.find('\t');
206 if (tab == std::string::npos) {
207 ADD_FAILURE() << line;
208 continue;
209 }
210 const std::string key = line.substr(0, tab);
211 const std::string values = line.substr(tab + 1);
212 for (const std::string& value : SplitValues(values)) {
213 if (key == value) {
214 identityKeys.insert(key);
215 break;
216 }
217 }
218 }
219 return identityKeys;
220}
221
222void ExpectRevPhrasesComplete(const std::string& variantsName) {
223 std::unique_ptr<Runfiles> runfiles(Runfiles::CreateForTest());

Callers 1

ExpectRevPhrasesCompleteFunction · 0.85

Calls 6

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

Tested by

no test coverage detected