Add table_grid_fill: fill a ruling-line grid with OCR text#374
Merged
Conversation
edge_lines.find_grid recovers a bordered table's geometry but leaves the cells empty; OCR gives the text but no structure, and nothing joined them. Drop OCR boxes into the grid (assigned by cell-centre, gated by an overlap fraction), concatenate each cell's text in reading order, flag merged-cell spans, and convert to records / CSV. Pure-stdlib over plain dicts.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 50 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
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
Adds
populate_table/assign_text_to_grid/table_to_records/table_to_csv— join a bordered table's ruling-line geometry with OCR text boxes into an addressableR x Ctable.edge_lines.find_gridalready recovers{rows:[y…], cols:[x…], cells:[…]}but the cells come back empty; OCR gives the text but no table structure. Nothing joined the two, so reading a bordered table meant hand-rolling the box→cell assignment.Each box is assigned to the cell its centre falls in (gated by an
overlapfraction so a box straddling a thin rule isn't double-counted), text within a cell is concatenated in reading order, and boxes that straddle multiple cells are reported as merged-cell candidates. Converts straight to records / CSV. Pure-stdlib geometry over plain dicts — no image, no OCR engine, no device. Qt-free.Layers
utils/table_grid_fill/—assign_text_to_grid,populate_table,table_to_records,table_to_csv.je_auto_control+__all__.AC_populate_table(grid/text_boxes/overlap→{n_rows, n_cols, cells, spans}).ac_populate_table(read-only).Tests
test/unit_test/headless/test_table_grid_fill_batch.py— row-major fill, multi-word reading-order join, out-of-grid drop, dims + cells reporting, merged-cell span detection, records + CSV. 8 passed. ruff / bandit / radon / float-scan / Qt-free all clean.