This crate provides a data structure for word mapping. It can be used for language translation.
```rust use word_dictionary::Dictionary;
let mut dictionary = Dictionary::new("tests/data/dictionary.txt"); // input a dictionary file
// dictionary.read_data().unwrap(); // if the dictionary file already exists
dictionary.addedit("Althasol", "阿爾瑟索").unwrap(); dictionary.addedit("Aldun", "奧爾敦").unwrap(); dictionary.addedit("Alduin", "阿爾杜因").unwrap(); dictionary.addedit("Alduin", "奥杜因").unwrap();
asserteq!("阿爾瑟索", dictionary.getright(dictionary.findleftstrictly("Althasol", 0).unwrap()).unwrap()); asserteq!("奧爾敦", dictionary.getright(dictionary.findleft("dun", 0).unwrap()).unwrap()); asserteq!("奥杜因", dictionary.getright(dictionary.findleft("Alduin", 0).unwrap()).unwrap()); asserteq!("阿爾杜因 --> 奥杜因", dictionary.getallrighttostring(dictionary.findleft("Alduin", 0).unwrap()).unwrap());
// The dictionary file now would be /* Alduin = 阿爾杜因 --> 奥杜因 Aldun = 奧爾敦 Althasol = 阿爾瑟索 */ ```
https://crates.io/crates/word-dictionary
https://docs.rs/word-dictionary