pub struct TextChunk {
pub id: ChunkId,
pub document_id: DocumentId,
pub content: String,
pub start_offset: usize,
pub end_offset: usize,
pub embedding: Option<Vec<f32>>,
pub entities: Vec<EntityId>,
pub metadata: ChunkMetadata,
}Expand description
A chunk of text from a document
Fields§
§id: ChunkIdUnique identifier for the chunk
document_id: DocumentIdID of the parent document
content: StringText content of the chunk
start_offset: usizeStarting character offset in the original document
end_offset: usizeEnding character offset in the original document
embedding: Option<Vec<f32>>Optional vector embedding for the chunk
entities: Vec<EntityId>List of entity IDs mentioned in this chunk
metadata: ChunkMetadataSemantic metadata for the chunk (chapter, keywords, summary, etc.)
Implementations§
Source§impl TextChunk
impl TextChunk
Sourcepub fn new(
id: ChunkId,
document_id: DocumentId,
content: String,
start_offset: usize,
end_offset: usize,
) -> Self
pub fn new( id: ChunkId, document_id: DocumentId, content: String, start_offset: usize, end_offset: usize, ) -> Self
Create a new text chunk
Sourcepub fn with_embedding(self, embedding: Vec<f32>) -> Self
pub fn with_embedding(self, embedding: Vec<f32>) -> Self
Add an embedding to the chunk
Sourcepub fn with_entities(self, entities: Vec<EntityId>) -> Self
pub fn with_entities(self, entities: Vec<EntityId>) -> Self
Add entities to the chunk
Sourcepub fn with_metadata(self, metadata: ChunkMetadata) -> Self
pub fn with_metadata(self, metadata: ChunkMetadata) -> Self
Add metadata to the chunk
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TextChunk
impl<'de> Deserialize<'de> for TextChunk
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TextChunk
impl RefUnwindSafe for TextChunk
impl Send for TextChunk
impl Sync for TextChunk
impl Unpin for TextChunk
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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