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

#361 in Internationalization (i18n)

Download history 4825/week @ 2024-02-26 4908/week @ 2024-03-04 4419/week @ 2024-03-11 4662/week @ 2024-03-18 3962/week @ 2024-03-25 4805/week @ 2024-04-01 4636/week @ 2024-04-08 4922/week @ 2024-04-15 4561/week @ 2024-04-22 4847/week @ 2024-04-29 4470/week @ 2024-05-06 4259/week @ 2024-05-13 4388/week @ 2024-05-20 3978/week @ 2024-05-27 4150/week @ 2024-06-03 3766/week @ 2024-06-10

16,740 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