Add form_fields: multi-direction label/value association + checkbox state#378
Merged
Conversation
…tate ocr/structure only pairs a label: with the immediately next cell, so it can't handle label-above-value, two-column key/value, right-aligned values or non-text widgets, and has no checkbox notion. Pair each label with the nearest aligned value across directions (right/below) within max_gap, match free-standing widgets to their nearest label, and read checkbox state from the box's dark-pixel fill ratio.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 46 |
| 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.



摘要
新增
associate_fields/match_labels_to_widgets/checkbox_state— 將表單標籤與值關聯,並讀取核取方塊狀態。ocr/structure只在標籤以:結尾時才辨識,且只與緊接的下一格配對——無法處理標籤在值上方、雙欄 key/value、右對齊值或非文字 widget,且完全沒有核取方塊 / 單選鈕狀態概念。本功能將其一般化:把每個標籤與多方向(右、下)中最近的對齊值配對(
max_gap內),把獨立 widget(核取方塊 / 單選鈕 / 輸入框)依中心距離配到最近標籤,並由框內暗像素填充比例讀取核取方塊狀態。關聯部分純標準函式庫(可完整無頭測試);只有checkbox_state觸及像素,隔離在visual_match灰階載入器之後。重用table_grid_fill的框邊界讀取器。Qt-free。五層
utils/form_fields/—associate_fields、match_labels_to_widgets、checkbox_state。je_auto_control匯出 +__all__。AC_associate_fields({count, fields})/AC_match_labels_to_widgets({count, pairs})。ac_associate_fields/ac_match_labels_to_widgets(read-only)。測試
test/unit_test/headless/test_form_fields_batch.py— 右側值、下方值、最近值優先、超出 max_gap 不配、widget→最近標籤、核取方塊填充判定 checked/unchecked、wiring + facade。8 passed。ruff / bandit / radon / float-scan / Qt-free 全乾淨。