Files
breakpilot-lehrer/studio-v2/app/vocab-worksheet/constants.ts
Benjamin Admin 909d0729f6
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 45s
CI / test-go-edu-search (push) Successful in 43s
CI / test-python-klausur (push) Failing after 2m51s
CI / test-python-agent-core (push) Successful in 36s
CI / test-nodejs-website (push) Successful in 37s
Add SmartSpellChecker + refactor vocab-worksheet page.tsx
SmartSpellChecker (klausur-service):
- Language-aware OCR post-correction without LLMs
- Dual-dictionary heuristic for EN/DE language detection
- Context-based a/I disambiguation via bigram lookup
- Multi-digit substitution (sch00l→school)
- Cross-language guard (don't false-correct DE words in EN column)
- Umlaut correction (Schuler→Schüler, uber→über)
- Integrated into spell_review_entries_sync() pipeline
- 31 tests, 9ms/100 corrections

Vocab-worksheet refactoring (studio-v2):
- Split 2337-line page.tsx into 14 files
- Custom hook useVocabWorksheet.ts (all state + logic)
- 9 components in components/ directory
- types.ts, constants.ts for shared definitions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 12:25:01 +02:00

57 lines
2.1 KiB
TypeScript

import type { OcrPrompts, WorksheetFormat, WorksheetType } from './types'
// API Base URL - dynamisch basierend auf Browser-Host
// Verwendet /klausur-api/ Proxy um Zertifikat-Probleme zu vermeiden
export const getApiBase = () => {
if (typeof window === 'undefined') return 'http://localhost:8086'
const { hostname, protocol } = window.location
if (hostname === 'localhost') return 'http://localhost:8086'
return `${protocol}//${hostname}/klausur-api`
}
// LocalStorage Keys
export const DOCUMENTS_KEY = 'bp_documents'
export const OCR_PROMPTS_KEY = 'bp_ocr_prompts'
export const SESSION_ID_KEY = 'bp_upload_session'
// Worksheet format templates
export const worksheetFormats: { id: WorksheetFormat; label: string; description: string; icon: string }[] = [
{
id: 'standard',
label: 'Standard-Format',
description: 'Klassisches Arbeitsblatt mit waehlbarer Uebersetzungsrichtung',
icon: 'document'
},
{
id: 'nru',
label: 'NRU-Vorlage',
description: '3-Spalten-Tabelle (EN|DE|Korrektur) + Lernsaetze mit Uebersetzungszeilen',
icon: 'template'
},
]
// Default OCR filtering prompts
export const defaultOcrPrompts: OcrPrompts = {
filterHeaders: true,
filterFooters: true,
filterPageNumbers: true,
customFilter: '',
headerPatterns: ['Unit', 'Chapter', 'Lesson', 'Kapitel', 'Lektion'],
footerPatterns: ['zweihundert', 'dreihundert', 'vierhundert', 'Page', 'Seite']
}
export const worksheetTypes: { id: WorksheetType; label: string; description: string }[] = [
{ id: 'en_to_de', label: 'Englisch → Deutsch', description: 'Englische Woerter uebersetzen' },
{ id: 'de_to_en', label: 'Deutsch → Englisch', description: 'Deutsche Woerter uebersetzen' },
{ id: 'copy', label: 'Abschreibuebung', description: 'Woerter mehrfach schreiben' },
{ id: 'gap_fill', label: 'Lueckensaetze', description: 'Saetze mit Luecken ausfuellen' },
]
export const formatFileSize = (bytes: number): string => {
if (bytes === 0) return '0 B'
const k = 1024
const sizes = ['B', 'KB', 'MB', 'GB']
const i = Math.floor(Math.log(bytes) / Math.log(k))
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i]
}