Repository navigation
feat: keep source coordinates for single-page text chunks - #4865
Open
sviat-barbutsa wants to merge 1 commit into
Open
sviat-barbutsa wants to merge 1 commit into
sviat-barbutsa wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3194. When two paragraphs are returned as a single chunk, I want to show the passage in search results and highlight it back on the original PDF. With
chunk_by_title(..., multipage_sections=False), source paragraphs carry coordinates, but the merged text chunk drops them.I build a bounding rectangle from the outermost points of the contributing elements when the entire passage maps to one page in a single coordinate system. This also works when
include_orig_elements=False. If the chunk is split, carries text from a prior chunk, or has missing or mismatched source coordinates, the coordinates stay empty. Default chunking and table handling stay unchanged.Validation
main. Across the full chunking suite, 721 tests passed and 2 skipped, and all 17 targeted PDF integration checks passed.chunk_by_titleandpartition_pdf(..., chunking_strategy="by_title")output against extracted text positions, both with and without retained original elements. I also checked serialized page numbers, coordinate systems, and rounded points.combine_text_under_n_chars=0for the page-by-page check and separately confirmed that chunks merged across pages do not get a rectangle.mypypassed on the three modified files. In a wider Windows run, 1,051 tests passed and 6 skipped, with all 8 failures reproducing on cleanmain. The full repository suite was not run end-to-end. A separate pass over remaining suites stopped on a translation test needingSentencePieceand a file-detection test needinglibmagic, both of which also failed on cleanmain.Checklist
feat:prefix.enhancementlabel?For breaking changes, include migration instructions.