Conversion options
Pass options as keyword arguments to Converter(...). Options are immutable
after construction; create another converter for a different configuration.
Use enum members, such as Preset.KO_KP, rather than raw strings. To read a
string from configuration, convert it explicitly with Preset("ko-kp").
Presets
preset supplies the default initial sound law and homophone window:
Neither preset loads official dictionaries. Install and add them explicitly; see Dictionaries. An explicit option overrides its preset:
converter.options contains the resolved values, including a fully resolved
punctuation profile. It and its nested records are read-only.
Segmentation
segmentation chooses how dictionary matches divide a hanja run into words.
The default Segmentation.LATTICE compares candidate paths with dynamic
programming. Segmentation.EAGER takes the longest match at each position;
it can choose a worse boundary when a long match leaves an unmatched suffix.
Keep the default for general document conversion. Evaluate EAGER against
your own vocabulary before choosing it.
Numerals
numerals controls the conversion of hanja numeral sequences. These examples
use character fallback, without a dictionary:
POSITIONAL_ARABIC handles digit sequences; ADDITIVE_ARABIC handles
quantities with place-value markers such as 十 and 百. SMART combines both
and keeps phonetic readings for sequences that read as words, such as 十長生
in the example.
Initial sound law
initial_sound_law changes certain word-initial fallback readings to South
Korean forms. For example, 來日 reads 내일 when enabled and 래일 when
disabled. Dictionary entries already supply their readings; this setting does
not rewrite them.
Parenthetical reading annotations
With a dictionary entry for 庫間 read as 곳간, the default
collapse_redundant_parens=True recognizes an existing reading annotation in
either order, such as 庫間(곳간) or 곳간(庫間), and renders one annotation
instead of duplicating it. In hangul-only mode the result is 곳간(庫間).
Set the option to False to disable this handling. The same input 庫間(곳간)
then becomes 곳간(곳간): the word converts while the existing parentheses
remain.
A gloss that matches the dictionary reading is accepted, including readings
with a linking ㅅ (사이시옷). An alternative reading must have one hangul
syllable per hanja, with each syllable a valid Sino-Korean reading of that
character. Thus 數字(수자) can select 수자 for that occurrence. Definition
glosses and foreign transliterations that fail these rules stay unchanged.
Homophones
homophone_window sets where two recognized words with the same reading can
cause a distinguishing hanja gloss. With hangul-only rendering:
Each convert() call starts a new document and its own tracking state.
For HTML and Markdown, the windows use these structural scopes:
With InputFormat.TEXT, both PER_BLOCK and PER_SECTION cover the entire
document. Blank lines and heading-like text do not create boundaries. These
format-dependent scopes also apply to first_occurrence_window.
homophone_detection defaults to HomophoneDetection.CONTEXT_LOCAL, which
requires a conflicting word to appear in the window. DICTIONARY_WIDE also
considers other forms with the same reading anywhere in the loaded dictionary.
With a large dictionary this can add many glosses. To always annotate a chosen
form, use a directive instead.
Disambiguation works on recognized dictionary units. A sequence read through character fallback is not automatically a word with a lexical identity. Add a dictionary entry when an entire term needs to take part in homophone detection.
First occurrences
first_occurrence_window clears repeated dictionary-entry require_hanja and
require_hangul requirements within the selected window. Explicit reading
glosses in the input and directives keep their requirements, and homophone
marks remain. Rendering modes that always show both scripts still do so. The
option accepts the same four ContextWindow values and defaults to OFF,
independently of the homophone window.
Punctuation and recovery
Punctuation normalization is independent of dictionary and rendering choices:
An omitted custom field inherits the base profile through UNSET; None
preserves the input punctuation for that role. See
Punctuation profiles for recognized punctuation and the
API reference for Python types.
recovery controls malformed HTML handling. It does not change plain-text or
Markdown conversion. See HTML processing.