anthropics / anthropics/skills

check_bounding_boxes.py performs unnecessary comparisons for multi-page forms

未关闭
#259 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
176k
派生
20.9k
平均合并
7 小时 21 分钟
30 天内合并 PR
5

描述

## Problem

The `check_bounding_boxes.py` script validates that bounding boxes in PDF forms don't overlap. Currently, it uses O(N²) nested loops to check all pairs of bounding boxes, even when boxes are on different pages.

**The Issue:**
- Bounding boxes on different pages can never overlap (they're on separate pages)
- The current implementation still compares boxes across different pages
- This results in many unnecessary comparisons for multi-page forms

## Impact

For multi-page forms, the script performs significantly more comparisons than necessary:

**Example with 100 fields across 10 pages:**
- Total bounding boxes: 200 (2 per field: label + entry)
- Current comparisons: 19,900 (checking all pairs)
- Necessary comparisons: ~1,900 (only boxes on same page)
- **Waste: ~18,000 unnecessary comparisons (90% waste)**

**Real-world impact:**
- Large multi-page forms (tax forms, medical intake forms, etc.) experience slower validation
- The performance degrades quadratically as the number of fields increases
- For forms with 500+ fields across multiple pages, validation can take several seconds

## Current Behavior

The script currently:
1. Creates a flat list of all bounding boxes from all pages
2. Compares every box with every other box
3. Only filters by page number inside the comparison loop (still does the comparison check)

This means boxes on page 1 are still compared against boxes on page 2, 3, etc., even though they can never overlap.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。