feat: dictation segmentation on blank lines
This commit is contained in:
+20
-1
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user