inputx-scoring
Probability-native candidate scoring primitive for IME engines.
score(W | i) = log_prior(W) + log_likelihood(i | W)
This crate ships only the schema — the Candidate struct, the
MatchType enum, the Source tag, and the additive sort key. It has
no opinion on how producers derive log_prior or log_likelihood;
that lives in the consuming engine (Inputx wubi / pinyin / nihongo
cement crates, or any third-party IME that wants the same Bayesian
shape).
Why log-space, why fixed-point
P(W|i) ∝ P(i|W) · P(W) is the standard Bayesian decomposition for
candidate ranking. In log space, multiplication becomes addition —
so each candidate's score is the sum of two independent factors, and
producers (dict lookups, n-gram scorers, fuzzy matchers) can contribute
to either term without coordinating a single global formula.
i32 Q4 fixed-point (Q4 = 16) gives ~0.0625 log-unit resolution
over ±67 million log units — far more headroom than any realistic
corpus needs. Integer arithmetic also keeps the path deterministic
across platforms (no f64 rounding drift between mac / iOS / Linux).
Schema
pub const Q4: i32 = 16;
Usage
use ;
let c = Candidate ;
assert_eq!;
no_std
Disable the std feature for #![no_std] builds (the schema itself
is core only; the std feature gates optional formatting helpers).
= { = "1.4", = false }
License
Dual-licensed under MIT or Apache-2.0.