10 releases

0.3.1 Oct 20, 2022
0.3.0 Oct 20, 2022
0.2.3 Apr 6, 2018
0.2.1 Mar 27, 2018
0.1.0 Mar 27, 2017

#592 in Parser implementations

Download history 4078/week @ 2023-11-19 3093/week @ 2023-11-26 2467/week @ 2023-12-03 3202/week @ 2023-12-10 2454/week @ 2023-12-17 1787/week @ 2023-12-24 2461/week @ 2023-12-31 2579/week @ 2024-01-07 3422/week @ 2024-01-14 5099/week @ 2024-01-21 4199/week @ 2024-01-28 4027/week @ 2024-02-04 4747/week @ 2024-02-11 5096/week @ 2024-02-18 4826/week @ 2024-02-25 4715/week @ 2024-03-03

19,971 downloads per month
Used in haoxue-dict

MIT license

10KB
170 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