| 13 | namespace LightGBM { |
| 14 | |
| 15 | void 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 | |
| 41 | std::unordered_map<std::string, std::string> Config::Str2Map(const char* parameters) { |
| 42 | std::unordered_map<std::string, std::string> params; |
nothing calls this directly
no test coverage detected