Source formats
G2Lex adapters are intentionally strict and preserve source-specific semantics. All formats produce the same typed lexicon model, but they do not flatten features that their source format represents differently.
Format |
Accepted input |
Important behavior |
|---|---|---|
|
JSON object mapping words to values |
Typed values and deterministic key ordering are preserved. |
|
One JSON record per line |
Records are decoded independently; malformed records are rejected. |
|
Word and pronunciation columns |
Empty required fields, malformed columns, and unsupported typed shapes are rejected. |
|
Word and slash-delimited IPA columns |
One optional outer slash pair is removed; internal slashes are preserved. |
|
CMUdict word plus phonemes |
Numbered variants such as |
|
Plain MFA dictionary rows |
Weighted or extra fields are rejected rather than discarded. |
|
Strict single-language PLS subset |
One grapheme per lexeme, one alphabet, phoneme values, and optional role. |
|
Gruut SQLite pronunciation table |
Required schema and fields are validated; rows retain deterministic ordering. |
|
Kokoro JSON source |
Legacy consumer shape is handled by the compatibility adapter. |
|
One word per line |
Blank lines and comments follow the word-list adapter contract. |
Duplicate words are handled by each adapter’s documented source rules. Variant order is meaningful and is retained. Tags and selectors are represented as typed values rather than embedded in pronunciation strings.
For the plain two-column tsv adapter, every spelling is represented as a tuple
at the exact-value layer, including a spelling with only one physical row. For
example, one Haus row becomes ("pronunciation",), while repeated rows keep
their source order. Use lookup_all() or lookup() when a consumer needs a
pronunciation tuple or the first pronunciation instead of the exact typed value.
Use the format name with g2lex pack:
g2lex pack cmudict.dict cmudict.g2lex --format cmudict
g2lex pack source.mfa dictionary.g2lex --format mfa
g2lex pack source.pls dictionary.g2lex --format pls
g2lex pack lexicon.sqlite dictionary.g2lex --format gruut-sqlite
g2lex pack source.json dictionary.g2lex --format json-map
g2lex pack source-ipa.tsv dictionary.g2lex --format ipa-tsv
Invalid UTF-8, missing required fields, and unsupported source shapes fail with a contextual adapter error. Source metadata such as format, size, and digest is recorded when available.