feat: dictation segmentation on blank lines

This commit is contained in:
2026-05-18 16:38:21 +02:00
parent 9f3e79c874
commit 27d5144864
2 changed files with 42 additions and 1 deletions
+20 -1
View File
@@ -1 +1,20 @@
// implemented in a later task
/// Split a dictation into Befund segments on Markdown paragraph
/// breaks (one or more blank lines). Trims each segment; drops empties.
pub fn split_segments(dictation: &str) -> Vec<String> {
let mut segments = Vec::new();
let mut current: Vec<&str> = Vec::new();
for line in dictation.lines() {
if line.trim().is_empty() {
if !current.is_empty() {
segments.push(current.join("\n").trim().to_string());
current.clear();
}
} else {
current.push(line);
}
}
if !current.is_empty() {
segments.push(current.join("\n").trim().to_string());
}
segments.into_iter().filter(|s| !s.is_empty()).collect()
}