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

Function append_piece_chunks

src/framework/text/chunking.cpp:197–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195 !is_cjk_punctuation_delimiter(spans[word_end].text)) {
196 ++word_end;
197 }
198 const auto last = spans[word_end - 1].text;
199 words.push_back({
200 word_start,
201 word_end,
202 spans[word_start].start,
203 spans[word_end - 1].end,
204 is_sentence_break(last),
205 is_clause_break(last),
206 });
207 span_pos = word_end;
208 }
209 return words;
210}
211
212// A run of hanzi, kana or Hangul without punctuation has no word boundary, so it used to come back as one chunk over
213// the budget, which a model with a per-chunk length limit cuts short. Cut such words into about equal pieces, as
214// Japanese mode does, but only between two CJK letters, so tags, numbers and Latin text inside the word stay whole. A
215// word without such a boundary, like a long Latin word, stays whole.
216std::vector<WordRange> fit_cjk_runs(
217 const std::vector<Utf8Span> & spans,
218 const std::vector<WordRange> & words,
219 int64_t codepoint_budget) {
220 const auto budget = static_cast<size_t>(codepoint_budget);
221 std::vector<WordRange> out;
222 out.reserve(words.size());

Callers 1

split_tag_aware_bodyFunction · 0.85

Calls 3

unit_range_codepointsFunction · 0.85
join_unitsFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected