| 33 | |
| 34 | // ── Helpers ───────────────────────────────────────────────────────────── |
| 35 | |
| 36 | std::string normalize_model_card_stem(const std::string & general_name) { |
| 37 | std::string out; |
| 38 | out.reserve(general_name.size()); |
| 39 | for (char c : general_name) { |
| 40 | const unsigned char uc = static_cast<unsigned char>(c); |
| 41 | if (uc == ' ' || uc == '\t' || uc == '_') { |
| 42 | out.push_back('-'); |
| 43 | } else if (uc >= 'A' && uc <= 'Z') { |
| 44 | out.push_back(static_cast<char>(uc - 'A' + 'a')); |
| 45 | } else if ((uc >= 'a' && uc <= 'z') || |
| 46 | (uc >= '0' && uc <= '9') || |
| 47 | uc == '.' || uc == '-') { |
| 48 | out.push_back(static_cast<char>(uc)); |
| 49 | } |
| 50 | // else: silently drop punctuation |
| 51 | } |
| 52 | return out; |
| 53 | } |
| 54 | |
| 55 | static bool file_exists(const std::string & path) { |
no test coverage detected