MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / unicode_regex_split_custom

Function unicode_regex_split_custom

smallthinker/src/unicode.cpp:555–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553}
554
555static std::vector<size_t> unicode_regex_split_custom(const std::string & text, const std::string & regex_expr, const std::vector<size_t> & offsets) {
556 std::vector<size_t> bpe_offsets;
557
558 if (regex_expr == "'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)") {
559 bpe_offsets = unicode_regex_split_custom_gpt2(text, offsets);
560 } else if (
561 regex_expr == "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}{1,3}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+" ||
562 regex_expr == "(?:'[sS]|'[tT]|'[rR][eE]|'[vV][eE]|'[mM]|'[lL][lL]|'[dD])|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}{1,3}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+") {
563
564 bpe_offsets = unicode_regex_split_custom_llama3(text, offsets);
565 }
566
567 return bpe_offsets;
568}
569
570//
571// interface

Callers 1

unicode_regex_splitFunction · 0.85

Tested by

no test coverage detected