MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / build_cjk_split_map

Function build_cjk_split_map

src/models/voxcpm2/tokenizer_text.cpp:250–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250void build_cjk_split_map(VoxCPM2TextTokenizer::Impl & impl) {
251 for (const auto & [id, token] : impl.id_to_token) {
252 const std::string clean = strip_sentencepiece_prefix(token);
253 if (!is_pure_multichar_cjk(clean)) {
254 continue;
255 }
256 std::vector<int32_t> char_ids;
257 for (const auto & ch : utf8_codepoints(clean)) {
258 const auto it = impl.vocab.find(ch);
259 if (it == impl.vocab.end()) {
260 char_ids.clear();
261 break;
262 }
263 char_ids.push_back(it->second);
264 }
265 if (!char_ids.empty()) {
266 impl.cjk_split_map.emplace(id, std::move(char_ids));
267 }
268 }
269}
270
271std::shared_ptr<const VoxCPM2TextTokenizer::Impl> load_impl(const VoxCPM2Assets & assets) {
272 auto impl = std::make_shared<VoxCPM2TextTokenizer::Impl>();

Callers 1

load_implFunction · 0.85

Calls 7

is_pure_multichar_cjkFunction · 0.85
utf8_codepointsFunction · 0.70
findMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected