Add parsers for the remaining PT9 interlinear files - #238
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
adba5df to
8cfc530
Compare
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>
8cfc530 to
25bc4dd
Compare
imnasnainaec
left a comment
There was a problem hiding this comment.
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.)
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:
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