1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![deny(elided_lifetimes_in_paths)]
#![deny(macro_use_extern_crate)]
#![deny(missing_abi)]
#![warn(missing_debug_implementations)]
// #![deny(missing_docs)]
#![warn(noop_method_call)]
#![warn(single_use_lifetimes)]
#![deny(unreachable_pub)]
#![deny(unsafe_code)]
#![warn(unused_import_braces)]
#![deny(unused_lifetimes)]
#![warn(unused_macro_rules)]
#![warn(unused_qualifications)]
#![warn(variant_size_differences)]
//! The Chewing (酷音) intelligent phonetic input method library.
//!
//! This crate provides the core algorithms and facilities that can be used to
//! implement input methods and manipulate user dictionaries.
//!
//! # Behavior
//!
//! The [Editor][editor::Editor] implements the behavior of the Chewing input
//! method. Chewing is a bopomofo phonetics input method that can convert
//! keystrokes to Zhuyin/Bopomofo and then to Chinese characters. The state
//! machine powering the input method can detect the current input context and
//! translate the input to symbols, latin characters, or Chinese characters. The
//! Editor also has an option that is enabled by default to auto-learn new
//! phrases from users' input to provide more personalized intelligence.
//!
//! ```rust,no_run
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! use chewing::editor::{BasicEditor, Editor};
//! use chewing::editor::keyboard::{KeyboardLayout, KeyCode, Qwerty};
//!
//! let keyboard = Qwerty;
//! let mut editor = Editor::chewing()?;
//!
//! editor.process_keyevent(keyboard.map(KeyCode::D));
//! editor.process_keyevent(keyboard.map(KeyCode::J));
//! editor.process_keyevent(keyboard.map(KeyCode::N4));
//! editor.process_keyevent(keyboard.map(KeyCode::Down));
//! editor.process_keyevent(keyboard.map(KeyCode::N3));
//!
//! assert_eq!("酷", editor.display());
//! # Ok(()) }
//! ```
//!
//! # Dictionary Files
//!
//! Chewing requires dictionary files at runtime. By default
//! [SystemDictionaryLoader][dictionary::SystemDictionaryLoader] will search
//! dictionaries from pre-configured system paths. See the [path] module level
//! document for the search order.
//!
//! `chewing-cli` can be used to compile the dictionary files.
//!
//! ```sh
//! cargo install chewing-cli
//! cd data
//! chewing-cli init-database -t trie tsi.src tsi.dat
//! chewing-cli init-database -t trie word.src word.dat
//! ```
//!
//! After the `tsi.dat` and `word.dat` files are generated, copy them to
//! `/usr/share/libchewing` or corresponding path on other platforms. They can
//! also be placed at user's home directory `$HOME/.config/chewing` which has
//! higher priority than the system path.
//!
//! Other required files `swkb.dat` and `symbols.dat` can be copied directly to
//! the dictionary folder.
pub mod conversion;
pub mod dictionary;
pub mod editor;
pub mod path;
pub mod zhuyin;