pub struct CustomDictionary { /* private fields */ }Expand description
カスタム辞書
技術用語・固有名詞の読みを保持し、テキスト中の該当箇所を置換する。
- 大文字小文字混在の単語 (例: “GitHub”) は case-sensitive マップに格納
- 全大文字/全小文字の単語は lowercase 正規化して case-insensitive マップに格納
- 日本語 (非 ASCII) 文字を含む単語は単純部分文字列マッチ
- ASCII のみの単語は単語境界正規表現でマッチ
Implementations§
Source§impl CustomDictionary
impl CustomDictionary
Sourcepub fn load_dictionary(&mut self, path: &Path) -> Result<(), PiperError>
pub fn load_dictionary(&mut self, path: &Path) -> Result<(), PiperError>
JSON 辞書ファイルを読み込む (v1.0 / v2.0 対応)
Sourcepub fn apply_to_text(&self, text: &str) -> String
pub fn apply_to_text(&self, text: &str) -> String
テキストに辞書を適用して単語を置換
- Case-sensitive エントリを長い順に処理
- Case-insensitive エントリを長い順に処理
Sourcepub fn add_word(&mut self, word: &str, pronunciation: &str, priority: i32)
pub fn add_word(&mut self, word: &str, pronunciation: &str, priority: i32)
単語と読みを追加
既存エントリより優先度が低い場合は追加しない。 パターンキャッシュはクリアされる。
Sourcepub fn get_pronunciation(&self, word: &str) -> Option<&str>
pub fn get_pronunciation(&self, word: &str) -> Option<&str>
単語の読みを取得
Case-sensitive マップを先に検索し、見つからなければ case-insensitive マップを検索。
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CustomDictionary
impl RefUnwindSafe for CustomDictionary
impl Send for CustomDictionary
impl Sync for CustomDictionary
impl Unpin for CustomDictionary
impl UnsafeUnpin for CustomDictionary
impl UnwindSafe for CustomDictionary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more