golia_pinyin/lib.rs
1#![deny(missing_docs)]
2#![deny(rustdoc::broken_intra_doc_links)]
3
4//! `golia-pinyin` — self-developed Mandarin Pinyin input method engine.
5//!
6//! Engine surface ✓ (segmenter, fuzzy, FST dict, encode, session) +
7//! 414k-entry corpus-derived dict (Unihan kHanyuPinlu + jieba + pypinyin
8//! + Leipzig + SUBTLEX) + L0 user-learning ranking (3-pick auto-pin).
9//!
10//! Sibling library: [`inputx-wubi`](https://crates.io/crates/inputx-wubi)
11//! — same architectural pattern (PHF static tables, FST main dict,
12//! zero-alloc hot path).
13//!
14//! # Quickstart
15//!
16//! ```no_run
17//! use golia_pinyin::{PinyinEngine, Session};
18//! let engine = PinyinEngine::new();
19//! let mut session = Session::new(&engine);
20//! for c in "zhongguo".chars() {
21//! session.input_char(c);
22//! }
23//! let cands = session.candidates();
24//! assert_eq!(cands.first().map(String::as_str), Some("中国"));
25//! ```
26//!
27//! # Module map
28//! - [`syllable`] — 403 valid Mandarin syllable inventory (PHF set)
29//! - [`fuzzy`] — toggleable fuzzy-pair expansion (`z↔zh` etc.)
30//! - [`segmenter`] — DP segmentation of continuous pinyin strings
31//! - [`dict`] — FST-backed `pinyin → words` lookup with L0 user-learning
32//! - [`encode`] — `char → readings` reverse lookup
33//! - [`engine`] — immutable [`PinyinEngine`] (dict + fuzzy)
34//! - [`session`] — mutable [`Session`] holding the user's input buffer
35//! - [`ranking`] — L0 snapshot type for host-side persistence
36
37pub mod dict;
38pub mod encode;
39pub mod engine;
40pub mod fuzzy;
41pub mod ranking;
42pub mod segmenter;
43pub mod session;
44pub mod syllable;
45
46pub use dict::PinyinDict;
47pub use encode::{char_to_pinyin, covered_char_count};
48pub use engine::PinyinEngine;
49pub use fuzzy::FuzzyConfig;
50pub use ranking::{L0Snapshot, PROMOTE_THRESHOLD};
51pub use segmenter::{Segmentation, segment};
52pub use session::Session;
53pub use syllable::{VALID_SYLLABLES, count as syllable_count, is_valid as is_valid_syllable};