4 Website: http://www.vultaire.net/software/jben/
5 License: GNU General Public License (GPL) version 2
6 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>
27 #define KD_SUCCESS 0x0
28 #define KD_FAILURE 0x80000000
30 /* Onyomi/kunyomi/nanori/radical readings */
31 #define KDO_READINGS 0x1
32 /* English meanings */
33 #define KDO_MEANINGS 0x2
34 /* Grade, frequency, stroke count(s) */
35 #define KDO_HIGHIMPORTANCE 0x4
36 /* Enable dictionary display */
37 #define KDO_DICTIONARIES 0x8
38 /* Less important miscellanea, plus radical #'s */
39 #define KDO_LOWIMPORTANCE 0x10
40 /* Enable cross-referencing with vocab study list */
41 #define KDO_VOCABCROSSREF 0x20
42 /* KanjiCafe.com Stroke Order Diagrams (if present) */
43 #define KDO_SOD_STATIC 0x40
44 #define KDO_SOD_ANIM 0x80
45 /* Multi-radical information */
46 #define KDO_MULTIRAD 0x100
47 /* All options (except UNHANDLED) */
49 /* All unhandled dictionary stuff */
50 #define KDO_UNHANDLED 0x8000
52 /* Hn...: "New Japanese-English Character Dictionary" by Jack Halpern. "Halpern" field 1 in JWPce. */
54 /* Nn...: "Modern Reader's Japanese-English Character Dictionary" by Andrew Nelson. "Nelson" field 1 in JWPce. */
55 #define KDD_MRJECD 0x2
56 /* Vn...: "The New Nelson Japanese-English Character Dictionary" by John Haig. "Nelson" field 2 in JWPce. */
57 #define KDD_NNJECD 0x4
58 /* More "D" codes... add as needed */
59 /* DBnnn: Japanese for Busy People, AJLT */
61 /* DCnnnn: The Kanji Way to Japanese Language Power, Dale Crowley */
62 #define KDD_KWJLP 0x10
63 /* DGnnn: Kodansha Compact Kanji Guide */
65 /* DHnnnn: A Guide To Reading and Writing Japanese, Ken Henshall et al. */
66 #define KDD_GTRWJH 0x40
67 /* DJnnnn: Kanji in Context, Nishiguchi and Kono */
69 /* DKnnnn: Kanji Learners Dictionary, Jack Halpern */
71 /* DOnnnn: Essential Kanji, P.G. O'Neill */
73 /* DRnnnn: 2001 Kanji, Father Joseph De Roo */
75 /* DSnnnn: A Guide To Reading and Writing Japanese, Florence Sakade */
76 #define KDD_GTRWJS 0x800
77 /* DTnnn: Tuttle Kanji Cards, Alexander Kask */
78 #define KDD_TKC 0x1000
79 /* DFnnnn: Japanese Kanji Flashcards, White Rabbit Press */
80 #define KDD_JKF 0x2000
81 /* "Pn...-n...-n..." - SKIP codes used by Halpern dictionaries */
82 #define KDD_SKIP 0x4000
83 /* Inxnn.n: Kanji Dictionary, Spahn & Hadamitzky */
85 /* INnnnn: Kanji & Kana, Spahn & Hadamitzky */
86 #define KDD_KK 0x10000
87 /* Qnnnn.n: Four Corner code, used by various dictionaries in China and Japan */
88 #define KDD_FC 0x20000
89 /* MNnnnnnnn: Morohashi Daikanwajiten, index number */
90 #define KDD_MOROI 0x40000
91 /* MPnn.nnnn: Morohashi Daikanwajiten, volume.page number */
92 #define KDD_MOROVP 0x80000
93 /* Morohashi Daikanwajiten (Both indexing options) */
94 #define KDD_MORO (KDD_MOROI | KDD_MOROVP)
95 /* Ennnn: A Guide to Remembering Japanese Characters, Kenneth G. Henshall */
96 #define KDD_GRJC 0x100000
97 /* Knnnn: Gakken Kanji Dictionary ("A New Dictionary of Kanji Usage") */
98 #define KDD_GKD 0x200000
99 /* Lnnnn: Remembering The Kanji, James Heisig */
100 #define KDD_RTK 0x400000
101 /* Onnnn[A]: Japanese Names, P.G. O'Neill */
102 #define KDD_JN 0x800000
104 This is a lot of output, so it's probably for debug purposes only. */
105 #define KDD_ALL 0xFFFFFFFF
119 map
<string
,string
> codepoint
;
120 unsigned char radical
, radicalNelson
;
123 list
<int> misstrokes
;
124 map
<string
,string
> variant
;
127 map
<string
,string
> dictCode
;
128 map
<string
,string
> queryCode
;
129 list
< pair
<string
,string
> > skipMisclass
; /* Maybe this should be a
130 std::multimap instead? */
131 list
<string
> pinyin
, korean_r
, korean_h
,
132 onyomi
, kunyomi
, nanori
;
133 /* FOR NOW: I am ignoring onyomi and kunyomi r_status and on_type flags.
134 In the KANJIDIC2 dated 2008-02-12, there was only one entry, "行く",
135 which had any of these flags. Not worth the effort. */
136 map
<string
, list
<string
> > meaning
;
142 static const KDict
*Get();
143 static void Destroy();
146 /* General purpose access functions */
147 static wstring
KInfoToHtml(const KInfo
& k
);
148 static wstring
KInfoToHtml(const KInfo
& k
,
149 long options
, long dictionaries
);
150 const KInfo
* GetEntry(const wchar_t key
) const;
151 const BoostHM
<wchar_t, KInfo
>* GetHashTable() const;
153 /* Other functions */
154 bool MainDataLoaded() const;
156 /* Hidden constructor */
159 /* Dictionary file loaders */
160 int LoadKanjidic(const char* filename
, const char* jisStd
="jis208");
161 int LoadKanjidic2(const char* filename
);
162 int LoadRadkfile(const char* filename
);
163 int LoadKradfile(const char* filename
);
165 /* Kanjidic-specific stuff */
166 void KanjidicToKInfo(const string
& kanjidicEntry
, KInfo
& k
,
168 void KanjidicParser(char* kanjidicRawData
, const char* jisStd
);
169 static wstring
ConvertKanjidicEntry(const wstring
& s
);
172 static KDict
*kdictSingleton
;
173 BoostHM
<wchar_t, KInfo
> kdictData
;
174 BoostHM
<wchar_t, wstring
> radkData
;
175 BoostHM
<wchar_t, int> radkDataStrokes
;