Add heading_segment: heading vs body classification + document outline#390
Merged
Conversation
Nothing mapped line height to heading levels or built a section outline; ocr/structure and element_parse are positional and text_blocks doesn't rank. Apply the standard heuristic: a line taller than heading_ratio x the median line height is a heading, and distinct heading heights become levels (tallest = 1). classify_lines tags each line; outline returns the headings in order.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 31 |
| 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.



摘要
新增
classify_lines/outline— 以 box 高度區分標題與內文並建立文件大綱。框架中沒有功能把行高對應到標題層級或建立章節大綱(ocr/structure/element_parse純屬位置性,text_blocks不排序)。本功能套用標準啟發法:行高超過
heading_ratio× 中位行高者為標題,不同的標題高度成為層級(最高 = 1)。classify_lines為每行標記{box, text, role, level};outline依上到下順序回傳標題作為目錄。純標準函式庫,作用於純行字典;重用table_grid_fill的框邊界讀取器。Qt-free。五層
utils/heading_segment/—classify_lines、outline。AC_classify_lines+AC_outline/ MCPac_classify_lines+ac_outline/ Script Builder(OCR)。測試
test_heading_segment_batch.py— 標題/內文標記與層級、純內文無標題、outline 依序、空輸入、wiring + facade。6 passed。ruff / bandit / radon / float-scan / Qt-free 全乾淨。