fix(kon): normalise British English table, single-pass whitespace collapse, byte-index safety

- Normalise BRITISH_REPLACEMENTS: remove baked-in \b from entries so all
  entries are plain base words; the function adds boundaries uniformly
- Replace O(n*m) while-loop double-space removal with single-pass collapse
- Add debug_assert! documenting ASCII assumption for byte-indexed suffix slicing
- Expand llm_client.rs module-level doc comment
- Run cargo fmt on ai-formatting crate

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jake
2026-03-17 00:19:59 +00:00
parent 95c8d490c3
commit 2ac98e6d40
4 changed files with 81 additions and 88 deletions

View File

@@ -31,10 +31,7 @@ impl FormatMode {
/// Apply all post-processing steps to a list of segments.
/// Modifies segments in place. Composed from individual pure functions.
pub fn post_process_segments(
segments: &mut Vec<Segment>,
options: &PostProcessOptions,
) {
pub fn post_process_segments(segments: &mut Vec<Segment>, options: &PostProcessOptions) {
if options.anti_hallucination {
segments.retain(|seg| !rule_based::is_hallucination(&seg.text));
}
@@ -55,8 +52,7 @@ pub fn post_process_segments(
for i in (1..segments.len()).rev() {
let gap = segments[i].start - segments[i - 1].end;
if gap > SMART_PARAGRAPH_GAP_SECS {
segments[i].text =
format!("\n\n{}", segments[i].text.trim_start());
segments[i].text = format!("\n\n{}", segments[i].text.trim_start());
}
}
}