anthropics / anthropics/skills

check_bounding_boxes.py performs unnecessary comparisons for multi-page forms

Open
#259 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
176k
Forks
20.9k
Avg merge
7h 21m
Merged PRs (30d)
5

Description

## 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.