pub struct Dict { /* private fields */ }Expand description
Dictionary to convert text.
This library doesn’t contain dictionary file. You may download them from OpenCC’s repo.
For chaining multiple dicts, just concat all to one file (in any order).
§Built-in dictionaries
The library includes optional dictionaries when builtin_dicts
feature is on. Disabled by default.
§File Format
The format is the same as text format (not the compiled binary one) in OpenCC project.
Specifically, one rule per line, two columns per rule splitted by a TAB
(\t). First column is original word/phrase, the other is converted one,
which may contains multiples word/phrase splitted by a space ( ), but
only the first one is used, others will be ignored.
Implementations§
Source§impl Dict
impl Dict
Sourcepub fn load_lines<T, S>(lines: T) -> Self
pub fn load_lines<T, S>(lines: T) -> Self
Load dict from lines of string.
Sourcepub fn load<T>(reader: T) -> Selfwhere
T: Read,
pub fn load<T>(reader: T) -> Selfwhere
T: Read,
Load dict file. Unrecognizable data will be silently ignored.
Sourcepub fn replace_all(&self, text: &str) -> String
pub fn replace_all(&self, text: &str) -> String
Use this dict to convert string. Return converted text.