backend-lehrer (10 files): - game/database.py (785 → 5), correction_api.py (683 → 4) - classroom_engine/antizipation.py (676 → 5) - llm_gateway schools/edu_search already done in prior batch klausur-service (12 files): - orientation_crop_api.py (694 → 5), pdf_export.py (677 → 4) - zeugnis_crawler.py (676 → 5), grid_editor_api.py (671 → 5) - eh_templates.py (658 → 5), mail/api.py (651 → 5) - qdrant_service.py (638 → 5), training_api.py (625 → 4) website (6 pages): - middleware (696 → 8), mail (733 → 6), consent (628 → 8) - compliance/risks (622 → 5), export (502 → 5), brandbook (629 → 7) studio-v2 (3 components): - B2BMigrationWizard (848 → 3), CleanupPanel (765 → 2) - dashboard-experimental (739 → 2) admin-lehrer (4 files): - uebersetzungen (769 → 4), manager (670 → 2) - ChunkBrowserQA (675 → 6), dsfa/page (674 → 5) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
/**
|
|
* Helper functions for ChunkBrowserQA component.
|
|
*/
|
|
|
|
import { REGULATION_INFO } from '../rag-constants'
|
|
|
|
/** Get text content from a chunk */
|
|
export function getChunkText(chunk: Record<string, unknown> | null): string {
|
|
if (!chunk) return ''
|
|
return String(chunk.chunk_text || chunk.text || chunk.content || '')
|
|
}
|
|
|
|
/** Extract structural metadata for prominent display */
|
|
export function getStructuralInfo(
|
|
chunk: Record<string, unknown> | null
|
|
): { article?: string; section?: string; pages?: string } {
|
|
if (!chunk) return {}
|
|
const result: { article?: string; section?: string; pages?: string } = {}
|
|
// Article / paragraph
|
|
const article = chunk.article || chunk.artikel || chunk.paragraph || chunk.section_title
|
|
if (article) result.article = String(article)
|
|
// Section
|
|
const section = chunk.section || chunk.chapter || chunk.abschnitt || chunk.kapitel
|
|
if (section) result.section = String(section)
|
|
// Pages
|
|
const pages = chunk.pages as number[] | undefined
|
|
if (Array.isArray(pages) && pages.length > 0) {
|
|
result.pages = pages.length === 1 ? `S. ${pages[0]}` : `S. ${pages[0]}-${pages[pages.length - 1]}`
|
|
} else if (chunk.page) {
|
|
result.pages = `S. ${chunk.page}`
|
|
}
|
|
return result
|
|
}
|
|
|
|
/** Regulation name lookup */
|
|
export function getRegName(code: string): string {
|
|
const reg = REGULATION_INFO.find(r => r.code === code)
|
|
return reg?.name || code
|
|
}
|