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

Function LoadUserDict

plugins/jieba/tools/cppjieba_dict.cpp:202–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202void LoadUserDict(const std::string& path,
203 std::map<std::string, std::vector<std::string> >& entries) {
204 std::ifstream ifs(path.c_str());
205 if (!ifs.is_open()) {
206 throw std::runtime_error("failed to open user dict: " + path);
207 }
208
209 std::string line;
210 size_t line_number = 0;
211 while (std::getline(ifs, line)) {
212 ++line_number;
213 if (IsCommentOrEmpty(line)) {
214 continue;
215 }
216 const std::vector<std::string> tokens = SplitWhitespace(line);
217 if (tokens.empty()) {
218 continue;
219 }
220 entries[tokens[0]] = ParseUserDictValues(tokens, line_number);
221 }
222}
223
224void WriteOcd2(const std::map<std::string, std::vector<std::string> >& entries,
225 const std::string& output_path) {

Callers 2

mainFunction · 0.85
InitMethod · 0.85

Calls 5

IsCommentOrEmptyFunction · 0.85
SplitWhitespaceFunction · 0.85
ParseUserDictValuesFunction · 0.85
is_openMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected