Skip to main content

Crate okpyeon

Crate okpyeon 

Source
Expand description

§okpyeon (옥편)

Korean IME candidate data as static tables, for the two conversions every Korean input method needs when the 한자(hanja) key is pressed:

  • Hanja lookup (hanja): a hangul syllable reading (독음) to its hanja candidates, each with a hun-eum gloss (훈음, e.g. "배울 학"). Like flipping through a paper 옥편.
  • Special symbols (symbols, symbols_revised): the MS-IME-style consonant tables (press then the 한자 key to pick ※ ☆ ★ …).

Word-level (multi-syllable) conversion is deliberately out of scope; every lookup key is a single char.

let candidates = okpyeon::hanja('학').unwrap();
assert_eq!(candidates[0], ('學', "배울 학"));

let shapes = okpyeon::symbols('ㅁ').unwrap();
assert!(shapes.contains(&'※'));

§Data

The tables are compiled in from two libhangul data files (vendored in data/, BSD-3-Clause, see the crate README for provenance):

  • hanja.txt, filtered to entries whose key and value are each a single character (multi-syllable word entries, plus two anomalous entries with multi-character values, are removed). Candidate order preserves the file order, which libhangul curates common-first ( starts with 學 鶴 虐 …), so it is directly usable as an IME candidate list. Glosses may be empty for rare hanja.
  • mssymbol.txt, the consonant-to-symbol tables replicating the Windows MS IME behavior. 18 keys exist (- plus ㄲ ㄸ ㅃ ㅆ; has no assignment, faithful to MS IME). Keys are compatibility jamo (U+3131..).

No allocation, no std, no dependencies; lookups are binary searches over sorted static slices.

Functions§

hanja
Looks up hanja candidates for a hangul syllable reading (독음).
symbols
Looks up the MS-IME-style special symbol candidates for a consonant.
symbols_revised
Like symbols, with the two known mssymbol.txt quirks corrected.