diff --git a/admin-lehrer/components/ocr-pipeline/StepWordRecognition.tsx b/admin-lehrer/components/ocr-pipeline/StepWordRecognition.tsx index d213074..e74d655 100644 --- a/admin-lehrer/components/ocr-pipeline/StepWordRecognition.tsx +++ b/admin-lehrer/components/ocr-pipeline/StepWordRecognition.tsx @@ -63,6 +63,7 @@ export function StepWordRecognition({ sessionId, onNext, goToStep, skipHealGaps const [ocrEngine, setOcrEngine] = useState<'auto' | 'tesseract' | 'rapid'>('auto') const [usedEngine, setUsedEngine] = useState('') const [pronunciation, setPronunciation] = useState<'british' | 'american'>('british') + const [gridMethod, setGridMethod] = useState<'v2' | 'words_first'>('v2') // Streaming progress state const [streamProgress, setStreamProgress] = useState<{ current: number; total: number } | null>(null) @@ -112,7 +113,7 @@ export function StepWordRecognition({ sessionId, onNext, goToStep, skipHealGaps let res: Response | null = null for (let attempt = 0; attempt < 2; attempt++) { res = await fetch( - `${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${sessionId}/words?stream=true&engine=${eng}&pronunciation=${pronunciation}${skipHealGaps ? '&skip_heal_gaps=true' : ''}`, + `${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${sessionId}/words?stream=${gridMethod === 'v2' ? 'true' : 'false'}&engine=${eng}&pronunciation=${pronunciation}${skipHealGaps ? '&skip_heal_gaps=true' : ''}&grid_method=${gridMethod}`, { method: 'POST' }, ) if (res.ok) break @@ -128,6 +129,13 @@ export function StepWordRecognition({ sessionId, onNext, goToStep, skipHealGaps throw new Error(err.detail || 'Worterkennung fehlgeschlagen') } + // words_first returns plain JSON (no streaming) + if (gridMethod === 'words_first') { + const data = await res.json() as GridResult + applyGridResult(data) + return + } + const reader = res.body!.getReader() const decoder = new TextDecoder() let buffer = '' @@ -220,7 +228,7 @@ export function StepWordRecognition({ sessionId, onNext, goToStep, skipHealGaps setDetecting(false) } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [sessionId, ocrEngine, pronunciation]) + }, [sessionId, ocrEngine, pronunciation, gridMethod]) const handleGroundTruth = useCallback(async (isCorrect: boolean) => { if (!sessionId) return @@ -789,6 +797,16 @@ export function StepWordRecognition({ sessionId, onNext, goToStep, skipHealGaps {gridResult && (
+ {/* Grid method selector */} + + {/* OCR Engine selector */}