Crates.io | cedict |
lib.rs | cedict |
version | 0.3.2 |
source | src |
created_at | 2017-03-27 19:45:37.348037 |
updated_at | 2024-09-17 20:21:35.051393 |
description | Parser for the CC-CEDICT Chinese-English Dictionary |
homepage | |
repository | https://github.com/gkbrk/rust-cedict |
max_upload_size | |
id | 9172 |
size | 12,294 |
cedict is a Rust crate for reading and writing the CC-CEDICT Chinese-English dictionary format. It can be used to implement Chinese dictionaries in Rust. It can also serve as a tool for automating maintenance to the CEDICT project.
CC-CEDICT, or formerly CEDICT, is a freely available Chinese-English dictionary. This library allows you to parse it.
let line = "你好 你好 [ni3 hao3] /Hello!/Hi!/How are you?/";
let parsed = cedict::parse_line(line).unwrap();
println!("{}", parsed.definitions[0]); // Prints "Hello!"
Parse a dictionary file and search for "Hello".
extern crate cedict;
use std::fs::File;
fn main() {
let file = File::open("cedict.txt").unwrap();
for definition in cedict::parse_reader(file) {
if definition.definitions().next().unwrap().contains("Hello") {
println!("{}", definition.simplified());
}
}
}