pub struct TextChunk {
pub id: usize,
pub text: String,
pub char_offset: usize,
pub char_length: usize,
pub document_id: Option<String>,
pub has_overlap: bool,
pub overlap_info: Option<(usize, usize)>,
}
Expand description
A chunk of text with metadata
Fields§
§id: usize
The chunk ID
text: String
Text content of the chunk
char_offset: usize
Character offset from the beginning of the original document
char_length: usize
Length of the chunk in characters
document_id: Option<String>
Original document this chunk belongs to
has_overlap: bool
Whether this chunk overlaps with adjacent chunks
overlap_info: Option<(usize, usize)>
Overlap information (start and end overlap lengths)
Implementations§
Source§impl TextChunk
impl TextChunk
Sourcepub fn new(
id: usize,
text: String,
char_offset: usize,
document_id: Option<String>,
) -> Self
pub fn new( id: usize, text: String, char_offset: usize, document_id: Option<String>, ) -> Self
Create a new text chunk
Sourcepub fn with_overlap(
id: usize,
text: String,
char_offset: usize,
document_id: Option<String>,
overlap_start: usize,
overlap_end: usize,
) -> Self
pub fn with_overlap( id: usize, text: String, char_offset: usize, document_id: Option<String>, overlap_start: usize, overlap_end: usize, ) -> Self
Create a chunk with overlap information
Sourcepub fn char_interval(&self) -> CharInterval
pub fn char_interval(&self) -> CharInterval
Get the character interval for this chunk in the original document
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextChunk
impl RefUnwindSafe for TextChunk
impl Send for TextChunk
impl Sync for TextChunk
impl Unpin for TextChunk
impl UnwindSafe for TextChunk
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