Skip to content

Add form_fields: multi-direction label/value association + checkbox state#378

Merged
JE-Chen merged 1 commit into
devfrom
feat/form-fields-batch
Jun 23, 2026
Merged

Add form_fields: multi-direction label/value association + checkbox state#378
JE-Chen merged 1 commit into
devfrom
feat/form-fields-batch

Conversation

@JE-Chen

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

Copy link
Copy Markdown
Member

摘要

新增 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_fieldsmatch_labels_to_widgetscheckbox_state
  • Facade:由 je_auto_control 匯出 + __all__
  • Executor:AC_associate_fields({count, fields})/ AC_match_labels_to_widgets({count, pairs})。
  • MCP:ac_associate_fields / ac_match_labels_to_widgets(read-only)。
  • Script Builder:Associate Form Fields / Match Labels To Widgets(OCR)。
  • 文件:v166 EN + Zh + toctree。更新日誌:root EN + zh-TW + zh-CN。

測試

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 全乾淨。

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

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 46 complexity · 0 duplication

Metric Results
Complexity 46
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 bfed3bc into dev Jun 23, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/form-fields-batch branch June 23, 2026 19:57
@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