MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / chunk_by_paragraphs

Function chunk_by_paragraphs

nodedb-query/src/chunk_text.rs:164–175  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

162/// If a single paragraph exceeds chunk_size, it falls back to sentence split,
163/// then character split if needed.
164fn 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(&paragraphs, chunk_size, overlap)
175}
176
177/// Split text into sentences at `.` `!` `?` followed by whitespace or end-of-string.
178///

Callers 1

chunk_textFunction · 0.85

Calls 3

split_paragraphsFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected