Skip to content

Add parsers for the remaining PT9 interlinear files - #238

Open
jasonleenaylor wants to merge 1 commit into
pt9-lossless-parser-modelfrom
pt9-import
Open

Add parsers for the remaining PT9 interlinear files#238
jasonleenaylor wants to merge 1 commit into
pt9-lossless-parser-modelfrom
pt9-import

Conversation

@jasonleenaylor

@jasonleenaylor jasonleenaylor commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Parse Lexicon.xml, WordAnalyses.xml, and InterlinearSetup.xml into models that mirror the file shapes alongside the existing interlinear parser, as the first slice of the PT9 import pipeline:

  • lexemeKey.ts holds the shared LexemeKeyData shape and pure helpers (parse/compose/equality) for PT9's Type:Form[:Homograph] id grammar, with homograph 1 omitted from composed ids and unknown type names preserved.
  • lexiconXmlParser.ts parses entries (senses, per-language glosses) and the legacy Analyses section (wordform -> ordered lexeme keys, as a record matching how the interlinear parser represents Verses).
  • wordAnalysesXmlParser.ts parses the wordform-to-parse inventory, keeping lexeme ids as raw composed strings.
  • interlinearSetupXmlParser.ts parses per-language configuration fully leniently: every field optional, unknown type names kept as raw strings.

All parsers are identity-strict and otherwise preserve optional data as written: they throw only on a missing root, duplicate dictionary keys, or entries missing their identity; absent attributes and elements stay absent.

Grow pt9-xml.md into the four-file format reference with a shared conventions section, and add coherent test-data fixtures whose sense ids and lexeme keys resolve against Interlinear_en_MAT.xml.

🤖 Generated with Claude Code


This change is Reviewable

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a507599-189c-4ed6-8623-2c55d6947a31

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Parse Lexicon.xml, WordAnalyses.xml, and InterlinearSetup.xml into
models that mirror the file shapes alongside the existing interlinear
parser, as the first slice of the PT9 import pipeline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@imnasnainaec imnasnainaec left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a handful of minor readability/coverage things.

@imnasnainaec reviewed 5 files and all commit messages, and made 7 comments.
Reviewable status: 5 of 12 files reviewed, 6 unresolved discussions (waiting on jasonleenaylor).


src/__tests__/parsers/pt9/lexiconXmlParser.test.ts line 436 at r2 (raw file):
This throw test highlights a valid example missing from the first section of tests:

one side write Homograph="2" and the other omits it


src/parsers/pt9/interlinearSetupXmlParser.ts line 28 at r2 (raw file):

  /** Hex id of the model text, kept as the raw string. */
  MdlScrTextId?: string;
  MdlIsResource?: boolean;

❓ What sort of resource does MdlIsResource refer to?


src/parsers/pt9/interlinearSetupXmlParser.ts line 41 at r2 (raw file):

}

/** InterlinearSetup: type/language attributes plus text elements; empty parses as a bare string. */

I didn't see test coverage for "empty parses as bare string.


src/parsers/pt9/lexiconXmlParser.ts line 119 at r2 (raw file):

  const form = element['@_Form'];
  if (!type || form === undefined) {
    throw new SyntaxError('Invalid XML: Lexeme key missing Type or Form attribute');

❓ Why one common error for missing Type and/or Form?


src/parsers/pt9/pt9-xml.md line 159 at r2 (raw file):

- **Analyses**
  - **Children:** Zero or more `item` elements.
    - **`string`** (element text): Surface wordform. Required and non-empty; a missing or empty key causes a parse error, and duplicate wordforms cause a parse error.

⛏️ The "Required and non-empty" is information that elsewhere is more upfront, e.g. "(required, non-empty)", on other lines in these doc structures.


src/parsers/pt9/pt9-xml.md line 178 at r2 (raw file):

### Parsed output (in-memory)

Types exported from `src/parsers/pt9/lexiconXmlParser.ts`: **LexiconData** (`Language?`, `FontName?`, `FontSize?` as raw strings, `Entries`, `Analyses` as a record of wordform → `LexemeKeyData[]`, mirroring how string-keyed PT9 dictionaries parse elsewhere), **LexiconEntryData** (`Key` as a `LexemeKeyData`, `Senses`), **LexiconSenseData** (`Id?`, `Glosses`), **LexiconGlossData** (`Language?`, `Text`). `Entries` stays an array of key-carrying objects because its key is the non-string `LexemeKey`.

This would be more readable as a bulleted list. (Same for other "Parsed output" sections.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants