In the previous article, I pulled apart what actually lives inside a Japanese dictionary entry. Once I started converting several dictionaries for real, the difficult part quickly moved beyond file parsing. The harder question was deciding which pieces of two very different dictionaries should be represented in the same way, and which differences had to survive the conversion.
JSON, XML, MDX, Yomitan ZIP and EPWING all need parsers. Those format problems are usually temporary. The structure left behind after conversion is what every later application has to live with.
I call this project for turning different dictionaries into consistent data products Unidicts. Each dictionary should end up as its own SQLite database that can be searched and exported independently, while downstream software can rely on the same basic rules across different books.
Decide what is actually worth standardising
Looking only at source files tends to push a project toward one of two extremes.
The first is to preserve each source structure almost literally. If one dictionary has dozens of fields, keep dozens of fields; when another dictionary uses a different structure, build another model for that one. This can look faithful, but every consumer then has to learn every dictionary again.
The other extreme is a large universal schema with a place for every conceivable feature. It looks tidy on paper and quickly starts flattening editorial differences that were valuable in the first place.
The V1 contract ended up much smaller: entries, senses and assets.
- An entry stores the written form, reading and information that belongs to the headword as a whole.
- A sense stores part of speech, definition, examples, glosses and sense-specific information.
- Images, external glyphs (外字(がいじ)), audio and other binary material are stored as assets.
The contract does not attempt to describe every dictionary ever made. It only standardises information whose meaning remains reasonably stable across sources and that lookup software genuinely needs to understand. Material unique to one dictionary can stay in structured extension data at the appropriate level.
That decision matters more than the parser. A broken parser can be rewritten. If the data contract itself discards a class of knowledge, every downstream application inherits the loss.
Written form and reading define an entry together
Entry identity sounds simple until the source format starts making decisions for you.
In Unidicts, an Entry is uniquely identified by form + reading. For example:
- 食べる / たべる
- 喰べる / たべる
The readings match, but the written forms differ, so they remain separate entries. If the source dictionary explicitly groups them as spelling variants, that relationship is preserved as source information without collapsing the two forms into one record.
A source “record” is also not automatically an entry. One source record may contain several written forms and readings and need to expand into multiple entries. Another source may split the same form + reading across several editorial records, which then need to converge on one entry.
JMdict shows why row counts are a poor guide. It contains 275,241 source records and produces 262,137 unique form-reading pairs. JMnedict goes the other way: 666,782 source records expand to 744,428 Entries.
I stopped trusting “rows before versus rows after” as an acceptance test. A correct conversion can legitimately shrink or grow. The useful question is whether the expected identities survived and whether their senses ended up under the right entries.
Senses can be shared structure without making dictionaries identical
A headword usually has more than one meaning. If several definitions are concatenated into one large string, a surprising amount of useful structure disappears immediately: which part of speech belongs to which meaning, which example supports which sense, and where a usage note belongs.
Each Sense therefore keeps its own order, following the source dictionary’s sense boundaries.
Part of speech gets a coarser layer of normalisation. Dictionaries use different label systems, and many mix conjugation type, transitivity and grammatical properties in the same tag set. Downstream software benefits from a stable set of broad categories such as noun, verb, adjective, particle, prefix and suffix. The original source labels remain available in extension data.
I like this boundary because the shared layer stops once it becomes useful. Lookup software gets stable fields, while the original editorial judgement remains visible.
Material such as the 語誌(ごし) and 方言(ほうげん) sections in Nihon Kokugo Daijiten (日本国語大辞典), 書き分け(かきわけ) and 読み分け(よみわけ) guidance in Meikyo (明鏡国語辞典), or illustrations and external glyphs (外字(がいじ)) in Kojien (広辞苑) still belongs to those dictionaries. There is no benefit in deleting it simply because other books do not have matching sections.
An empty field can be harder than a populated one
One of the more instructive conversion problems was a source field literally named reading that was empty.
A simplistic importer can treat that as “no reading”. Real dictionaries often encode the reading elsewhere: in kana attached to the headword, in ruby-like structures, or in another explicit source field. A headword written entirely in kana may also provide the reading directly.
The second edition of Daijisen contains 636,276 source records. Of those, 309,214 initially have an empty reading field. After examining the headword structure and other explicit source information, most readings can still be recovered. 73,240 records remain with no reliable reading anywhere in the source.
Those 73,240 records do not become Entries. Familiar-looking kanji are not enough reason for a converter to invent a pronunciation.
The final accounting is therefore explicit:
636,276 = 563,036 + 73,240 + 0
That is the number of records converted normally, plus records with genuinely missing readings, plus other record-level exclusions. Data that does not enter SQLite still has a clear explanation instead of silently disappearing.
This is one reason dictionary conversion can be deceptive. A crash is easy to notice. A converter that finishes successfully while making a plausible guess on behalf of the source is much more dangerous.
Asset files need their own boundary too
While working through the seventh edition of Kojien, I ran into a small detail that became unexpectedly useful.
The source package contains 7,684 media resource files. Only 7,360 are actually referenced by dictionary entries or senses. The remaining 324 never appear in the dictionary content.
If the goal were simply to move an archive into a database, copying all 7,684 files would be easy. The resulting SQLite would also contain a collection of spare files that have no role in lookup. I kept only resources actually referenced by the dictionary and verified those relationships.
This is also why assets belong in the finished data product. If a dictionary needs to return to its original ZIP whenever an entry references an illustration or gaiji, it is still partly dependent on the source package.
Images and other required resources now live in the same SQLite database in an assets table. Entries and senses store references to those assets. A reader, web dictionary or exporter can work from the finished database alone.
A successful conversion deserves another round of suspicion
Dictionary conversion has an awkward testing problem: the implementer’s verifier can repeat the implementer’s misunderstanding.
If a converter misreads a dictionary’s sense boundaries from the beginning, a verify command based on the same interpretation can still produce a perfect PASS.
Every dictionary therefore goes through an independent review after build and verify. The reviewer returns to the source, conversion rules and final SQLite, checking entry identity, sense order, POS mappings, assets, JSON structure and source coverage. Final acceptance is done outside the implementation context as well.
This is more work than stopping when a script succeeds, but it targets the hardest class of dictionary-data errors: the database is structurally valid, the content looks plausible, and only a fresh comparison with the source reveals that the source was misunderstood.
The final deliverable is pleasantly boring
One dictionary ends up as one SQLite file.
The stable shared structure stays small. Each dictionary keeps the editorial material that makes it distinctive. Source formats can change, parsers can be rewritten, and new exporters can be added later while downstream software continues to depend on the same data contract.
That has also made “reusable” much more concrete for me. A dictionary source should be studied once and turned into a reliable data product. Lookup, vocabulary work, reading software and format-specific exports can then build on that result instead of parsing the original dictionary again.
Different dictionaries can finally be used together without erasing the reasons they were different in the first place.