Crate cedict [] [src]

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.

Examples

let line = "你好 你好 [ni3 hao3] /Hello!/Hi!/How are you?/";
let parsed = cedict::parse_line(line).unwrap();

assert_eq!(parsed.definitions().next(), Some("Hello!"));
use std::fs::File;

match File::open("cedict.txt") {
    Ok(file) => {
        for word in cedict::parse_reader(file) {
            if word.definitions().next().unwrap().contains("Hello") {
                println!("{}", word.simplified());
            }
        }
    },
    Err(_) => {
        println!("Cannot read file");
    }
}

Structs

DictEntry

A struct that contains all fields of a CEDICT definition

Functions

parse_line

Parses a line in the CEDICT format into a DictEntry

parse_reader

Returns an iterator over Readers, which can be open files, byte arrays or anything else that implements Read