From 1b7e095176bbfd1032c68a5e5f280dfc19703f48 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Tue, 14 Apr 2026 17:00:28 +0200 Subject: [PATCH] StepAnsicht: fix row filtering for partial-width boxes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content rows were incorrectly filtered out when their Y overlapped with a box, even if the box only covered the right half of the page. Now checks both Y AND X overlap — rows are only excluded if they start within the box's horizontal range. Fixes: rows next to Box 2 (lend, coconut, taste) were missing from reconstruction because Box 2 (x=871, w=525) only covers the right side, but left-side content rows at x≈148 were being filtered. Co-Authored-By: Claude Opus 4.6 (1M context) --- admin-lehrer/components/ocr-kombi/StepAnsicht.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/admin-lehrer/components/ocr-kombi/StepAnsicht.tsx b/admin-lehrer/components/ocr-kombi/StepAnsicht.tsx index becd9d3..841a4e1 100644 --- a/admin-lehrer/components/ocr-kombi/StepAnsicht.tsx +++ b/admin-lehrer/components/ocr-kombi/StepAnsicht.tsx @@ -110,8 +110,19 @@ export function StepAnsicht({ sessionId, onNext }: StepAnsichtProps) { boxIdx++ } - // Skip rows that fall inside a box boundary - const insideBox = boxBounds.some((bb) => ry >= bb.yStart && ry <= bb.yEnd) + // Skip rows only if they fall FULLY inside a box (both Y and X overlap). + // Small boxes (e.g. on the right half) don't cover left-side content rows. + const rowCells = contentZone!.cells.filter((c) => c.row_index === row.index) + const rowXMin = rowCells.length > 0 + ? Math.min(...rowCells.map((c) => c.bbox_px?.x ?? contentZone!.bbox_px.x)) + : contentZone!.bbox_px.x + const insideBox = boxBounds.some((bb) => { + if (ry < bb.yStart || ry > bb.yEnd) return false + // Check horizontal overlap: row must be mostly inside box x-range + const boxXMin = bb.zone.bbox_px.x + const boxXMax = boxXMin + bb.zone.bbox_px.w + return rowXMin >= boxXMin - 20 && rowXMin <= boxXMax + }) if (!insideBox) { currentRows.push(row) }