11 releases

0.3.2 Sep 17, 2024
0.3.1 Oct 20, 2022
0.2.3 Apr 6, 2018
0.2.1 Mar 27, 2018
0.1.0 Mar 27, 2017

#289 in Parser implementations

Download history 3813/week @ 2024-07-29 4095/week @ 2024-08-05 4023/week @ 2024-08-12 3721/week @ 2024-08-19 3970/week @ 2024-08-26 4552/week @ 2024-09-02 4276/week @ 2024-09-09 4174/week @ 2024-09-16 6436/week @ 2024-09-23 4407/week @ 2024-09-30 5284/week @ 2024-10-07 5176/week @ 2024-10-14 5112/week @ 2024-10-21 4301/week @ 2024-10-28 4265/week @ 2024-11-04 4596/week @ 2024-11-11

18,930 downloads per month
Used in haoxue-dict

MIT license

11KB
171 lines

cedict - Rust library for parsing CC-CEDICT

Crates.io Docs.rs

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.

What is CC-CEDICT

CC-CEDICT, or formerly CEDICT, is a freely available Chinese-English dictionary. This library allows you to parse it.

Usage

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());
        }
    }
}

No runtime deps