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

#315 in Parser implementations

Download history 4696/week @ 2025-02-02 4556/week @ 2025-02-09 5044/week @ 2025-02-16 5040/week @ 2025-02-23 4981/week @ 2025-03-02 7045/week @ 2025-03-09 5619/week @ 2025-03-16 5441/week @ 2025-03-23 5336/week @ 2025-03-30 5616/week @ 2025-04-06 5303/week @ 2025-04-13 5538/week @ 2025-04-20 5361/week @ 2025-04-27 5664/week @ 2025-05-04 5616/week @ 2025-05-11 6105/week @ 2025-05-18

23,276 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