Skip to content

Add table_grid_fill: fill a ruling-line grid with OCR text#374

Merged
JE-Chen merged 1 commit into
devfrom
feat/table-grid-fill-batch
Jun 23, 2026
Merged

Add table_grid_fill: fill a ruling-line grid with OCR text#374
JE-Chen merged 1 commit into
devfrom
feat/table-grid-fill-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 23, 2026

Copy link
Copy Markdown
Member

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 addressable R x C table. edge_lines.find_grid already 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 overlap fraction 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

  • Core: utils/table_grid_fill/assign_text_to_grid, populate_table, table_to_records, table_to_csv.
  • Facade: re-exported from je_auto_control + __all__.
  • Executor: AC_populate_table (grid / text_boxes / overlap{n_rows, n_cols, cells, spans}).
  • MCP: ac_populate_table (read-only).
  • Script Builder: Fill Table From Grid + OCR under OCR.
  • Docs: v162 EN + Zh + toctree. Changelog: root EN + zh-TW + zh-CN.

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.

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.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 50 complexity · 0 duplication

Metric Results
Complexity 50
Duplication 0

View in Codacy

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.

@JE-Chen JE-Chen merged commit cb15f12 into dev Jun 23, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/table-grid-fill-batch branch June 23, 2026 18:56
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant