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

Function unicode_cpt_flags_array

external/llama_tokenizer/unicode.cpp:116–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114//}
115
116static std::vector<unicode_cpt_flags> unicode_cpt_flags_array() {
117 std::vector<unicode_cpt_flags> cpt_flags(MAX_CODEPOINTS, unicode_cpt_flags::UNDEFINED);
118
119 assert (unicode_ranges_flags.begin()[0].first == 0);
120 assert (unicode_ranges_flags.begin()[unicode_ranges_flags.size()-1].first == MAX_CODEPOINTS);
121 for (size_t i = 1; i < unicode_ranges_flags.size(); ++i) {
122 const auto range_ini = unicode_ranges_flags.begin()[i-1]; // codepoint_ini, flags
123 const auto range_end = unicode_ranges_flags.begin()[i]; // codepoint_end, flags
124 for (uint32_t cpt = range_ini.first; cpt < range_end.first; ++cpt) {
125 cpt_flags[cpt] = range_ini.second;
126 }
127 }
128
129 for (auto cpt : unicode_set_whitespace) {
130 cpt_flags[cpt].is_whitespace = true;
131 }
132
133 for (auto p : unicode_map_lowercase) {
134 cpt_flags[p.second].is_lowercase = true;
135 }
136
137 for (auto p : unicode_map_uppercase) {
138 cpt_flags[p.second].is_uppercase = true;
139 }
140
141 for (auto &range : unicode_ranges_nfd) { // start, last, nfd
142 cpt_flags[range.nfd].is_nfd = true;
143 }
144
145 return cpt_flags;
146}
147
148static std::unordered_map<uint8_t, std::string> unicode_byte_to_utf8_map() {
149 std::unordered_map<uint8_t, std::string> map;

Callers 1

Calls 2

beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected