| Metadata | Value |
|---|---|
| Status | Completed |
| Version | 1.0.0 |
| Last Updated | 2026-03-20 |
| Author | Sangeetha Grantha Team |
ID: TRACK-100 Status: Not Started Owner: Sangita Grantha Architect Created: 2026-03-20 Updated: 2026-03-20 Parent: TRACK-093 (Trinity Krithi Import)
Redesign the StructureParser.parse() method to process content beyond the first metadata boundary, enabling extraction of Devanagari, Tamil, Telugu, Kannada, and Malayalam lyric variants. Currently only the English/IAST variant is extracted because the parser truncates all text at the first metadata boundary (Gist/Meaning/Variations), and all Indic-script lyrics appear after these boundaries on all three Trinity blogs.
database/for_import/EXTRACTION-INVESTIGATION-REPORT.mdtools/krithi-extract-enrich-worker/src/structure_parser.pyparse() at line 299 sets lyric_window_end = effective_boundaries[0].start_pos, truncating all text after the first metadata boundary. On Dikshitar blogs this is variations (~pos 370), on Syama Sastri/Tyagaraja it’s Gist (~pos 229-285). All Indic scripts appear after these positions and are never parsed.parse() (line 274) receives full extracted text_find_metadata_boundaries() (line 862) scans entire text for MEANING, GIST, NOTES, WORD_DIVISION, VARIATIONS patternslyric_window_end = effective_boundaries[0].start_pos if effective_boundaries else len(source_text)
lyric_text = source_text[:lyric_window_end]
_build_blocks() (line 315) only receives lyric_text — the truncated window_extract_sections() and _extract_lyric_variants() therefore only see English/IAST contentEnglish/IAST sections (Pallavi, Anupallavi, Charanam)
─── metadata boundary (Gist/Variations) ─── ← parser stops here
Word-by-word Meaning
Notes/Comments
Devanagari sections
Tamil sections
Telugu sections
Kannada sections
Malayalam sections
The report’s characterization is accurate. The truncation at line 299-300 is the root cause. The _extract_language_header_variants() method (line 665) already has logic to handle language-labeled blocks, but it never sees them because _build_blocks() is fed truncated text.
parse(), scan the entire source_text (not just lyric_text) for language headers using _detect_language_header() to identify top-level language block boundaries{language_label: (start_pos, end_pos)} covering the full document_build_blocks() on the block’s text slice independently_extract_sections() per block to get section structure_sections_from_variant_blocks() logic)parse() to assemble lyric_variants from all language blocks instead of just the truncated window_extract_script_split_variants() pathOption A — Full-document language-block parsing (recommended): Scan the entire document for language headers, parse each block independently. This is cleaner because it treats each language variant as a first-class entity and naturally handles per-script metadata sections.
Option B — Two-phase approach: Extract English skeleton first, then scan remaining document for Indic blocks. This preserves more of the current code path but creates tighter coupling between the two phases.
Recommendation: Option A. The existing _extract_language_header_variants() method already implements most of the per-block logic — it just needs to operate on the full document. The change is primarily in parse() where the text window is constructed, not in the downstream extraction methods.
Risk: Language headers (e.g., “Tamil”, “Devanagari”) might appear within lyric text as words. Mitigation: language headers must be standalone lines (the existing _detect_language_header() already checks for this via lowered == key or lowered.startswith(f"{key}:") patterns).
tools/krithi-extract-enrich-worker/src/structure_parser.py — rewrite parse() to scan full document for language blocks; adjust _build_blocks() call sitestools/krithi-extract-enrich-worker/tests/test_structure_parser.py — add multi-variant test cases for all 3 blog sources