Skip to content

A Rust parser for the CC-CEDICT Chinese-English Dictionary

License

Notifications You must be signed in to change notification settings

gkbrk/rust-cedict

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cedict - Rust library for parsing CC-CEDICT

Crates.io Docs.rs

Welcome to cedict! This Rust crate provides functionality for reading and writing the CC-CEDICT Chinese-English dictionary format. You can use it to implement Chinese dictionaries in Rust or automate maintenance tasks for the CEDICT project.

What is CC-CEDICT?

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

Usage

Here's a simple example of parsing a single dictionary entry:

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

About

A Rust parser for the CC-CEDICT Chinese-English Dictionary

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages