msime_engine/cantonese/
mod.rs1pub mod scheme;
4pub mod shuangpin;
5pub mod syllable;
6
7use std::path::Path;
8use std::sync::Arc;
9
10pub use scheme::{CantoneseCandidate, CantoneseScheme};
11pub use syllable::Inventory;
12
13use crate::error::Result;
14use crate::language_dictionary::{self, LanguageDictionary};
15
16pub const SPELLING_SYMBOLS_COMPOSING: &str = "'";
18
19pub struct CantoneseDictionary {
21 dictionary: LanguageDictionary,
22 inventory: Arc<Inventory>,
23}
24
25impl CantoneseDictionary {
26 pub fn open(path: &Path) -> Result<Self> {
28 let dictionary = language_dictionary::open_read_only(path)?;
29 let inventory = Arc::new(Inventory::load(&dictionary)?);
30 Ok(Self {
31 dictionary,
32 inventory,
33 })
34 }
35
36 pub fn dictionary(&self) -> &LanguageDictionary {
37 &self.dictionary
38 }
39
40 pub fn inventory(&self) -> Arc<Inventory> {
42 Arc::clone(&self.inventory)
43 }
44}