pub struct SemanticChunker { /* private fields */ }Expand description
Semantic chunker that respects sentence and paragraph boundaries.
This chunker produces more coherent chunks by avoiding splits in the middle of sentences or words. It uses Unicode segmentation rules for proper international text handling.
§Examples
use rlm_rs::chunking::{Chunker, SemanticChunker};
let chunker = SemanticChunker::new();
let text = "Hello, world! This is a test. Another sentence here.";
let chunks = chunker.chunk(1, text, None).unwrap();Implementations§
Source§impl SemanticChunker
impl SemanticChunker
Sourcepub const fn with_size(chunk_size: usize) -> Self
pub const fn with_size(chunk_size: usize) -> Self
Creates a semantic chunker with custom chunk size and no overlap.
Sourcepub const fn with_size_and_overlap(chunk_size: usize, overlap: usize) -> Self
pub const fn with_size_and_overlap(chunk_size: usize, overlap: usize) -> Self
Creates a semantic chunker with custom size and overlap.
Sourcepub const fn min_chunk_size(self, size: usize) -> Self
pub const fn min_chunk_size(self, size: usize) -> Self
Sets the minimum chunk size.
Trait Implementations§
Source§impl Chunker for SemanticChunker
impl Chunker for SemanticChunker
Source§fn chunk(
&self,
buffer_id: i64,
text: &str,
metadata: Option<&ChunkMetadata>,
) -> Result<Vec<Chunk>>
fn chunk( &self, buffer_id: i64, text: &str, metadata: Option<&ChunkMetadata>, ) -> Result<Vec<Chunk>>
Chunks the input text into segments. Read more
Source§fn supports_parallel(&self) -> bool
fn supports_parallel(&self) -> bool
Returns whether this chunker supports parallel processing. Read more
Source§fn description(&self) -> &'static str
fn description(&self) -> &'static str
Returns a description of the chunking strategy.
Source§impl Clone for SemanticChunker
impl Clone for SemanticChunker
Source§fn clone(&self) -> SemanticChunker
fn clone(&self) -> SemanticChunker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SemanticChunker
impl Debug for SemanticChunker
Auto Trait Implementations§
impl Freeze for SemanticChunker
impl RefUnwindSafe for SemanticChunker
impl Send for SemanticChunker
impl Sync for SemanticChunker
impl Unpin for SemanticChunker
impl UnwindSafe for SemanticChunker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more