-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.ts
983 lines (875 loc) · 27.9 KB
/
index.ts
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
//////////////////////////////////////////////
// Shared custom types for all dictionaries //
//////////////////////////////////////////////
/**
* Language code, ISO 639-1 standard.
* 2 letters: "en", "es", "fr"
* @see <https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes>
* @see <https://en.wikipedia.org/wiki/ISO_639-1>
*/
export type Language2Letter = string;
/**
* Language code, ISO 639-2 standard.
* 3 letters: "eng", "spa", "fra"
* @see <https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes>
* @see <https://en.wikipedia.org/wiki/ISO_639-2>
*/
export type Language3Letter = string;
export type Language = Language2Letter | Language3Letter;
/**
* Dictionary metadata: version, languages, creation date
*/
export interface DictionaryMetadata<L extends Language> {
/**
* Semantic version of this project (not the dictionary itself).
* For the dictionary revisions, see `dictRevisions` field below
* @see <https://semver.org/>
*/
version: string;
/**
* List of languages in this files
*/
languages: L[];
/**
* Creation date of JMdict file, as it appears in a comment
* with format "JMdict created: YYYY-MM-DD" in the original XML file header
*/
dictDate: string;
}
/////////////////////////////////////////////////
// Shared custom types for JMdict and JMnedict //
/////////////////////////////////////////////////
/**
* xref - Full reference format: word (kanji+kana) + reading (kana-only) + sense index (starting from 1)
*/
export type XrefWordReadingIndex = [
kanji: string,
kana: string,
senseIndex: number,
];
/**
* xref - Shorter reference format: word + reading, without sense index
*/
export type XrefWordReading = [kanji: string, kana: string];
/**
* xref - Shorter reference format: word (can be kana-only or contain kanji) + sense index
*/
export type XrefWordIndex = [kanjiOrKana: string, senseIndex: number];
/**
* xref - The shortest reference format: just the word (can be kana-only or contain kanji)
*/
export type XrefWord = [kanjiOrKana: string];
/**
* xref - Cross-reference
*
* Examples:
* - `["丸", "まる", 1]` - refers to the word "丸", read as "まる" ("maru"),
* specifically the 1st sense element
* - `["○", "まる", 1]` - same as previous, but "○" is a special character
* for the word "丸"
* - `["二重丸", "にじゅうまる"]` - refers to the word "二重丸",
* read as "にじゅうまる" ("nijoumaru")
* - `["漢数字"]` - refers to the word "漢数字", with any reading
*/
export type Xref =
| XrefWordReadingIndex
| XrefWordReading
| XrefWordIndex
| XrefWord;
/**
* tag - All tags are listed in a separate section of the file.
* See the descriptions of the root JSON objects of each dictionary.
*
* Examples:
* - `"v5uru"` - "Godan verb - Uru old class verb (old form of Eru)"
* - `"n"` - "noun (common) (futsuumeishi)",
* - `"tv"` - "television"
*/
export type Tag = string;
/**
* Dictionary metadata, such as revisions and tags.
*/
export interface JMdictDictionaryMetadata
extends DictionaryMetadata<Language3Letter> {
/**
* `true` if this file contains only common kana/kanji versions
*/
commonOnly: boolean;
/**
* Revisions of JMdict file, as they appear in comments
* in the original XML file header. These only contain
* actual version (e.g., "1.08"), not a full comment.
* Original comments also mention changes made,
* but this is omitted in the resulting JSON files
*/
dictRevisions: string[];
/**
* Tags: parts of speech, names of dialects, fields of application, etc.
* All those things are expressed as XML entities in the original file.
* Keys of this object are tags per se, and values are descriptions,
* slightly modified from the original file
*/
tags: {
[tag: Tag]: string;
};
}
//////////////////
// JMdict types //
//////////////////
/**
* JMdict root object
*
* Important concepts:
*
* - "Kanji" and "kana" versions of words are not always equivalent
* to "spellings" and "readings" correspondingly. Some words are kana-only.
* You should treat "kanji" and "kana" as different ways of spelling,
* although when kanji versions are present, kana versions are indeed "readings" for those
* - Some kana versions only apply to particular kanji versions, i.e. different spellings
* of the same word can be read in different ways. You'll see the `appliesToKanji` field
* being filled with a particular version in such cases
* - "Sense" in JMdict refers to translations along with some other information.
* Sometimes, some "senses" only apply to some particular kanji/kana versions of a word,
* that's why you'll see fields `appliesToKanji` and `appliesToKana`.
* In {@link JMnedict}, translations are simply called "translations," there are no "senses"
*/
export interface JMdict extends JMdictDictionaryMetadata {
/**
* List of dictionary entries/words
*/
words: JMdictWord[];
}
/**
* JMdict entry/word
*/
export type JMdictWord = {
/**
* Unique identifier of an entry
*/
id: string;
/**
* Kanji (and other non-kana) writings.
* Note that some words are only spelled with kana, so this may be empty.
*/
kanji: JMdictKanji[];
/**
* Kana-only writings of words.
* If a kanji is also present, these can be considered as "readings",
* but there are words written with kana only.
*/
kana: JMdictKana[];
/**
* Senses = translations + some related data
*/
sense: JMdictSense[];
};
export type JMdictKanji = {
/**
* `true` if this particular word is considered common.
* This field combines all the `*_pri` fields
* from original files in a same way as <https://jisho.org>
* and other on-line dictionaries do (typically, some words have
* "common" markers/tags). It gets rid of a bunch of `*_pri` fields
* which are not typically used. Words marked with "news1", "ichi1",
* "spec1", "spec2", "gai1" in the original file are treated as common,
* which may or may not be true according to other sources.
*/
common: boolean;
/**
* The word itself, as spelled with any non-kana-only writing.
* May contain kanji, kana (but not only kana!), and some other characters.
* Example: "CDプレイヤー" - none of these symbols are kanji,
* but "CD" is not kana, so it will be in this field. The corresponding
* kana text will be "シーディープレイヤー", where "シーディー" is how the "CD"
* is spelled in Japanese kana.
*/
text: string;
/**
* Tags applicable to this writing
*/
tags: Tag[];
};
export type JMdictKana = {
/**
* Same as {@link JMdictKanji}.common.
* In this case, it shows that this particular kana transcription of a word
* is considered common. For example, when a word can be read in multiple ways,
* some of them may be more common than others.
*/
common: boolean;
/**
* Kana-only writing, may only accidentally contain middle-dot
* and other punctuation-like characters.
*/
text: string;
/**
* Same as {@link JMdictKanji}.tags
*/
tags: Tag[];
/**
* List of kanji spellings of this word which this particular kana version applies to.
* `"*"` means "all", an empty array means "none".
* This field is useful for words will multiple kanji variants - some of them may be read
* differently than others.
*/
appliesToKanji: string[];
};
export type JMdictSense = {
/**
* Parts of speech for this sense.
*
* In the original files, part-of-speech from the previous sense elements
* may apply to the subsequent elements: e.g. if the 1st and 2nd elements
* are both nouns, then only the 1st will state that explicitly.
* This requires users to check the whole list of senses to correctly
* determine part of speech for any particular sense.
*
* Unlike the original XML files, this field is never empty/missing.
* Here, this field is "normalized" - parts of speech are present
* in every element, even if they are all the same.
*/
partOfSpeech: Tag[];
/**
* List of kanji writings within this word which this sense applies to.
* Works in conjunction with the next `appliesToKana` field.
* `"*"` means "all". This is never empty, unlike {@link JMdictKana}.appliesToKanji.
*/
appliesToKanji: string[];
/**
* List of kana writings within this word which this sense applies to.
* Works in conjunction with the previous `appliesToKanji` field.
* "*" means "all". This is never empty, unlike {@link JMdictKana}.appliesToKanji.
*/
appliesToKana: string[];
/**
* References to related words
*/
related: Xref[];
/**
* References to antonyms of this word
*/
antonym: Xref[];
/**
* List of fields of application of this word.
* E.g. `"math"` means that this word is related to or used in Mathematics.
*/
field: Tag[];
/**
* List of dialects where this word is used
*/
dialect: Tag[];
/**
* Miscellanea - list of other tags which don't fit into other tag fields
*/
misc: Tag[];
/**
* Other information about this word
*/
info: string[];
/**
* Source language information for borrowed words and wasei-eigo.
* Will be empty for words with Japanese origin (most of JMdict entries)
*/
languageSource: JMdictLanguageSource[];
/**
* Translations of this word
*/
gloss: JMdictGloss[];
};
/**
* Source language information for borrowed words and wasei-eigo.
* For borrowed words this will contain the original word/phrase,
* in the source language
*/
export type JMdictLanguageSource = {
/**
* Language of this translation
*/
lang: Language3Letter;
/**
* Indicates whether the sense element fully or partially
* describes the source word or phrase of the loanword
*/
full: boolean;
/**
* Indicates that the word is wasei-eigo.
*
* @see <https://en.wikipedia.org/wiki/Wasei-eigo>
*/
wasei: boolean;
/**
* Text in the language defined by a `lang` field, or `null`
*/
text: string | null;
};
/**
* Gender
*/
export type JMdictGender = 'masculine' | 'feminine' | 'neuter';
/**
* export type of translation
*/
export type JMdictGlossType =
| 'literal'
| 'figurative'
| 'explanation'
| 'trademark'; // e.g. name of a company or a product
/**
* Translation of a word
*/
export type JMdictGloss = {
/**
* Language of this translation
*/
lang: Language3Letter;
/**
* Gender.
* Typically, for a noun in the target language.
* When `null`, the gender is either not relevant or hasn't been provided.
*/
gender: JMdictGender | null;
/**
* export type of translation.
* Most words have `null` values, meaning this attribute was absent in the original XML entry.
* Jmdict documentation does not describe the meaning of this attribute being absent.
*/
type: JMdictGlossType | null;
/**
* A translation word/phrase
*/
text: string;
};
////////////////////
// Jmnedict types //
////////////////////
/**
* JMnedict root object
*
* Differences from {@link JMdict} format (in {@link JMdictWord}):
*
* 1. `kanji` and `kana` have no `common` flag because in this dictionary
* priority data is missing (`ke_pri` and `re_pri` fields in JMdict,
* see {@link JMdictKanji}.common and {@link JMdictKana}.common)
* 2. `translation` instead of `gloss`
* 3. `translation->translation->lang` seems to be always empty because
* the original XML files have no data in corresponding attributes,
* even though documentation says otherwise. In this JSON version,
* `"eng"` (English) is always present as a default
*/
export interface JMnedict extends JMdictDictionaryMetadata {
/**
* List of dictionary entries/words
*/
words: JMnedictWord[];
}
/**
* JMdict entry/word
*/
export type JMnedictWord = {
/**
* Unique identifier of an entry
*/
id: string;
/**
* Kanji (and other non-kana) writings.
* Note that some words are only spelled with kana, so this may be empty.
*/
kanji: JMnedictKanji[];
/**
* Kana-only writings of words.
* If a kanji is also present, these can be considered as "readings",
* but there are words written with kana only.
*/
kana: JMnedictKana[];
/**
* Translations + some related data
*/
translation: JMnedictTranslation[];
};
export type JMnedictKanji = {
/**
* The word itself, as spelled with any non-kana-only writing.
*
* @see {@link JMdictKanji}.text
*/
text: string;
/**
* Tags applicable to this writing
*/
tags: Tag[];
};
export type JMnedictKana = {
/**
* Kana-only writing, may only accidentally contain middle-dot
* and other punctuation-like characters.
*/
text: string;
/**
* Same as {@link JMnedictKanji}.tags
*/
tags: Tag[];
/**
* List of kanji spellings of this word which this particular kana version applies to.
* `"*"` means "all", an empty array means "none".
* This field is useful for words will multiple kanji variants - some of them may be read
* differently than others.
*/
appliesToKanji: string[];
};
export type JMnedictTranslation = {
/**
* Name types, as specified in {@link JMnedict}.tags
*/
type: Tag[];
/**
* References to related words
*/
related: Xref[];
/**
* Translations
*/
translation: JMnedictTranslationTranslation[];
};
export type JMnedictTranslationTranslation = {
/**
* Language of this translation
*/
lang: Language3Letter;
/**
* A translation word/phrase
*/
text: string;
};
////////////////////
// Kanjidic types //
////////////////////
export interface Kanjidic2DictionaryMetadata
extends DictionaryMetadata<Language2Letter> {
/**
* Version of the file, ordinal number.
* The original XML file doesn't specify the meaning of this field.
*/
fileVersion: number;
/**
* Format: YYYY-NN, where YYYY is a year, and NN is a zero-padded ordinal number (01, 02, ..., 99)
*/
databaseVersion: string;
}
/**
* Kanjidic root object
*/
export interface Kanjidic2 extends Kanjidic2DictionaryMetadata {
/**
* List of dictionary entries/characters
*/
characters: Kanjidic2Character[];
}
export type Kanjidic2Character = {
/**
* Kanji itself
*/
literal: string;
/**
* Kanji code in various encoding systems, such as Unicode or JIS
*/
codepoints: Kanjidic2Codepoint[];
/**
* Radicals (i.e. "components" used for looking up kanji in dictionaries) of this kanji
* Note that radicals don't necessarily represent all the component parts of a kanji,
* but instead only describe some more distinctive parts. Radicals are used
* to create indexes of kanji in dictionaries.
*/
radicals: Kanjidic2Radical[];
/**
* Miscellanea data, such as school grade, JLPT level, usage frequency, etc.
*/
misc: Kanjidic2Misc;
/**
* References to find this kanji in various dictionaries
*/
dictionaryReferences: Kanjidic2DictionaryReference[];
/**
* Query codes to find this kanji in various (typically electronic) dictionaries.
* Query code is typically a unique sequence of numbers and/or letters which
* describes the shape of a kanji w/o relying on the knowledge of its
* reading or meaning.
*/
queryCodes: Kanjidic2QueryCode[];
/**
* Reading and meaning of a kanji, split into groups because different
* readings can have different meanings.
*/
readingMeaning: Kanjidic2ReadingMeaning | null;
};
export type Kanjidic2Codepoint = {
/**
* - jis208 - JIS X 0208-1997 - kuten coding, value format: nn-nn
* - jis212 - JIS X 0212-1990 - kuten coding, value format: nn-nn
* - jis213 - JIS X 0213-2000 - kuten coding, value format: p-nn-nn
* - ucs - Unicode 4.0 - hex coding, value format: 4 or 5 hexadecimal digits
*/
type: 'jis208' | 'jis212' | 'jis213' | 'ucs';
value: string;
};
export type Kanjidic2Radical = {
/**
* - classical - based on the system first used in the KangXi Zidian.
* The Shibano "JIS Kanwa Jiten" is used as the reference source.
* - nelson_c - as used in the Nelson "Modern Japanese-English
* Character Dictionary" (i.e. the Classic, not the New Nelson).
* This will only be used where Nelson reclassified the kanji.
*/
type: 'classical' | 'nelson_c';
value: number;
};
export type Kanjidic2Misc = {
grade: number | null;
/**
* First value is the right count, the rest are common miscounts
*/
strokeCounts: number[];
/**
* List of variants of this kanji. "Variants" typically kanji with the same
* meaning but different shape, e.g. language-specific or simplified versions.
*/
variants: Kanjidic2Variant[];
/**
* The rank of the character based on its frequency.
* Only first 2,500 most used kanji, based on data of Japanese newspapers.
*/
frequency: number | null;
/**
* Human-readable names of radical, if this kanji is also known as a radical
* for other kanji. Most of the time this list is empty.
*/
radicalNames: string[];
/**
* The (former) Japanese Language Proficiency Test (JLPT) level for this kanji.
* 1 (most advanced) to 4 (most elementary).
* Some kanji are not listed in JLPT.
*
* "Note that the JLPT test levels changed in 2010, with a new 5-level
* system (N1 to N5) being introduced. No official kanji lists are
* available for the new levels. The new levels are regarded as
* being similar to the old levels except that the old level 2 is
* now divided between N2 and N3."
*/
jlptLevel: number | null;
};
export type Kanjidic2Variant = {
/**
* - jis208 - in JIS X 0208 - kuten coding
* - jis212 - in JIS X 0212 - kuten coding
* - jis213 - in JIS X 0213 - kuten coding
* - deroo - De Roo number - numeric
* - njecd - Halpern NJECD index number - numeric
* - s_h - The Kanji Dictionary (Spahn & Hadamitzky) - descriptor
* - nelson_c - "Classic" Nelson - numeric
* - oneill - Japanese Names (O'Neill) - numeric
* - ucs - Unicode codepoint - hexadecimal
*/
type:
| 'jis208'
| 'jis212'
| 'jis213'
| 'deroo'
| 'njecd'
| 's_h'
| 'nelson_c'
| 'oneill'
| 'ucs';
value: string;
};
/**
* Special case for reference: Morohashi
*
* @see {@link Kanjidic2DictionaryReferenceNotMorohashi} for non-Morohashi types
*/
export type Kanjidic2DictionaryReferenceMorohashi = {
/**
* - moro - "Daikanwajiten" compiled by Morohashi. For some kanji two
* additional attributes are used: m_vol: the volume of the
* dictionary in which the kanji is found, and m_page: the page
* number in the volume.
*
* @see {@link Kanjidic2DictionaryReferenceNotMorohashi} for non-Morohashi types
*/
type: 'moro';
morohashi: {
volume: number;
page: number;
} | null;
value: string;
};
export type Kanjidic2DictionaryReferenceNotMorohashi = {
/**
* - nelson_c - "Modern Reader's Japanese-English Character Dictionary",
* edited by Andrew Nelson (now published as the "Classic" Nelson).
* - nelson_n - "The New Nelson Japanese-English Character Dictionary", edited by John Haig.
* - halpern_njecd - "New Japanese-English Character Dictionary", edited by Jack Halpern.
* - halpern_kkd - "Kodansha Kanji Dictionary", (2nd Ed. of the NJECD) edited by Jack Halpern.
* - halpern_kkld - "Kanji Learners Dictionary" (Kodansha) edited by Jack Halpern.
* - halpern_kkld_2ed - "Kanji Learners Dictionary" (Kodansha), 2nd edition
* (2013) edited by Jack Halpern.
* - heisig - "Remembering The Kanji" by James Heisig.
* - heisig6 - "Remembering The Kanji, Sixth Ed." by James Heisig.
* - gakken - "A New Dictionary of Kanji Usage" (Gakken)
* - oneill_names - "Japanese Names", by P.G. O'Neill.
* - oneill_kk - "Essential Kanji" by P.G. O'Neill.
* - moro - See {@link Kanjidic2DictionaryReferenceMorohashi}
* - henshall - "A Guide To Remembering Japanese Characters" by Kenneth G. Henshall.
* - sh_kk - "Kanji and Kana" by Spahn and Hadamitzky.
* - sh_kk2 - "Kanji and Kana" by Spahn and Hadamitzky (2011 edition).
* - sakade - "A Guide To Reading and Writing Japanese" edited by Florence Sakade.
* - jf_cards - Japanese Kanji Flashcards, by Max Hodges and Tomoko Okazaki. (Series 1)
* - henshall3 - "A Guide To Reading and Writing Japanese" 3rd
* edition, edited by Henshall, Seeley and De Groot.
* - tutt_cards - Tuttle Kanji Cards, compiled by Alexander Kask.
* - crowley - "The Kanji Way to Japanese Language Power" by Dale Crowley.
* - kanji_in_context - "Kanji in Context" by Nishiguchi and Kono.
* - busy_people - "Japanese For Busy People" vols I-III, published
* by the AJLT. The codes are the volume.chapter.
* - kodansha_compact - the "Kodansha Compact Kanji Guide".
* - maniette - codes from Yves Maniette's "Les Kanjis dans la tete" French adaptation of Heisig.
*
* 'moro' type is excluded on purpose
*
* @see {@link Kanjidic2DictionaryReferenceMorohashi} for Morohashi ('moro') type
*/
type:
| 'nelson_c'
| 'nelson_n'
| 'halpern_njecd'
| 'halpern_kkd'
| 'halpern_kkld'
| 'halpern_kkld_2ed'
| 'heisig'
| 'heisig6'
| 'gakken'
| 'oneill_names'
| 'oneill_kk'
| 'henshall'
| 'sh_kk'
| 'sh_kk2'
| 'sakade'
| 'jf_cards'
| 'henshall3'
| 'tutt_cards'
| 'crowley'
| 'kanji_in_context'
| 'busy_people'
| 'kodansha_compact'
| 'maniette';
morohashi: null;
value: string;
};
/**
* Dictionary references.
*
* This type is split into multiple cases for better type checking:
*
* - {@link Kanjidic2DictionaryReferenceMorohashi} - "Morohashi", has an optional additional field
* - {@link Kanjidic2DictionaryReferenceNotMorohashi} - everything else
*/
export type Kanjidic2DictionaryReference =
| Kanjidic2DictionaryReferenceMorohashi
| Kanjidic2DictionaryReferenceNotMorohashi;
/**
* Special case for query code: skip
*
* @see {@link Kanjidic2QueryCodeNotSkip} for non-skip types
*/
export type Kanjidic2QueryCodeSkip = {
/**
* - skip - Halpern's SKIP (System of Kanji Indexing by Patterns)
* code. The format is n-nn-nn. See the KANJIDIC documentation
* for a description of the code and restrictions on the
* commercial use of this data. [P] There are also
* a number of misclassification codes, indicated by the
* "skip_misclass" attribute.
*
* @see {@link Kanjidic2QueryCodeNotSkip} for non-skip types
*/
type: 'skip';
/**
* - posn - a mistake in the division of the kanji
* - stroke_count - a mistake in the number of strokes
* - stroke_and_posn - mistakes in both division and strokes
* - stroke_diff - ambiguous stroke counts depending on glyph
*/
skipMisclassification:
| 'posn'
| 'stroke_count'
| 'stroke_and_posn'
| 'stroke_diff'
| null;
value: string;
};
export type Kanjidic2QueryCodeNotSkip = {
/**
* - skip - See {@link Kanjidic2QueryCodeSkip}
* - sh_desc - the descriptor codes for The Kanji Dictionary (Tuttle 1996)
* by Spahn and Hadamitzky. They are in the form nxnn.n,
* e.g. 3k11.2, where the kanji has 3 strokes in the
* identifying radical, it is radical "k" in the SH
* classification system, there are 11 other strokes, and it is
* the 2nd kanji in the 3k11 sequence. [I]
* - four_corner - the "Four Corner" code for the kanji. This is a code
* invented by Wang Chen in 1928. See the KANJIDIC documentation
* for an overview of the Four Corner System. [Q]
* - deroo - the codes developed by the late Father Joseph De Roo, and
* published in his book "2001 Kanji" (Bonjinsha). Fr De Roo
* gave his permission for these codes to be included. [DR]
* - misclass - a possible misclassification of the kanji according
* to one of the code types. (See the "Z" codes in the KANJIDIC
* documentation for more details.)
*
* 'skip' type is excluded on purpose
*
* @see {@link Kanjidic2QueryCodeSkip} for 'skip' type
*/
type: 'sh_desc' | 'four_corner' | 'deroo' | 'misclass';
skipMisclassification: null;
value: string;
};
/**
* Query codes.
*
* This type is split into multiple cases for better type checking:
*
* - {@link Kanjidic2QueryCodeSkip} - "skip" code, has an optional additional field
* - {@link Kanjidic2QueryCodeNotSkip} - everything else
*/
export type Kanjidic2QueryCode =
| Kanjidic2QueryCodeSkip
| Kanjidic2QueryCodeNotSkip;
/**
* Readings and meanings of kanji, split by groups
*/
export type Kanjidic2ReadingMeaning = {
/**
* Groups are required because different readings can have
* different meanings.
*/
groups: Kanjidic2ReadingMeaningGroup[];
/**
* Japanese readings that are now only associated with names.
* (from jap. "名乗り", "to say or give one's own name")
*/
nanori: string[];
};
/**
* Reading/meaning group.
*
* Groups are required because different readings can have
* different meanings.
*/
export type Kanjidic2ReadingMeaningGroup = {
readings: Kanjidic2Reading[];
meanings: Kanjidic2Meaning[];
};
export type Kanjidic2Reading = {
/**
* - pinyin - the modern PinYin romanization of the Chinese reading
* of the kanji. The tones are represented by a concluding digit. [Y]
* - korean_r - the romanized form of the Korean reading(s) of the
* kanji. The readings are in the (Republic of Korea) Ministry
* of Education style of romanization. [W]
* - korean_h - the Korean reading(s) of the kanji in hangul.
* - vietnam - the Vietnamese readings supplied by Minh Chau Pham.
* - ja_on - the "on" Japanese reading of the kanji, in katakana.
* Another attribute r_status, if present, will indicate with
* a value of "jy" whether the reading is approved for a
* "Jouyou kanji". (The r_status attribute is not currently used.)
* A further attribute on_type, if present, will indicate with
* a value of kan, go, tou or kan'you the type of on-reading.
* (The on_type attribute is not currently used.)
* - ja_kun - the "kun" Japanese reading of the kanji, usually in hiragana.
* Where relevant the okurigana is also included separated by a
* "." (dot). Readings associated with prefixes and suffixes are
* marked with a "-" (minus/hyphen). A second attribute r_status, if present,
* will indicate with a value of "jy" whether the reading is
* approved for a "Jouyou kanji". (The r_status attribute is not currently used.)
*/
type: 'pinyin' | 'korean_r' | 'korean_h' | 'vietnam' | 'ja_on' | 'ja_kun';
/**
* Indicates the type of on-reading: "kan", "go", "tou" or "kan'you".
* Currently not used.
*/
onType: string | null;
/**
* "jy" indicates the reading is approved for a "Jouyou kanji"
* Currently not used.
*/
status: string | null;
value: string;
};
/**
* Meaning usually refers to a historical usage of a kanji.
* This sometimes doesn't represent the current usage.
* For example, some kanji are not used as standalone words anymore,
* or used in multiple words with unrelated meanings.
*/
export type Kanjidic2Meaning = {
lang: Language2Letter;
value: string;
};
//////////////////////////////
// KRADFILE+KRADFILE2 types //
//////////////////////////////
/**
* KRADFILE and KRADFILE2 are combined into a single file.
* This is the only type you'll need.
*/
export interface Kradfile {
/**
* Version of jmdict-simplified project
*/
version: string;
/**
* Map of: Kanji -> list of radicals/components
*/
kanji: {
[kanji: string]: string[];
};
}
//////////////////////////////
// RADKFILE+RADKFILE2 types //
//////////////////////////////
/**
* RADKFILE and RADKFILE2 are combined into a single file.
* (The "radkfilex" file from the source archive is used.)
*/
export interface Radkfile {
/**
* Version of jmdict-simplified project
*/
version: string;
/**
* Map of: radical -> radical info, see {@link RadkfileRadicalInfo}
*/
radicals: {
// Radical -> info
[radical: string]: RadkfileRadicalInfo;
};
}
/**
* Radical info
*/
export type RadkfileRadicalInfo = {
/**
* Stroke count, integer > 0
*/
strokeCount: number;
/**
* One of:
*
* - the JIS X 0212 code of the kanji whose glyph better depicts the element in question
* - the name of an image file (used by the WWWJDIC server)
*/
code: string | null;
/**
* Kanji which use this radical.
*/
kanji: string[];
};