anthropics / anthropics/skills
check_bounding_boxes.py performs unnecessary comparisons for multi-page forms
- Ngôn ngữ chính
- Python
- Star
- 176k
- Fork
- 20.8k
- Merge trung bình
- 7 giờ 21 phút
- Pull request đã merge (30 ngày)
- 5
Mô tả
## 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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.