Keep adjacent numeric table columns separate - #424
Conversation
Preserve sparse header-to-data merging while preventing two predominantly numeric clusters from collapsing. Also split a two-value financial item only when its geometry crosses a ruled column boundary, keeping the heuristic splitter conservative.
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Shadow auto-approve: would not auto-approve because issues were found.
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
Classify clusters by their actual members, limit two-value splitting to ruled grids and text items, preserve heuristic slot alignment, and keep an original item intact when any split fragment cannot be placed.
|
Addressed in 4d90870:
Validation: full |
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/tables/detect_rects.rs">
<violation number="1" location="src/tables/detect_rects.rs:1534">
P2: When `columns_from_text` is true, this call treats inferred text-cluster midpoints as ruled boundaries and splits qualifying two-value items across them. Use `assign_items_to_grid` for that branch and reserve `assign_items_to_ruled_grid` for rect-derived columns.</violation>
</file>
Shadow auto-approve: would not auto-approve because issues were found.
Fix all with cubic | Re-trigger cubic
|
|
||
| // Build table: assign text items to cells | ||
| let (mut cells, item_indices) = assign_items_to_grid(items, &col_edges, &row_edges, page); | ||
| let (mut cells, item_indices) = assign_items_to_ruled_grid(items, &col_edges, &row_edges, page); |
There was a problem hiding this comment.
P2: When columns_from_text is true, this call treats inferred text-cluster midpoints as ruled boundaries and splits qualifying two-value items across them. Use assign_items_to_grid for that branch and reserve assign_items_to_ruled_grid for rect-derived columns.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/tables/detect_rects.rs, line 1534:
<comment>When `columns_from_text` is true, this call treats inferred text-cluster midpoints as ruled boundaries and splits qualifying two-value items across them. Use `assign_items_to_grid` for that branch and reserve `assign_items_to_ruled_grid` for rect-derived columns.</comment>
<file context>
@@ -1531,7 +1531,7 @@ fn try_build_grid(
// Build table: assign text items to cells
- let (mut cells, item_indices) = assign_items_to_grid(items, &col_edges, &row_edges, page);
+ let (mut cells, item_indices) = assign_items_to_ruled_grid(items, &col_edges, &row_edges, page);
// Consolidate vertically-merged cells: rects spanning multiple grid rows
</file context>
| let (mut cells, item_indices) = assign_items_to_ruled_grid(items, &col_edges, &row_edges, page); | |
| let (mut cells, item_indices) = if columns_from_text { | |
| assign_items_to_grid(items, &col_edges, &row_edges, page) | |
| } else { | |
| assign_items_to_ruled_grid(items, &col_edges, &row_edges, page) | |
| }; |
Summary
Fixes #419.
Validation on the attached customs PDFs
Before:
After:
Tests
cargo testcargo clippy -- -D warnings— passescargo fmt --all -- --check— passesgit diff --check— passesSummary by cubic
Keep adjacent numeric table columns separate and split two-value financial items only when they cross a ruled column boundary. Preserves header-to-data merging and inferred-grid behavior. Fixes #419.
Textitems with positive font size; keep the heuristic splitter unchanged (requires 3+ values). Preserve slot alignment (heuristic: centered; ruled: slot start), and fall back to the original item if any split fragment cannot be placed.assign_items_to_ruled_gridfor ruled tables; inferred grids continue to useassign_items_to_gridso two-value items stay intact. Deduplicate item indices and ignore zero-width items.Written for commit 4d90870. Summary will update on new commits.