jmdict-rs

Crates.iojmdict-rs
lib.rsjmdict-rs
version0.1.2
sourcesrc
created_at2023-07-29 15:47:22.847221
updated_at2023-07-30 12:16:50.73749
descriptionSimple interface for interacting with JMdict Japanese dictionary
homepage
repositoryhttps://github.com/piropaolo/jmdict-rs
max_upload_size
id929315
size19,666
Paweł Kamiński (piropaolo)

documentation

https://docs.rs/jmdict-rs

README

jmdict-rs

Crates.io Docs License

Unleash the kawaii power! jmdict-rs is a simple and lightweight Rust library that provides an interface for accessing the JMdict Japanese language dictionary. Instead of using the original XML files, this library utilizes preprocessed JSON files from the jmdict-simplified project.

In order to reduce the crate size and to provide up-to-date entries, language data is downloaded at build time from the latest release of jmdict-simplified.

Installation

Add the following to your Cargo.toml file

[dependencies]
jmdict-rs = "0.1.2"

Usage

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let search = "楽勝";
    let entries = jmdict_rs::entries();

    let entry = entries.iter().find(|e| {
        e.kanji.iter().any(|k| k.text == search)
    }).unwrap();

    let texts: Vec<String> = entry.sense.iter().map(|s|
        s.gloss.iter().map(|g|
            g.text.clone()
        )
    ).flatten().collect();
    eprintln!("Search result = {:#?}", texts.iter().next().unwrap());

    Ok(())
}

License

JMdict

The origin of JMdict in the form of a JSON file is the repository jmdict-simplified. In view of this, the said file is subject to the same license as its original source, namely JMdict.xml, which is the intellectual property of the Electronic Dictionary Research and Development Group. See EDRDG License

Other files

Source code and the rest of the files in this project are licensed under Apache License, Version 2.0.

Commit count: 17

cargo fmt