pub struct LanguageDictionary { /* private fields */ }Expand description
An open language dictionary whose format version has been checked.
Implementations§
Source§impl LanguageDictionary
impl LanguageDictionary
Sourcepub fn metadata(&self, name: &str) -> Result<Option<String>>
pub fn metadata(&self, name: &str) -> Result<Option<String>>
The metadata value stored under name.
Sourcepub fn lookup(&self, key: &str, limit: usize) -> Result<Vec<LanguageEntry>>
pub fn lookup(&self, key: &str, limit: usize) -> Result<Vec<LanguageEntry>>
The entries stored under exactly key, heaviest first and by text within a weight, at most limit.
Sourcepub fn lookup_into(
&self,
key: &str,
limit: usize,
result: &mut Vec<LanguageEntry>,
) -> Result<()>
pub fn lookup_into( &self, key: &str, limit: usize, result: &mut Vec<LanguageEntry>, ) -> Result<()>
将精确键的查询结果写入已有缓冲,保留其中字符串的容量。
Sourcepub fn has_syllable(&self, syllable: &str) -> Result<bool>
pub fn has_syllable(&self, syllable: &str) -> Result<bool>
Whether syllable is in the scheme’s syllable inventory.
Sourcepub fn syllables(&self) -> Result<Vec<String>>
pub fn syllables(&self) -> Result<Vec<String>>
The whole syllable inventory, for a scheme that segments typed letters against it in memory.
Sourcepub fn lookup_completions(
&self,
prefix: &str,
limit: usize,
) -> Result<Vec<(String, LanguageEntry)>>
pub fn lookup_completions( &self, prefix: &str, limit: usize, ) -> Result<Vec<(String, LanguageEntry)>>
The entries whose key completes the last syllable of prefix: the key starts with prefix and has no syllable boundary after it, so nei h finds nei hou but not nei hou aa. Each comes with its key, heaviest first and by text within a weight, at most limit.
Sourcepub fn lookup_completions_into(
&self,
prefix: &str,
limit: usize,
result: &mut Vec<(String, LanguageEntry)>,
) -> Result<()>
pub fn lookup_completions_into( &self, prefix: &str, limit: usize, result: &mut Vec<(String, LanguageEntry)>, ) -> Result<()>
将补全查询结果写入已有缓冲,保留键和值字符串的容量。
Sourcepub fn texts_with_key_prefix(&self, prefix: &str) -> Result<Vec<String>>
pub fn texts_with_key_prefix(&self, prefix: &str) -> Result<Vec<String>>
键以 prefix 开头的全部词条的文字,不分先后、可能重复。九宫格的笔画筛选用它取「笔顺以这几笔开头的字」:键按前缀落在一段连续区间里,只扫这一段。
Sourcepub fn lookup_pattern(
&self,
pattern: &str,
wildcard: char,
completions: bool,
limit: usize,
) -> Result<Vec<(String, LanguageEntry)>>
pub fn lookup_pattern( &self, pattern: &str, wildcard: char, completions: bool, limit: usize, ) -> Result<Vec<(String, LanguageEntry)>>
匹配 pattern 的词条,wildcard 匹配任意非空格字符,其他字符按字面匹配。补全只匹配键前缀且余下部分不能有音节边界;精确匹配整个键。按权重降序、文字升序返回至多 limit 条。首个通配符前的字面前缀限制扫描范围,只有开头通配符需要整表过滤。
Sourcepub fn lookup_pattern_into(
&self,
pattern: &str,
wildcard: char,
completions: bool,
limit: usize,
result: &mut Vec<(String, LanguageEntry)>,
) -> Result<()>
pub fn lookup_pattern_into( &self, pattern: &str, wildcard: char, completions: bool, limit: usize, result: &mut Vec<(String, LanguageEntry)>, ) -> Result<()>
将通配查询写入已有缓冲,复用键与文字的字符串容量;空模式清空结果。
Sourcepub fn lookup_readings(
&self,
positions: &[&[String]],
limit: usize,
) -> Result<Vec<(String, LanguageEntry)>>
pub fn lookup_readings( &self, positions: &[&[String]], limit: usize, ) -> Result<Vec<(String, LanguageEntry)>>
键按位置逐段取自 positions[i](以单个空格连接)的词条,各带自己的键;按权重从重到轻,再按文字、键排序,至多 limit 条。每个位置都只有一个读音时就是 lookup 对连接后的键查询,结果与它逐条相同。