Dictionaries
Gukhanmun uses dictionaries to look up the hangul readings of hanja. The
ko-kr preset uses the bundled Loanword spelling examples and Standard
Korean Dictionary (標準國語大辭典), and the ko-kp preset uses the bundled
Open Korean Dictionary (우리말샘) North Korean category.
Bundled dictionaries
The bundled dictionary selected by the preset is loaded automatically. No extra flags are needed for most Korean text.
To disable every bundled dictionary, for example when you want to rely entirely
on a custom dictionary, pass --no-bundled-dictionaries:
Use the ko-kp preset for North Korean orthography. It disables the initial
sound law and uses the bundled Open Korean Dictionary (우리말샘) North Korean
(北韓語) dictionary:
Loanword spelling examples
The ko-kr preset includes the National Institute of Korean Language's
Loanword spelling examples dictionary by default. It supplies Korean
spellings of foreign names written in hanja, such as 香港 → 홍콩:
Use --no-loanwords to disable only loanword examples while keeping the
preset's other dictionaries. The ko-kp preset leaves loanword examples off;
pass --loanwords to enable them explicitly. Custom dictionaries take priority,
followed by loanword examples, then the preset's other dictionaries.
--loanwords cannot be combined with --no-bundled-dictionaries.
Custom dictionaries
Supply one or more custom dictionaries with -d (or --dictionary). The
flag can be repeated:
Gukhanmun supports two binary dictionary formats:
Later -d arguments take priority over earlier ones and over every bundled
dictionary for matches of the same text and length. With
--segmentation lattice (the default), overlapping matches of different
lengths are compared by dictionary coverage, so a longer bundled match can beat
a shorter user match.
Building a custom dictionary
The .gukfst and .gukcdb files are compiled artifacts, not something you
edit by hand. You author your entries as a plain text table and compile them
with gukhanmun-mkdict.
The gukhanmun-mkdict builder is installed together with gukhanmun, whether
you install via mise or
download a prebuilt archive. If you instead
built from crates.io, install the builder the same way:
Write your entries as a tab-separated file with a hanja key column and a
hangul reading column:
Two optional columns control how renderers treat each entry: set
require_hanja to true to keep the source hanja visible (for homophones that
need disambiguation), and require_hangul to true to force a hangul gloss in
the original-script rendering mode.
Compile the table into an FST dictionary (the default format):
Pass --format cdb to produce a .gukcdb file instead. You can supply
several input files, which are merged in order; --merge selects how duplicate
keys are resolved (error, first-wins, or last-wins). Add --validate to
reopen the output and confirm every entry round-trips, and --metadata KEY=VAL
to embed provenance such as the source or license.
Then load the result like any other custom dictionary:
CSV and JSON Lines inputs are also accepted, and a few more advanced options are available. See the internals section for the full dictionary file format specification.