Add reading_flow: column-aware reading order via XY-cut#386
Merged
Conversation
element_parse.reading_order is a flat top-to-bottom sort that interleaves columns on multi-column pages (A1, B1, A2, B2). Recover the correct order with recursive XY-cut: split at the widest whitespace valley (vertical -> columns, horizontal -> rows), so a two-column page reads A1, A2, B1, B2. flow_order returns the same index-tagged contract as reading_order (a drop-in column-aware upgrade, named to not shadow it).
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 53 |
| 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.



摘要
新增
flow_order/xy_cut/to_blocks— 以遞迴 XY-cut 還原多欄版面的正確閱讀順序。element_parse.reading_order是平面上到下 / 左到右排序,在多欄頁面會交錯欄位(讀 A 欄第 1 列、B 欄第 1 列、A 欄第 2 列…)。本功能在最寬留白谷反覆切分(垂直 gutter → 欄、水平 gutter → 列 / 區塊),因此兩欄版面完整讀完 A 欄再讀 B 欄。公開展平函式命名為
flow_order以並列而非遮蔽element_parse.reading_order,並回傳相同的index標記契約(欄位感知的直接升級)。純標準函式庫幾何;重用table_grid_fill的框邊界讀取器。Qt-free。五層
utils/reading_flow/—xy_cut、flow_order、to_blocks。AC_flow_order+AC_xy_cut/ MCPac_flow_order+ac_xy_cut/ Script Builder(OCR)。測試
test_reading_flow_batch.py— 兩欄欄位感知順序 A1,A2,B1,B2、頂層 X 切分、單欄上到下、to_blocks 葉數、index 指派、空輸入、wiring + facade。8 passed。ruff / bandit / radon / float-scan / Qt-free 全乾淨。