| 110 | } |
| 111 | } |
| 112 | if (!buffer.empty()) { |
| 113 | out.push_back(buffer); |
| 114 | } |
| 115 | return out; |
| 116 | } |
| 117 | |
| 118 | std::vector<std::string> tokenize_space_language(const std::string & text) { |
| 119 | std::vector<std::string> words; |
| 120 | std::string segment; |
| 121 | auto flush = [&]() { |
| 122 | if (segment.empty()) { |
| 123 | return; |
| 124 | } |
| 125 | const auto cleaned = clean_token(segment); |
| 126 | if (!cleaned.empty()) { |
| 127 | auto split = split_segment_with_chinese(cleaned); |
| 128 | words.insert(words.end(), split.begin(), split.end()); |
| 129 | } |
| 130 | segment.clear(); |
| 131 | }; |
| 132 | for (const auto & ch : utf8_chars(text)) { |
| 133 | if (ch.codepoint == ' ' || ch.codepoint == '\t' || ch.codepoint == '\n' || ch.codepoint == '\r') { |
| 134 | flush(); |
| 135 | } else { |
| 136 | segment += ch.text; |
| 137 | } |
| 138 | } |
no test coverage detected