MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / sam3_utf8_chars

Function sam3_utf8_chars

sam3.cpp:1248–1257  ·  view source on GitHub ↗

Split a UTF-8 string into individual unicode characters.

Source from the content-addressed store, hash-verified

1246
1247// Split a UTF-8 string into individual unicode characters.
1248static 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>").

Callers 1

sam3_bpe_encodeFunction · 0.85

Calls 1

sam3_utf8_lenFunction · 0.85

Tested by

no test coverage detected