pub struct TextPositionIndex { /* private fields */ }Expand description
Maps character offsets in concatenated document text to PDF coordinates.
Built from per-page ExtractedText (with preserve_layout: true),
this index allows mapping a character range (like those in DocumentChunk)
back to the physical locations on PDF pages.
Implementations§
Source§impl TextPositionIndex
impl TextPositionIndex
Sourcepub fn build(pages: &[ExtractedText]) -> Self
pub fn build(pages: &[ExtractedText]) -> Self
Build an index from per-page extracted text.
Pages are concatenated with "\n\n" separators (matching the chunker).
For each page’s TextFragment, we find its position in the page text
and compute the global character offset.
Sourcepub fn fragments_for_range(
&self,
start: usize,
end: usize,
) -> Vec<&IndexedFragment>
pub fn fragments_for_range( &self, start: usize, end: usize, ) -> Vec<&IndexedFragment>
Find all fragments whose character range overlaps with [start, end).
Sourcepub fn page_offset(&self, page: usize) -> Option<usize>
pub fn page_offset(&self, page: usize) -> Option<usize>
Get the character offset where a given page starts.
Sourcepub fn entries(&self) -> &[IndexedFragment]
pub fn entries(&self) -> &[IndexedFragment]
All indexed entries (for inspection/testing).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextPositionIndex
impl RefUnwindSafe for TextPositionIndex
impl Send for TextPositionIndex
impl Sync for TextPositionIndex
impl Unpin for TextPositionIndex
impl UnsafeUnpin for TextPositionIndex
impl UnwindSafe for TextPositionIndex
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