Repository navigation
Add Tabula table extraction to the PdfPig provider - #99
Open
luisquintanilla wants to merge 3 commits into
Open
luisquintanilla wants to merge 3 commits into
luisquintanilla wants to merge 3 commits into
Conversation
Introduce PdfPigDocumentExtractionClientOptions and PdfPigTableExtractionMode. Lattice (default) detects ruled tables with merged-cell spans; LatticeThenStream adds whitespace-aligned tables. Cell text is built from PdfPig words so every word is emitted exactly once, and None preserves the previous output. Refs #98 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pins 10 table pages and 5 negative controls from llamaindex/ParseBench-2 by revision and SHA-256. The tests download and cache the pages, and check text conservation, None-mode compatibility, table dimensions, reference facts and well-formed grids. Refs #98 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #98 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Closes #98
Summary
CommunityToolkit.DocumentExtraction.PdfPignow detects tables in native (searchable) PDFs using tabula-sharp (Tabula1.0.1) and emits them asExtractionDocumentTableElements with cell text, row/column spans and source polygons. Words placed in a table cell are removed from the surrounding text blocks, so content is not duplicated.API
PdfPigDocumentExtractionClientOptions(keeps future settings off the constructor):TableExtraction(PdfPigTableExtractionMode)PageSegmenter,WordExtractor,RoleResolver(previously constructor-only)PdfPigTableExtractionMode:None: text only (previous behavior)Lattice(default): tables drawn with ruling linesLatticeThenStream: lattice, then whitespace-aligned tables on the remaining text1.1.0-preview.Behavior change
With the new
Latticedefault, words inside ruled tables now appear as table cells instead of text blocks. SetTableExtraction = PdfPigTableExtractionMode.Noneto get the earlier output; a corpus test verifies it is byte-identical to the previous behavior.Pipeline notes / deviations from the original issue sketch
Tests
PdfPigTableExtractionTests): synthetic PDFs cover lattice, merged cells, stream mode,None, word conservation, options validation and the legacy constructor.PdfPigCorpusTests) on 15 pages from the public ParseBench-2 dataset (Apache-2.0), pinned to a specific revision:Noneparity.test/Corpus/ParseBench-2/corpus.jsonlists URLs and SHA-256 hashes:DOCUMENT_EXTRACTION_CORPUS_DIRor the temp directory);actions/cache, keyed on the manifest hash;Results: all DocumentExtraction test projects pass in Release (PdfPig: 193 tests).
dotnet packproduces a nuspec with dependencies onPdfPig0.1.15 andTabula1.0.1.Corpus evidence (lattice/stream adjacency agreement against ParseBench-2 ground truth)
Word conservation: no missing or extra characters on any page. Typical page time is under 250 ms; the densest page takes about 1 s.
Known limitations
These are documented in the README and in
corpus.jsonknown gaps.Latticefinds only ruled tables. On partially ruled tables it may capture just the ruled header.LatticeThenStreamcan report charts or forms as tables and does not infer merged cells.Docs
Updated the PdfPig README (new "Read tables" section and an options example), the DocumentExtraction and root READMEs, and the PdfPig agent skill.