Skip to main content

DictionaryComposer

Struct DictionaryComposer 

Source
pub struct DictionaryComposer { /* private fields */ }
Expand description

使用所选语言的现有词库提供者组成完整混合路径。构造应在会话准备阶段完成, 不要在每次按键时重建。它持有独立查询状态,中文 n 元表和日文模型仍由现有缓存共享。 语言集合或模型路径改变时重建;词典修订到达时调用 Self::clear。

Implementations§

Source§

impl DictionaryComposer

Source

pub fn new(paths: &RuntimePaths, languages: &[Language]) -> Self

只打开显式选择的语言,缺失资源按原有提供者语义返回没有词条,不下载或补写资源。

Source

pub fn with_japanese_model( paths: &RuntimePaths, languages: &[Language], model: &Path, ) -> Self

使用宿主已解析的日文资源包路径,其它词库仍取同一份运行时目录。

Source

pub fn warm_up_in_background(&self)

会话准备时沿现有提供者预热;未选日文时不读模型,不等待后台完成。

Source

pub fn convert(&mut self, input: &str) -> Option<Conversion>

只返回全串覆盖的混合备选,完整中文的存在性由 chinese_complete 保留。 当前仅接受小写拉丁编码;非法输入或预算不足时不返回部分路径。

Source

pub fn clear(&mut self)

词典修订后丢弃已确认及未命中的跨度。不可变模型更换需重建本适配器。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.