Split a UTF-8 string into individual unicode characters.
| 1246 | |
| 1247 | // Split a UTF-8 string into individual unicode characters. |
| 1248 | static std::vector<std::string> sam3_utf8_chars(const std::string& s) { |
| 1249 | std::vector<std::string> chars; |
| 1250 | size_t i = 0; |
| 1251 | while (i < s.size()) { |
| 1252 | int len = sam3_utf8_len((uint8_t)s[i]); |
| 1253 | chars.push_back(s.substr(i, len)); |
| 1254 | i += len; |
| 1255 | } |
| 1256 | return chars; |
| 1257 | } |
| 1258 | |
| 1259 | // Apply BPE merges to a byte-encoded word string. |
| 1260 | // Returns space-separated BPE tokens (e.g. "he llo</w>"). |
no test coverage detected