inputx-nihongo
Self-contained Japanese input engine for Rust — Hepburn (with kunrei
alternates) romaji → hiragana/katakana, on-yomi kanji lookup, jukugo
(熟語) compound lookup, and compose_sentence particle/copula
sentence guesses. Pluggable third-source designed to plug next to
the wubi / pinyin engines in Inputx,
or to run standalone as a permissively-licensed Japanese IME building
block.
[]
= "1.4"
What's in the box
- Romaji table — Hepburn primary + kunrei alternates + extended
foreign-syllable subset (
fa/fi/vu/tha/kwo/…) for gairaigo. Whole-buffer rendering: every keystroke re-renders the kana from scratch, so backspace / mid-buffer edits never leave stale state. - 27,380 jukugo entries —
JUKUGO_TABLEcovering common compounds;lookup_by_readingreturns(kanji, freq)tuples,lookup_by_reading_prefixpowers the prefix-prediction path (shinjuk → 新宿at proximity 7/8). - 1,666 kanji readings (813 source kanji × multi-reading) —
restricted to kanji whose Unicode codepoint is identical to a
Simplified-Chinese hanzi, so single-kanji surfaces (
ka → 加, 家, …) never collide with the wubi / pinyin output. JapaneseEngine— stateful per-session driver:handle_letter/backspace/escape/candidates/commit_index, parallel in shape toinputx-wubi::WubiEngineso the composite layer plugs it in next to the existing engines without bespoke wiring.- Chōonpu plumbing —
-is a typeable JP chōonpu (ー) input character when the buffer is non-empty, so long-vowel words like コーヒー stay reachable; empty-buffer-rejects so a stranded hyphen still routes to the host as ASCII punctuation.
Quick start
use ;
let mut eng = new;
for b in b"shinjuku"
// Candidates re-rendered after every keystroke; ordered by
// composite-layer scoring (jukugo > kanji > kana fallback).
for cand in eng.candidates
// kanji: 新宿 (freq=N, composed=false)
// hira: しんじゅく (freq=0, composed=false)
// kata: シンジュク (freq=0, composed=false)
// Commit one — engine clears its buffer ready for the next word.
let committed = eng.commit_index;
assert_eq!;
Direct table access (no engine state needed):
use ;
// All jukugo whose reading is `shinjuku`.
let jc: = lookup_by_reading.collect;
// All kanji whose on-yomi includes `ka`.
let kc: = lookup_by_reading.collect;
// Prefix-prediction: jukugo whose reading STARTS with `shinjuk`.
let pred: =
lookup_by_reading_prefix.collect;
Plugin-style integration
The crate has no dependency on inputx-wubi / inputx-pinyin. The
consumer (typically inputx-core::composite) holds an optional
JapaneseEngine and routes keystrokes to it based on the
enable_japanese flag. When disabled the engine is never constructed
and JP has zero runtime cost on the hot path.
For the cement / dispatch wiring used by the Inputx IME, see the
companion inputx-nihongo-cement crate.
Scope
- In v1.4: romaji → hiragana/katakana, on-yomi kanji lookup,
jukugo compound lookup, mechanical
compose_sentence(particle/copula sentence guesses, markedcomposed: trueso the composite layer can score them below real dictionary entries), prefix-prediction for jukugo. - Not in v1.4: okurigana / verb inflection, user-learning (no L0 pin layer), per-kanji frequency ordering beyond what's baked into the tables.
API stability
The 1.x line follows semver:
JapaneseEngine/Candidate/KanaKindpublic surface — no breaking changes within 1.x. NewCandidatefields land via#[non_exhaustive]semantics (already in place).jukugo::lookup_by_reading/jukugo::lookup_by_reading_prefix/kanji::lookup_by_readingiterators — signature stable; the underlyingJUKUGO_TABLE/KANJI_TABLEconst tables may grow (new entries) but never shrink in 1.x.- Chōonpu
-handling — fixed:-is a JP input character when the buffer is non-empty, rejected when empty. Stable across 1.x.
Anything not on pub is internal — module layout, helper traits,
romaji-table internals — and may change in any minor release.
License
Dual-licensed under MIT OR Apache-2.0 © 2026 GOLIA K.K., at your option.
Bundled data (jukugo / kanji tables) is hand-curated from permissively-licensed and public-domain sources; no GPL or LGPL content is embedded.