fix(pdf): recover whitespace when pdfminer collapses plain text#1733
Open
LaplaceYoung wants to merge 1 commit intomicrosoft:mainfrom
Open
fix(pdf): recover whitespace when pdfminer collapses plain text#1733LaplaceYoung wants to merge 1 commit intomicrosoft:mainfrom
LaplaceYoung wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree |
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 whitespace-collapse behavior for plain-text PDFs in issue #120 without regressing table/form extraction.
What changed
PdfConverterto identify pathological extraction where words are concatenated with almost no spaces.pdfplumberwith conservative spacing tolerances (x_tolerance=1,y_tolerance=3).pdfminerfallback for plain PDFs, but whenpdfmineroutput is detected as collapsed, now fallback to the already-collectedpdfplumberplain text if it is healthier.adaptive_max_columns) to reduce false-positive table extraction on dense academic layouts.Files
packages/markitdown/src/markitdown/converters/_pdf_converter.pypackages/markitdown/tests/test_pdf_memory.pyValidation
python -m pytest packages/markitdown/tests/test_pdf_memory.py -qpython -m pytest packages/markitdown/tests/test_pdf_tables.py::TestPdfTableExtraction::test_borderless_table_extraction packages/markitdown/tests/test_pdf_tables.py::TestPdfFullOutputComparison::test_academic_paper_full_output -qIssue
Closes #120