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

Function LoadEntries

data/dictionary/DictionaryPhraseCharacterDependencyTest.cpp:66–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66std::vector<Entry> LoadEntries(const std::string& path) {
67 std::ifstream stream(path);
68 EXPECT_TRUE(stream.is_open()) << path;
69
70 std::vector<Entry> entries;
71 std::string line;
72 size_t lineNumber = 0;
73 while (std::getline(stream, line)) {
74 ++lineNumber;
75 if (!IsDictionaryEntry(line)) {
76 continue;
77 }
78
79 const size_t tab = line.find('\t');
80 if (tab == std::string::npos) {
81 ADD_FAILURE() << path << ":" << lineNumber
82 << " is missing a tab separator.";
83 continue;
84 }
85 entries.push_back(Entry{lineNumber, line.substr(0, tab),
86 SplitValues(line.substr(tab + 1))});
87 }
88 return entries;
89}
90
91std::unordered_map<std::string, std::unordered_set<std::string>>
92LoadCharacterCandidates(const std::string& path) {

Calls 6

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

Tested by

no test coverage detected