Skip to content

Import PT9 interlinearizations end-to-end (parser → InterlinearProject) #150

Description

@imnasnainaec

Umbrella for the goal raised in #94: fully support importing PT9 interlinearizations into an InterlinearProject. The XML parser exists but is wired into nothing — this issue is the end-to-end pipeline from PT9 data to a working, editable project.

Companions: #148 (model-text suggestion source, incl. the major-language model PT9 glosses against) and #149 (output project). This issue consumes both — it discovers a PT9 project's model/output relationships and attaches them to the imported project.

Design principles this follows

Current state

  • src/parsers/pt9/interlinearXmlParser.tsInterlinearXmlParser.parse(xml)InterlinearData (ScrTextName, GlossLanguage, BookId, Verses: verse key → VerseData of Clusters + Punctuations). Schema in pt9-xml.md; one sample in test-data/Interlinear_en_MAT.xml.
  • Not wired into anything — no import command, no cluster→analysis mapping, no gloss-text resolution, no UI. grep confirms the parser and its types are referenced only by their own tests.

Scope — the pipeline

  1. Import command + UI. An interlinearizer.importPt9 command and an entry point (file/folder picker for Interlinear_<lang>_<book>.xml, or selection of a PT9 project). Creates an InterlinearProject via projectStorage / interlinearizer.createProject.
  2. Cluster → Token mapping (the crux). PT9 Cluster.Range is an Index/Length span in the verse text; our tokens carry charStart/charEnd within Segment.baselineText from bookTokenizer. Reconcile the two so each cluster resolves to the token(s) it covers. A single-lexeme cluster over one token → a TokenAnalysis; a cluster spanning multiple tokens → a PhraseAnalysis; a multi-lexeme cluster → a morpheme breakdown (TokenAnalysis.morphemes).
  3. Gloss-text resolution (the big unknown). The XML stores only Lexeme.Id + GlossId/SenseIdnot gloss text. Resolving to a displayable gloss needs a lexicon. Options: resolve to TokenAnalysis.glossSenseRef (a SenseRef into the Lexicon extension, resolved lazily — the model already supports this) and/or resolve to literal gloss text at import time from PT9's lexicon files. Decide the strategy (see Open questions).
  4. Punctuation / Excluded / Hash. Punctuation tokens come from the tokenizer already; PT9 Punctuation change records are likely informational. Excluded clusters map to a suppressed/location-specific state. Verse Hash present ⇒ approved: map to status: 'approved' (+ confidence), absent ⇒ suggested.
  5. Keys & offsets. Verse key ("MAT 1:1") → Segment.id; cluster ranges → token offsets (step 2). Non-matching ranges (baseline drift) → stale handling.
  6. Multi-file merge. One file per book per gloss language (Interlinear_<lang>_<book>.xml). Merge across books and languages into one project whose analysisLanguages union the GlossLanguages.
  7. Link model & output. Attach the discovered major-language model project (Wire a model-text suggestion source into the suggestion engine #148) and any output project (Wire the output project (back-translation / adaptation) into export, not creation #149) to the imported project.

Dependencies

Out of scope

Open questions

  • Gloss resolution: import to glossSenseRef (lazy Lexicon resolution) vs. literal gloss text (from PT9 lexicon files) vs. both? What is the source of gloss text when the Lexicon extension lacks the entry?
  • Where PT9 data comes from: a mounted PT9 project directory, individual XML files, or a PAPI-exposed PT9 project? This decides the import UI and how ScrTextName maps to a Platform.Bible sourceProjectId.
  • Discovering model/output projects: PT9 stores the model text and BT/daughter project in project settings, not the interlinear XML. How do we read that config to populate Wire a model-text suggestion source into the suggestion engine #148/Wire the output project (back-translation / adaptation) into export, not creation #149 linkage on import?
  • Should this go to user-questions.md for review outside the dev team? (per AGENTS.md UX-decisions guidance)

Size: L (multi-stage pipeline; the cluster↔token mapping and gloss resolution are each substantial).
Priority: P1 — this is the concrete goal ("fully support importing PT9 interlinearizations"); #148/#149 are its enabling pieces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions