MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / KV2Map

Method KV2Map

src/io/config.cpp:15–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace LightGBM {
14
15void Config::KV2Map(std::unordered_map<std::string, std::string>* params, const char* kv) {
16 std::vector<std::string> tmp_strs = Common::Split(kv, '=');
17 if (tmp_strs.size() == 2 || tmp_strs.size() == 1) {
18 std::string key = Common::RemoveQuotationSymbol(Common::Trim(tmp_strs[0]));
19 std::string value = "";
20 if (tmp_strs.size() == 2) {
21 value = Common::RemoveQuotationSymbol(Common::Trim(tmp_strs[1]));
22 }
23 if (!Common::CheckASCII(key) || !Common::CheckASCII(value)) {
24 Log::Fatal("Do not support non-ASCII characters in config.");
25 }
26 if (key.size() > 0) {
27 auto value_search = params->find(key);
28 if (value_search == params->end()) { // not set
29 params->emplace(key, value);
30 } else {
31 Log::Warning("%s is set=%s, %s=%s will be ignored. Current value: %s=%s",
32 key.c_str(), value_search->second.c_str(), key.c_str(), value.c_str(),
33 key.c_str(), value_search->second.c_str());
34 }
35 }
36 } else {
37 Log::Warning("Unknown parameter %s", kv);
38 }
39}
40
41std::unordered_map<std::string, std::string> Config::Str2Map(const char* parameters) {
42 std::unordered_map<std::string, std::string> params;

Callers

nothing calls this directly

Calls 7

SplitFunction · 0.50
RemoveQuotationSymbolFunction · 0.50
TrimFunction · 0.50
CheckASCIIFunction · 0.50
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected