henkan 2.4.12 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs.js +439 -46
  3. package/dist/index.cjs.js.map +2 -2
  4. package/dist/index.mjs +436 -46
  5. package/dist/index.mjs.map +2 -2
  6. package/dist/types/types.d.ts +106 -15
  7. package/dist/types/types.d.ts.map +1 -1
  8. package/dist/types/utils.d.ts +28 -6
  9. package/dist/types/utils.d.ts.map +1 -1
  10. package/docs/api/README.md +8 -2
  11. package/docs/api/functions/capitalizeString.md +1 -1
  12. package/docs/api/functions/convertJMdict.md +1 -1
  13. package/docs/api/functions/convertJMnedict.md +33 -0
  14. package/docs/api/functions/convertJawiktionaryAsync.md +1 -1
  15. package/docs/api/functions/convertJawiktionarySync.md +1 -1
  16. package/docs/api/functions/convertKanjiDic.md +1 -1
  17. package/docs/api/functions/convertKradFile.md +1 -1
  18. package/docs/api/functions/convertRadkFile.md +1 -1
  19. package/docs/api/functions/convertTanakaCorpus.md +1 -1
  20. package/docs/api/functions/convertTanakaCorpusWithFurigana.md +1 -1
  21. package/docs/api/functions/createEntryMaps.md +9 -3
  22. package/docs/api/functions/generateAnkiNote.md +2 -2
  23. package/docs/api/functions/generateAnkiNotesFile.md +1 -1
  24. package/docs/api/functions/generateFurigana.md +1 -1
  25. package/docs/api/functions/getKanji.md +1 -1
  26. package/docs/api/functions/getKanjiExtended.md +1 -1
  27. package/docs/api/functions/getName.md +57 -0
  28. package/docs/api/functions/getValidForms.md +1 -1
  29. package/docs/api/functions/getWord.md +3 -3
  30. package/docs/api/functions/getWordDefinitions.md +1 -1
  31. package/docs/api/functions/getWordDefinitionsWithFurigana.md +1 -1
  32. package/docs/api/functions/hiraganaToKatakana.md +1 -1
  33. package/docs/api/functions/isObjectArray.md +1 -1
  34. package/docs/api/functions/isStringArray.md +1 -1
  35. package/docs/api/functions/isValidArrayWithFirstElement.md +1 -1
  36. package/docs/api/functions/katakanaToHiragana.md +1 -1
  37. package/docs/api/functions/shuffleArray.md +1 -1
  38. package/docs/api/interfaces/DefaultNoteInfo.md +10 -10
  39. package/docs/api/interfaces/Definition.md +4 -4
  40. package/docs/api/interfaces/DictKanji.md +5 -5
  41. package/docs/api/interfaces/DictKanjiForm.md +2 -2
  42. package/docs/api/interfaces/DictKanjiMisc.md +5 -5
  43. package/docs/api/interfaces/DictKanjiReading.md +3 -3
  44. package/docs/api/interfaces/DictKanjiReadingMeaning.md +3 -3
  45. package/docs/api/interfaces/DictKanjiReadingMeaningGroup.md +3 -3
  46. package/docs/api/interfaces/DictKanjiWithRadicals.md +3 -3
  47. package/docs/api/interfaces/DictName.md +75 -0
  48. package/docs/api/interfaces/DictRadical.md +4 -4
  49. package/docs/api/interfaces/DictReading.md +2 -2
  50. package/docs/api/interfaces/EntryMaps.md +33 -9
  51. package/docs/api/interfaces/ExamplePart.md +7 -7
  52. package/docs/api/interfaces/GlossSpecificNumber.md +3 -3
  53. package/docs/api/interfaces/Grammar.md +15 -15
  54. package/docs/api/interfaces/GrammarMeaning.md +3 -3
  55. package/docs/api/interfaces/JaWiktionaryEntry.md +5 -5
  56. package/docs/api/interfaces/Kana.md +11 -11
  57. package/docs/api/interfaces/Kanji.md +23 -23
  58. package/docs/api/interfaces/KanjiComponent.md +3 -3
  59. package/docs/api/interfaces/KanjiForm.md +5 -5
  60. package/docs/api/interfaces/Name.md +163 -0
  61. package/docs/api/interfaces/NeDictMeaning.md +33 -0
  62. package/docs/api/interfaces/NoteAndTag.md +3 -3
  63. package/docs/api/interfaces/NoteHeaderKeys.md +7 -7
  64. package/docs/api/interfaces/Phrase.md +5 -5
  65. package/docs/api/interfaces/Radical.md +16 -16
  66. package/docs/api/interfaces/Reading.md +6 -6
  67. package/docs/api/interfaces/ResultEntry.md +8 -7
  68. package/docs/api/interfaces/TanakaExample.md +7 -7
  69. package/docs/api/interfaces/Translation.md +5 -5
  70. package/docs/api/interfaces/UsefulRegExps.md +8 -8
  71. package/docs/api/interfaces/Word.md +15 -15
  72. package/docs/api/interfaces/WordDefinitionPair.md +4 -4
  73. package/docs/api/type-aliases/Dict.md +1 -1
  74. package/docs/api/type-aliases/{DictName.md → DictNames.md} +3 -3
  75. package/docs/api/type-aliases/EntryExamplesMap.md +13 -0
  76. package/docs/api/type-aliases/EntryType.md +2 -2
  77. package/docs/api/type-aliases/KanjiEntryMap.md +1 -1
  78. package/docs/api/type-aliases/KanjiSVGMap.md +1 -1
  79. package/docs/api/type-aliases/KanjiWordsMap.md +1 -1
  80. package/docs/api/type-aliases/NameIDEntryMap.md +13 -0
  81. package/docs/api/type-aliases/Result.md +2 -2
  82. package/docs/api/type-aliases/WordDefinitionsMap.md +1 -1
  83. package/docs/api/type-aliases/WordIDEntryMap.md +1 -1
  84. package/package.json +8 -7
  85. package/src/types.ts +115 -15
  86. package/src/utils.ts +733 -162
  87. package/docs/api/type-aliases/WordExamplesMap.md +0 -13
@@ -0,0 +1,13 @@
1
+ [**henkan**](../README.md)
2
+
3
+ ***
4
+
5
+ [henkan](../README.md) / NameIDEntryMap
6
+
7
+ # Type Alias: NameIDEntryMap
8
+
9
+ > **NameIDEntryMap** = `Map`\<[`StringNumber`](StringNumber.md), [`DictName`](../interfaces/DictName.md)\>
10
+
11
+ Defined in: [types.ts:497](https://github.com/Ronokof/Henkan/blob/main/src/types.ts#L497)
12
+
13
+ A `JMnedict entry ID` ---> [DictName](../interfaces/DictName.md) `object` map
@@ -6,8 +6,8 @@
6
6
 
7
7
  # Type Alias: Result
8
8
 
9
- > **Result** = [`Word`](../interfaces/Word.md) \| [`Kanji`](../interfaces/Kanji.md) \| [`Radical`](../interfaces/Radical.md) \| [`Kana`](../interfaces/Kana.md) \| [`Grammar`](../interfaces/Grammar.md)
9
+ > **Result** = [`Word`](../interfaces/Word.md) \| [`Name`](../interfaces/Name.md) \| [`Kanji`](../interfaces/Kanji.md) \| [`Radical`](../interfaces/Radical.md) \| [`Kana`](../interfaces/Kana.md) \| [`Grammar`](../interfaces/Grammar.md)
10
10
 
11
- Defined in: [types.ts:959](https://github.com/Ronokof/Henkan/blob/main/src/types.ts#L959)
11
+ Defined in: [types.ts:1059](https://github.com/Ronokof/Henkan/blob/main/src/types.ts#L1059)
12
12
 
13
13
  Any type of converted entry from a [Dict](Dict.md) array + others not from a dictionary
@@ -8,6 +8,6 @@
8
8
 
9
9
  > **WordDefinitionsMap** = `Map`\<[`StringNumber`](StringNumber.md), [`Definition`](../interfaces/Definition.md)[]\>
10
10
 
11
- Defined in: [types.ts:463](https://github.com/Ronokof/Henkan/blob/main/src/types.ts#L463)
11
+ Defined in: [types.ts:517](https://github.com/Ronokof/Henkan/blob/main/src/types.ts#L517)
12
12
 
13
13
  A `JMdict entry ID` ---> `Japanese definitions associated with the JMdict entry` map
@@ -8,6 +8,6 @@
8
8
 
9
9
  > **WordIDEntryMap** = `Map`\<[`StringNumber`](StringNumber.md), [`DictWord`](../interfaces/DictWord.md)\>
10
10
 
11
- Defined in: [types.ts:443](https://github.com/Ronokof/Henkan/blob/main/src/types.ts#L443)
11
+ Defined in: [types.ts:493](https://github.com/Ronokof/Henkan/blob/main/src/types.ts#L493)
12
12
 
13
13
  A `JMdict entry ID` ---> [DictWord](../interfaces/DictWord.md) `object` map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "henkan",
3
- "version": "2.4.12",
4
- "description": "Converter & Simplifier for JMdict, KANJIDIC, KRADFILE2, RADKFILE2 and Tanaka Corpus",
3
+ "version": "3.0.1",
4
+ "description": "Converter & Simplifier for JMdict, JMnedict, KANJIDIC, KRADFILE2, RADKFILE2 and Tanaka Corpus",
5
5
  "keywords": [
6
6
  "fjsd",
7
7
  "japanese",
@@ -15,6 +15,7 @@
15
15
  "kanji",
16
16
  "japanese-grammar",
17
17
  "jmdict",
18
+ "jmnedict",
18
19
  "kanjidic2",
19
20
  "kradfile2",
20
21
  "radkfile2",
@@ -72,17 +73,17 @@
72
73
  },
73
74
  "devDependencies": {
74
75
  "@types/node": "^24.10.9",
75
- "@typescript-eslint/eslint-plugin": "^8.54.0",
76
- "@typescript-eslint/parser": "^8.54.0",
76
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
77
+ "@typescript-eslint/parser": "^8.55.0",
77
78
  "@vitest/coverage-v8": "^4.0.18",
78
79
  "esbuild": "^0.27.3",
79
80
  "eslint": "^9.39.2",
80
81
  "eslint-plugin-import": "^2.32.0",
81
- "eslint-plugin-jsdoc": "^62.5.4",
82
+ "eslint-plugin-jsdoc": "^62.5.5",
82
83
  "eslint-plugin-prettier": "^5.5.5",
83
84
  "prettier": "^3.8.1",
84
- "rimraf": "^6.1.2",
85
- "typedoc": "^0.28.16",
85
+ "rimraf": "^6.1.3",
86
+ "typedoc": "^0.28.17",
86
87
  "typedoc-plugin-markdown": "^4.10.0",
87
88
  "typescript": "^5.9.3",
88
89
  "vitest": "^4.0.18"
package/src/types.ts CHANGED
@@ -47,7 +47,7 @@ export type POS =
47
47
  /**
48
48
  * Standardized dictionary names
49
49
  */
50
- export type DictName = "JMDict" | "Kanjidic" | "tanaka" | "radk" | "krad";
50
+ export type DictNames = "JMDict" | "Kanjidic" | "tanaka" | "radk" | "krad";
51
51
 
52
52
  /**
53
53
  * A number written as a string
@@ -55,9 +55,9 @@ export type DictName = "JMDict" | "Kanjidic" | "tanaka" | "radk" | "krad";
55
55
  export type StringNumber = `${number}`;
56
56
 
57
57
  /**
58
- * Word kanji form information
58
+ * Word/Name kanji form information
59
59
  *
60
- * Equivalent to the `k_ele` JMdict element
60
+ * Equivalent to the `k_ele` JMdict/JMnedict element
61
61
  */
62
62
  export interface DictKanjiForm {
63
63
  /**
@@ -79,9 +79,9 @@ export interface DictKanjiForm {
79
79
  }
80
80
 
81
81
  /**
82
- * Word reading information
82
+ * Word/Name reading information
83
83
  *
84
- * Equivalent to the `r_ele` JMdict element
84
+ * Equivalent to the `r_ele` JMdict/JMnedict element
85
85
  */
86
86
  export interface DictReading {
87
87
  /**
@@ -221,6 +221,56 @@ export interface DictWord {
221
221
  hasPhrases?: true | undefined;
222
222
  }
223
223
 
224
+ /**
225
+ * Name translation information
226
+ *
227
+ * Equivalent to the `trans` JMnedict element
228
+ */
229
+ export interface NeDictMeaning {
230
+ /**
231
+ * Name translations
232
+ */
233
+ translations: string[];
234
+ /**
235
+ * Types of the name
236
+ */
237
+ nameTypes?: string[] | undefined;
238
+ }
239
+
240
+ /**
241
+ * JMnedict entry (name)
242
+ *
243
+ * Equivalent to the `entry` JMnedict element
244
+ */
245
+ export interface DictName {
246
+ /**
247
+ * The entry sequence number
248
+ */
249
+ readonly id: StringNumber;
250
+ /**
251
+ * The name's readings
252
+ */
253
+ nameReadings: DictReading[];
254
+ /**
255
+ * The name's meanings/senses
256
+ */
257
+ meanings: NeDictMeaning[];
258
+ /**
259
+ * The name's kanji forms
260
+ */
261
+ kanjiForms?: DictKanjiForm[] | undefined;
262
+ /**
263
+ * Whether or not the entry has a priority tag (`k_pri` or `r_pri`)
264
+ */
265
+ isCommon?: true | undefined;
266
+ /**
267
+ * Whether or not the entry has at least one Tanaka Corpus phrase associated with it
268
+ *
269
+ * **May not always be accurate**
270
+ */
271
+ hasPhrases?: true | undefined;
272
+ }
273
+
224
274
  /**
225
275
  * Miscellaneous information about the kanji
226
276
  *
@@ -441,6 +491,10 @@ export interface TanakaExample {
441
491
  * A `JMdict entry ID` ---> {@link DictWord} `object` map
442
492
  */
443
493
  export type WordIDEntryMap = Map<StringNumber, DictWord>;
494
+ /**
495
+ * A `JMnedict entry ID` ---> {@link DictName} `object` map
496
+ */
497
+ export type NameIDEntryMap = Map<StringNumber, DictName>;
444
498
  /**
445
499
  * A `KANJIDIC kanji character` ---> {@link DictKanji} `object` map
446
500
  */
@@ -454,9 +508,9 @@ export type KanjiSVGMap = Map<string, string>;
454
508
  */
455
509
  export type KanjiWordsMap = Map<string, DictWord[]>;
456
510
  /**
457
- * A `JMdict entry ID` ---> `Tanaka examples associated with the JMdict entry` map
511
+ * A `JMdict/JMnedict entry ID` ---> `Tanaka examples associated with the JMdict/JMnedict entry` map
458
512
  */
459
- export type WordExamplesMap = Map<StringNumber, TanakaExample[]>;
513
+ export type EntryExamplesMap = Map<StringNumber, TanakaExample[]>;
460
514
  /**
461
515
  * A `JMdict entry ID` ---> `Japanese definitions associated with the JMdict entry` map
462
516
  */
@@ -470,6 +524,10 @@ export interface EntryMaps {
470
524
  * @see {@link WordIDEntryMap}
471
525
  */
472
526
  wordIDEntryMap?: WordIDEntryMap | undefined;
527
+ /**
528
+ * @see {@link NameIDEntryMap}
529
+ */
530
+ nameIDEntryMap?: NameIDEntryMap | undefined;
473
531
  /**
474
532
  * @see {@link KanjiWordsMap}
475
533
  */
@@ -479,9 +537,13 @@ export interface EntryMaps {
479
537
  */
480
538
  kanjiEntryMap?: KanjiEntryMap | undefined;
481
539
  /**
482
- * @see {@link WordExamplesMap}
540
+ * @see {@link EntryExamplesMap}
541
+ */
542
+ wordExamplesMap?: EntryExamplesMap | undefined;
543
+ /**
544
+ * @see {@link EntryExamplesMap}
483
545
  */
484
- wordExamplesMap?: WordExamplesMap | undefined;
546
+ nameExamplesMap?: EntryExamplesMap | undefined;
485
547
  /**
486
548
  * @see {@link WordDefinitionsMap}
487
549
  */
@@ -581,7 +643,13 @@ export type Dict =
581
643
  /**
582
644
  * Names of entry types used for the Anki note IDs
583
645
  */
584
- export type EntryType = "word" | "kanji" | "radical" | "kana" | "grammar";
646
+ export type EntryType =
647
+ | "word"
648
+ | "name"
649
+ | "kanji"
650
+ | "radical"
651
+ | "kana"
652
+ | "grammar";
585
653
 
586
654
  /**
587
655
  * Basic Anki note information
@@ -628,7 +696,7 @@ export interface NoteAndTag {
628
696
  }
629
697
 
630
698
  /**
631
- * A kanji form of the word
699
+ * A kanji form of the word/name
632
700
  *
633
701
  * Converted from a {@link DictKanjiForm}
634
702
  */
@@ -648,7 +716,7 @@ export interface KanjiForm {
648
716
  }
649
717
 
650
718
  /**
651
- * A reading of the word
719
+ * A reading of the word/name
652
720
  *
653
721
  * Converted from {@link DictReading}
654
722
  */
@@ -672,9 +740,9 @@ export interface Reading {
672
740
  }
673
741
 
674
742
  /**
675
- * A translation of the word
743
+ * A translation of the word/name
676
744
  *
677
- * Converted from {@link DictMeaning}
745
+ * Converted from {@link DictMeaning} or {@link NeDictMeaning}
678
746
  */
679
747
  export interface Translation {
680
748
  /**
@@ -879,6 +947,38 @@ export interface Word extends ResultEntry<"word"> {
879
947
  usuallyInKana?: true | undefined;
880
948
  }
881
949
 
950
+ /**
951
+ * Name information
952
+ *
953
+ * Converted from {@link DictName}
954
+ */
955
+ export interface Name extends ResultEntry<"name"> {
956
+ /**
957
+ * The name readings (in kana)
958
+ */
959
+ nameReadings: Reading[];
960
+ /**
961
+ * The name translations
962
+ */
963
+ translations: Translation[];
964
+ /**
965
+ * The name kanji forms
966
+ */
967
+ kanjiForms?: KanjiForm[] | undefined;
968
+ /**
969
+ * A list of kanji used in the kanji forms
970
+ */
971
+ kanji?: Kanji[] | undefined;
972
+ /**
973
+ * Phrases associated to the name
974
+ */
975
+ phrases?: Phrase[] | undefined;
976
+ /**
977
+ * @see {@link DictName.isCommon}
978
+ */
979
+ common?: true | undefined;
980
+ }
981
+
882
982
  /**
883
983
  * Kana information
884
984
  */
@@ -956,7 +1056,7 @@ export interface Grammar extends ResultEntry<"grammar"> {
956
1056
  /**
957
1057
  * Any type of converted entry from a {@link Dict} array + others not from a dictionary
958
1058
  */
959
- export type Result = Word | Kanji | Radical | Kana | Grammar;
1059
+ export type Result = Word | Name | Kanji | Radical | Kana | Grammar;
960
1060
 
961
1061
  /**
962
1062
  * Default note ID, note type and deck name of a note