Paragraph-based splitting: split at double-newline boundaries. If a single paragraph exceeds chunk_size, it falls back to sentence split, then character split if needed.
(
text: &str,
chunk_size: usize,
overlap: usize,
)
| 162 | /// If a single paragraph exceeds chunk_size, it falls back to sentence split, |
| 163 | /// then character split if needed. |
| 164 | fn chunk_by_paragraphs( |
| 165 | text: &str, |
| 166 | chunk_size: usize, |
| 167 | overlap: usize, |
| 168 | ) -> Result<Vec<TextChunk>, ChunkError> { |
| 169 | let paragraphs = split_paragraphs(text); |
| 170 | if paragraphs.is_empty() { |
| 171 | return Ok(Vec::new()); |
| 172 | } |
| 173 | |
| 174 | build_chunks_from_segments(¶graphs, chunk_size, overlap) |
| 175 | } |
| 176 | |
| 177 | /// Split text into sentences at `.` `!` `?` followed by whitespace or end-of-string. |
| 178 | /// |
no test coverage detected