| Metadata | Value |
|---|---|
| Status | Completed |
| Version | 1.0.0 |
| Last Updated | 2026-03-20 |
| Author | Sangeetha Grantha Team |
ID: TRACK-102 Status: Not Started Owner: Sangita Grantha Architect Created: 2026-03-20 Updated: 2026-03-20 Parent: TRACK-093 (Trinity Krithi Import)
Add support for Dikshitar blog’s compound language header format "English - Word Division", "Devanagari - Word Division", etc. The parser currently detects "English" as a language header and treats the "Word Division" portion ambiguously, potentially misclassifying content blocks.
database/for_import/EXTRACTION-INVESTIGATION-REPORT.mdtools/krithi-extract-enrich-worker/src/structure_parser.py_detect_language_header() (line 388) checks lowered.startswith(f"{key} -"). For "english - word division", it matches "english" with key "english" and the remainder becomes "word division". The block is labeled ENGLISH but is actually a word-division variant. The WORD_DIVISION semantic is lost."English - Word Division" should be recognized as a word-division block for the English script, labeled distinctly (e.g., ENGLISH_WORD_DIVISION or tagged as word-division type) so the dual-format merge logic can correctly deduplicate continuous vs word-division versions._detect_language_header() (line 388-393): iterates LANGUAGE_HEADER_CANDIDATES"english - word division":
("english", "ENGLISH") via lowered.startswith(f"{key} -") → True_HeaderMatch(label="ENGLISH", remainder="word division")remainder “word division” is discarded as unlabeled text within the ENGLISH block_extract_language_header_variants() treats this as a regular ENGLISH language block_merge_dual_format() method (line 571) handles deduplication but only within the same variant — it can’t distinguish “English continuous” from “English word division” since both are labeled ENGLISHAdd compound entries to LANGUAGE_HEADER_CANDIDATES that match before the simple entries. Order matters since the method returns on first match:
# Add BEFORE the simple "english" entry:
("english - word division", "ENGLISH_WORD_DIVISION"),
("devanagari - word division", "DEVANAGARI_WORD_DIVISION"),
("tamil - word division", "TAMIL_WORD_DIVISION"),
("telugu - word division", "TELUGU_WORD_DIVISION"),
("kannada - word division", "KANNADA_WORD_DIVISION"),
("malayalam - word division", "MALAYALAM_WORD_DIVISION"),
Then add these compound labels to METADATA_LABELS so they’re treated as non-lyric content (word divisions are supplementary to the continuous form and should be used for merge/dedup only).
"script - word division" entries to LANGUAGE_HEADER_CANDIDATES — placed before simple script entries so they match firstLANGUAGE_LABELS setMETADATA_LABELS (skip entirely) or keep as language blocks for dual-format merging_extract_language_header_variants() to pair each word-division block with its continuous counterpart_merge_dual_format() logic to deduplicate, keeping the word-division version (has explicit word boundaries useful for display)"English - Word Division" detected as compound header, not plain ENGLISH"Devanagari - Word Division" similarly handledOption A — Treat as METADATA_LABELS (skip): Word-division blocks are redundant with continuous blocks. Simplest approach — just skip them. Risk: loses the explicit word boundary information.
Option B — Pair and merge (recommended): Keep word-division blocks as language variants, then use _merge_dual_format() to pick the better version (word-division, which has cleaner spacing). This preserves maximum information and aligns with the existing merge logic.
"English - Word Division" is not confused with a plain "English" language blocktools/krithi-extract-enrich-worker/src/structure_parser.py — LANGUAGE_HEADER_CANDIDATES, LANGUAGE_LABELS, possibly _extract_language_header_variants()tools/krithi-extract-enrich-worker/tests/test_structure_parser.py — add compound header test cases