1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! **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][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
//!
//! ```toml
//! [dependencies]
//! jmdict-rs = "0.1.1"
//! ```
//!
//! # Usage
//!
//! ```rust
//! 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][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][EDRDG-license]
//!
//! ## Other files
//!
//! Source code and the rest of the files in this project are licensed under [Apache License, Version 2.0][Apache-2.0].
//!
//! [jmdict-simplified]: https://github.com/scriptin/jmdict-simplified
//! [EDRDG-license]: http://www.edrdg.org/edrdg/licence.html
//! [Apache-2.0]: http://www.apache.org/licenses/LICENSE-2.0
pub use crate;
static JM_DICT_STR: &'static str = include_str!;