yomitan-core 0.1.0

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 (207) hide show
  1. package/README.md +485 -0
  2. package/dist/anki-connect-BQyCGW3O.cjs +513 -0
  3. package/dist/anki-connect-BQyCGW3O.cjs.map +1 -0
  4. package/dist/anki-connect-CPPuhyiQ.js +6 -0
  5. package/dist/anki-connect-DbrQHphS.js +495 -0
  6. package/dist/anki-connect-DbrQHphS.js.map +1 -0
  7. package/dist/anki-connect-DcheJrp-.cjs +6 -0
  8. package/dist/anki.cjs +1758 -0
  9. package/dist/anki.cjs.map +1 -0
  10. package/dist/anki.d.cts +751 -0
  11. package/dist/anki.d.cts.map +1 -0
  12. package/dist/anki.d.ts +751 -0
  13. package/dist/anki.d.ts.map +1 -0
  14. package/dist/anki.js +1751 -0
  15. package/dist/anki.js.map +1 -0
  16. package/dist/audio-D9DvYyB7.d.cts +48 -0
  17. package/dist/audio-D9DvYyB7.d.cts.map +1 -0
  18. package/dist/audio-DQulUkDM.d.ts +48 -0
  19. package/dist/audio-DQulUkDM.d.ts.map +1 -0
  20. package/dist/audio-url-generator-BXvQaqUi.cjs +4 -0
  21. package/dist/audio-url-generator-Dy2hb2Mm.cjs +414 -0
  22. package/dist/audio-url-generator-Dy2hb2Mm.cjs.map +1 -0
  23. package/dist/audio-url-generator-Qi0rfzHz.js +4 -0
  24. package/dist/audio-url-generator-pFQAB5Nb.js +390 -0
  25. package/dist/audio-url-generator-pFQAB5Nb.js.map +1 -0
  26. package/dist/audio.cjs +7 -0
  27. package/dist/audio.d.cts +86 -0
  28. package/dist/audio.d.cts.map +1 -0
  29. package/dist/audio.d.ts +86 -0
  30. package/dist/audio.d.ts.map +1 -0
  31. package/dist/audio.js +4 -0
  32. package/dist/batch-processor-BR-gB3H3.js +84 -0
  33. package/dist/batch-processor-BR-gB3H3.js.map +1 -0
  34. package/dist/batch-processor-CSF1acTw.cjs +3 -0
  35. package/dist/batch-processor-DFqM_L-_.cjs +91 -0
  36. package/dist/batch-processor-DFqM_L-_.cjs.map +1 -0
  37. package/dist/batch-processor-Quo9jUyf.js +3 -0
  38. package/dist/chunk-BCwAaXi7.cjs +31 -0
  39. package/dist/cjk-util-Dp0ZU0sh.cjs +167 -0
  40. package/dist/cjk-util-Dp0ZU0sh.cjs.map +1 -0
  41. package/dist/cjk-util-DubXBGDG.js +94 -0
  42. package/dist/cjk-util-DubXBGDG.js.map +1 -0
  43. package/dist/core-BUpclilG.d.cts +102 -0
  44. package/dist/core-BUpclilG.d.cts.map +1 -0
  45. package/dist/core-DFUj5GtA.d.ts +102 -0
  46. package/dist/core-DFUj5GtA.d.ts.map +1 -0
  47. package/dist/database.cjs +7 -0
  48. package/dist/database.d.cts +4 -0
  49. package/dist/database.d.ts +4 -0
  50. package/dist/database.js +5 -0
  51. package/dist/dictionary-D7l-qFt1.d.cts +316 -0
  52. package/dist/dictionary-D7l-qFt1.d.cts.map +1 -0
  53. package/dist/dictionary-_vzfBLWi.d.ts +316 -0
  54. package/dist/dictionary-_vzfBLWi.d.ts.map +1 -0
  55. package/dist/dictionary-data-util-CHnRdYZ9.cjs +378 -0
  56. package/dist/dictionary-data-util-CHnRdYZ9.cjs.map +1 -0
  57. package/dist/dictionary-data-util-CfOLfEDE.js +323 -0
  58. package/dist/dictionary-data-util-CfOLfEDE.js.map +1 -0
  59. package/dist/dictionary-database-BDC2f9zc.d.ts +58 -0
  60. package/dist/dictionary-database-BDC2f9zc.d.ts.map +1 -0
  61. package/dist/dictionary-database-CU4TsvCC.js +393 -0
  62. package/dist/dictionary-database-CU4TsvCC.js.map +1 -0
  63. package/dist/dictionary-database-DsOi04Sg.d.cts +58 -0
  64. package/dist/dictionary-database-DsOi04Sg.d.cts.map +1 -0
  65. package/dist/dictionary-database-lvFvftnO.cjs +412 -0
  66. package/dist/dictionary-database-lvFvftnO.cjs.map +1 -0
  67. package/dist/dictionary-importer-BkQQSBhm.d.ts +237 -0
  68. package/dist/dictionary-importer-BkQQSBhm.d.ts.map +1 -0
  69. package/dist/dictionary-importer-Cen1z6co.js +1821 -0
  70. package/dist/dictionary-importer-Cen1z6co.js.map +1 -0
  71. package/dist/dictionary-importer-DYmmWmcX.cjs +8 -0
  72. package/dist/dictionary-importer-Da3AuTZw.d.cts +237 -0
  73. package/dist/dictionary-importer-Da3AuTZw.d.cts.map +1 -0
  74. package/dist/dictionary-importer-Dhn75iZ4.cjs +1834 -0
  75. package/dist/dictionary-importer-Dhn75iZ4.cjs.map +1 -0
  76. package/dist/dictionary-importer-xWkel0h-.js +8 -0
  77. package/dist/dictionary-update-checker-BNE4pGTx.js +4 -0
  78. package/dist/dictionary-update-checker-Byjvifd2.cjs +75 -0
  79. package/dist/dictionary-update-checker-Byjvifd2.cjs.map +1 -0
  80. package/dist/dictionary-update-checker-YdpalZ41.cjs +4 -0
  81. package/dist/dictionary-update-checker-kKukiovj.js +69 -0
  82. package/dist/dictionary-update-checker-kKukiovj.js.map +1 -0
  83. package/dist/display-generator-BGVWiI0t.js +746 -0
  84. package/dist/display-generator-BGVWiI0t.js.map +1 -0
  85. package/dist/display-generator-BMQmG5Ov.cjs +9 -0
  86. package/dist/display-generator-BxZ7mBjP.js +9 -0
  87. package/dist/display-generator-DyP-HNzP.cjs +758 -0
  88. package/dist/display-generator-DyP-HNzP.cjs.map +1 -0
  89. package/dist/errors-BSezaJwm.cjs +35 -0
  90. package/dist/errors-BSezaJwm.cjs.map +1 -0
  91. package/dist/errors-DuuDSO5N.js +22 -0
  92. package/dist/errors-DuuDSO5N.js.map +1 -0
  93. package/dist/frequency-ranking-BXjfhhUQ.js +3 -0
  94. package/dist/frequency-ranking-Cx1kkIrw.cjs +3 -0
  95. package/dist/frequency-ranking-DEJMTMdg.js +159 -0
  96. package/dist/frequency-ranking-DEJMTMdg.js.map +1 -0
  97. package/dist/frequency-ranking-DVYxTXN-.cjs +166 -0
  98. package/dist/frequency-ranking-DVYxTXN-.cjs.map +1 -0
  99. package/dist/furigana-5HK97CY8.js +4 -0
  100. package/dist/furigana-9bBI9-qe.d.ts +47 -0
  101. package/dist/furigana-9bBI9-qe.d.ts.map +1 -0
  102. package/dist/furigana-B3-0y231.js +471 -0
  103. package/dist/furigana-B3-0y231.js.map +1 -0
  104. package/dist/furigana-CjOhzvZt.d.cts +47 -0
  105. package/dist/furigana-CjOhzvZt.d.cts.map +1 -0
  106. package/dist/furigana-DpZLcues.cjs +609 -0
  107. package/dist/furigana-DpZLcues.cjs.map +1 -0
  108. package/dist/furigana-h3v2ub4-.cjs +4 -0
  109. package/dist/import.cjs +12 -0
  110. package/dist/import.d.cts +107 -0
  111. package/dist/import.d.cts.map +1 -0
  112. package/dist/import.d.ts +107 -0
  113. package/dist/import.d.ts.map +1 -0
  114. package/dist/import.js +9 -0
  115. package/dist/index.cjs +275 -0
  116. package/dist/index.cjs.map +1 -0
  117. package/dist/index.d.cts +211 -0
  118. package/dist/index.d.cts.map +1 -0
  119. package/dist/index.d.ts +211 -0
  120. package/dist/index.d.ts.map +1 -0
  121. package/dist/index.js +238 -0
  122. package/dist/index.js.map +1 -0
  123. package/dist/json-DGd-cunA.js +17 -0
  124. package/dist/json-DGd-cunA.js.map +1 -0
  125. package/dist/json-DKWp-B7Y.cjs +30 -0
  126. package/dist/json-DKWp-B7Y.cjs.map +1 -0
  127. package/dist/language-KN_u-nTR.d.ts +104 -0
  128. package/dist/language-KN_u-nTR.d.ts.map +1 -0
  129. package/dist/language-xAbQxgXc.d.cts +104 -0
  130. package/dist/language-xAbQxgXc.d.cts.map +1 -0
  131. package/dist/language.cjs +15626 -0
  132. package/dist/language.cjs.map +1 -0
  133. package/dist/language.d.cts +959 -0
  134. package/dist/language.d.cts.map +1 -0
  135. package/dist/language.d.ts +959 -0
  136. package/dist/language.d.ts.map +1 -0
  137. package/dist/language.js +15522 -0
  138. package/dist/language.js.map +1 -0
  139. package/dist/log-D8KtR3aP.cjs +67 -0
  140. package/dist/log-D8KtR3aP.cjs.map +1 -0
  141. package/dist/log-hgSll-dS.js +60 -0
  142. package/dist/log-hgSll-dS.js.map +1 -0
  143. package/dist/lookup.cjs +13 -0
  144. package/dist/lookup.d.cts +161 -0
  145. package/dist/lookup.d.cts.map +1 -0
  146. package/dist/lookup.d.ts +161 -0
  147. package/dist/lookup.d.ts.map +1 -0
  148. package/dist/lookup.js +10 -0
  149. package/dist/media-loader-BABA_E4W.js +3 -0
  150. package/dist/media-loader-Ce9cuANS.cjs +21 -0
  151. package/dist/media-loader-Ce9cuANS.cjs.map +1 -0
  152. package/dist/media-loader-qRti-Q6h.js +14 -0
  153. package/dist/media-loader-qRti-Q6h.js.map +1 -0
  154. package/dist/media-loader-xlUGaJrx.cjs +3 -0
  155. package/dist/multi-language-transformer-AlxOM6b3.js +637 -0
  156. package/dist/multi-language-transformer-AlxOM6b3.js.map +1 -0
  157. package/dist/multi-language-transformer-MdbQBBOt.cjs +685 -0
  158. package/dist/multi-language-transformer-MdbQBBOt.cjs.map +1 -0
  159. package/dist/multi-language-transformer-SEhcJXEB.d.ts +63 -0
  160. package/dist/multi-language-transformer-SEhcJXEB.d.ts.map +1 -0
  161. package/dist/multi-language-transformer-Ul9mbRce.d.cts +63 -0
  162. package/dist/multi-language-transformer-Ul9mbRce.d.cts.map +1 -0
  163. package/dist/pronunciation-generator-BtBc4q_V.js +397 -0
  164. package/dist/pronunciation-generator-BtBc4q_V.js.map +1 -0
  165. package/dist/pronunciation-generator-CBYdXYou.js +4 -0
  166. package/dist/pronunciation-generator-CFbZlf5J.cjs +445 -0
  167. package/dist/pronunciation-generator-CFbZlf5J.cjs.map +1 -0
  168. package/dist/pronunciation-generator-DOz9hEuk.cjs +4 -0
  169. package/dist/render.cjs +2796 -0
  170. package/dist/render.cjs.map +1 -0
  171. package/dist/render.d.cts +424 -0
  172. package/dist/render.d.cts.map +1 -0
  173. package/dist/render.d.ts +424 -0
  174. package/dist/render.d.ts.map +1 -0
  175. package/dist/render.js +2777 -0
  176. package/dist/render.js.map +1 -0
  177. package/dist/sentence-parser-BPAJNzqW.js +126 -0
  178. package/dist/sentence-parser-BPAJNzqW.js.map +1 -0
  179. package/dist/sentence-parser-BVIOI64h.cjs +132 -0
  180. package/dist/sentence-parser-BVIOI64h.cjs.map +1 -0
  181. package/dist/sentence-parser-BoHO3cHn.js +5 -0
  182. package/dist/sentence-parser-DQVLSW0z.cjs +5 -0
  183. package/dist/structured-content-generator-BtOApkTW.cjs +4 -0
  184. package/dist/structured-content-generator-Bx62RYa8.js +4 -0
  185. package/dist/structured-content-generator-CLnybumI.js +276 -0
  186. package/dist/structured-content-generator-CLnybumI.js.map +1 -0
  187. package/dist/structured-content-generator-DrwkB0-k.cjs +282 -0
  188. package/dist/structured-content-generator-DrwkB0-k.cjs.map +1 -0
  189. package/dist/text-utilities-B7PIythe.js +8 -0
  190. package/dist/text-utilities-B7PIythe.js.map +1 -0
  191. package/dist/text-utilities-Del2Ivkg.cjs +15 -0
  192. package/dist/text-utilities-Del2Ivkg.cjs.map +1 -0
  193. package/dist/translator-CRPlPzqi.cjs +1545 -0
  194. package/dist/translator-CRPlPzqi.cjs.map +1 -0
  195. package/dist/translator-CWgG5drA.js +1539 -0
  196. package/dist/translator-CWgG5drA.js.map +1 -0
  197. package/dist/translator-CaGtJvnQ.cjs +6 -0
  198. package/dist/translator-Cc6OGxrW.d.ts +180 -0
  199. package/dist/translator-Cc6OGxrW.d.ts.map +1 -0
  200. package/dist/translator-CcA-s-W4.d.cts +180 -0
  201. package/dist/translator-CcA-s-W4.d.cts.map +1 -0
  202. package/dist/translator-CuJOTK6l.js +6 -0
  203. package/dist/utilities-C-lbZaJE.cjs +52 -0
  204. package/dist/utilities-C-lbZaJE.cjs.map +1 -0
  205. package/dist/utilities-bi3EF-q5.js +33 -0
  206. package/dist/utilities-bi3EF-q5.js.map +1 -0
  207. package/package.json +102 -0
@@ -0,0 +1,316 @@
1
+ //#region src/types/structured-content.d.ts
2
+ type VerticalAlign = 'baseline' | 'sub' | 'super' | 'text-top' | 'text-bottom' | 'middle' | 'top' | 'bottom';
3
+ type TextDecorationLine = 'underline' | 'overline' | 'line-through';
4
+ type TextDecorationLineOrNone = 'none' | TextDecorationLine;
5
+ type TextDecorationStyle = 'solid' | 'double' | 'dotted' | 'dashed' | 'wavy';
6
+ type FontStyle = 'normal' | 'italic';
7
+ type FontWeight = 'normal' | 'bold';
8
+ type WordBreak = 'normal' | 'break-all' | 'keep-all';
9
+ type TextAlign = 'start' | 'end' | 'left' | 'right' | 'center' | 'justify' | 'justify-all' | 'match-parent';
10
+ type SizeUnits = 'px' | 'em';
11
+ type ImageRendering = 'auto' | 'pixelated' | 'crisp-edges';
12
+ type ImageAppearance = 'auto' | 'monochrome';
13
+ type Image = TermImage & {
14
+ verticalAlign: VerticalAlign;
15
+ border: string;
16
+ borderRadius: string;
17
+ sizeUnits: SizeUnits;
18
+ };
19
+ type Data = {
20
+ [key: string]: string;
21
+ };
22
+ type StructuredContentStyle = {
23
+ fontStyle?: FontStyle;
24
+ fontWeight?: FontWeight;
25
+ fontSize?: string;
26
+ color?: string;
27
+ background?: string;
28
+ backgroundColor?: string;
29
+ textDecorationLine?: TextDecorationLineOrNone | TextDecorationLine[];
30
+ textDecorationStyle?: TextDecorationStyle;
31
+ textDecorationColor?: string;
32
+ borderColor?: string;
33
+ borderStyle?: string;
34
+ borderRadius?: string;
35
+ borderWidth?: string;
36
+ clipPath?: string;
37
+ verticalAlign?: VerticalAlign;
38
+ textAlign?: TextAlign;
39
+ textEmphasis?: string;
40
+ textShadow?: string;
41
+ margin?: string;
42
+ marginTop?: number | string;
43
+ marginLeft?: number | string;
44
+ marginRight?: number | string;
45
+ marginBottom?: number | string;
46
+ padding?: string;
47
+ paddingTop?: string;
48
+ paddingLeft?: string;
49
+ paddingRight?: string;
50
+ paddingBottom?: string;
51
+ wordBreak?: WordBreak;
52
+ whiteSpace?: string;
53
+ cursor?: string;
54
+ listStyleType?: string;
55
+ };
56
+ type LineBreak = {
57
+ tag: 'br';
58
+ data?: Data;
59
+ content?: undefined;
60
+ lang?: undefined;
61
+ };
62
+ type UnstyledElement = {
63
+ tag: 'ruby' | 'rt' | 'rp' | 'table' | 'thead' | 'tbody' | 'tfoot' | 'tr';
64
+ content?: Content;
65
+ data?: Data;
66
+ lang?: string;
67
+ };
68
+ type TableElement = {
69
+ tag: 'td' | 'th';
70
+ content?: Content;
71
+ data?: Data;
72
+ colSpan?: number;
73
+ rowSpan?: number;
74
+ style?: StructuredContentStyle;
75
+ lang?: string;
76
+ };
77
+ type StyledElement = {
78
+ tag: 'span' | 'div' | 'ol' | 'ul' | 'li' | 'details' | 'summary';
79
+ content?: Content;
80
+ data?: Data;
81
+ style?: StructuredContentStyle;
82
+ title?: string;
83
+ open?: boolean;
84
+ lang?: string;
85
+ };
86
+ type ImageElementBase = {
87
+ data?: Data;
88
+ path: string;
89
+ width?: number;
90
+ height?: number;
91
+ preferredWidth?: number;
92
+ preferredHeight?: number;
93
+ title?: string;
94
+ alt?: string;
95
+ description?: string;
96
+ pixelated?: boolean;
97
+ imageRendering?: ImageRendering;
98
+ appearance?: ImageAppearance;
99
+ background?: boolean;
100
+ collapsed?: boolean;
101
+ collapsible?: boolean;
102
+ };
103
+ type ImageElement = ImageElementBase & {
104
+ tag: 'img';
105
+ content?: undefined;
106
+ verticalAlign?: VerticalAlign;
107
+ border?: string;
108
+ borderRadius?: string;
109
+ sizeUnits?: SizeUnits;
110
+ };
111
+ type LinkElement = {
112
+ tag: 'a';
113
+ content?: Content;
114
+ href: string;
115
+ lang?: string;
116
+ };
117
+ type Element = LineBreak | UnstyledElement | TableElement | StyledElement | ImageElement | LinkElement;
118
+ type Content = string | Element | Content[]; //#endregion
119
+ //#region src/types/dictionary-data.d.ts
120
+
121
+ //# sourceMappingURL=structured-content.d.ts.map
122
+ type TermGlossary = TermGlossaryContent | TermGlossaryDeinflection;
123
+ type TermGlossaryContent = TermGlossaryString | TermGlossaryText | TermGlossaryImage | TermGlossaryStructuredContent;
124
+ type TermGlossaryString = string;
125
+ type TermGlossaryText = {
126
+ type: 'text';
127
+ text: string;
128
+ };
129
+ type TermGlossaryImage = {
130
+ type: 'image';
131
+ } & TermImage;
132
+ type TermGlossaryStructuredContent = {
133
+ type: 'structured-content';
134
+ content: Content;
135
+ };
136
+ type TermGlossaryDeinflection = [uninflected: string, inflectionRuleChain: string[]];
137
+ type TermImage = ImageElementBase & {
138
+ verticalAlign?: undefined;
139
+ border?: undefined;
140
+ borderRadius?: undefined;
141
+ sizeUnits?: undefined;
142
+ };
143
+ type GenericFrequencyData = string | number | {
144
+ value: number;
145
+ displayValue?: string;
146
+ reading?: undefined;
147
+ };
148
+ type TermMetaFrequencyDataWithReading = {
149
+ reading: string;
150
+ frequency: GenericFrequencyData;
151
+ };
152
+ type TermMetaPitchData = {
153
+ reading: string;
154
+ pitches: {
155
+ position: number | string;
156
+ nasal?: number | number[];
157
+ devoice?: number | number[];
158
+ tags?: string[];
159
+ }[];
160
+ };
161
+ type TermMetaPhoneticData = {
162
+ reading: string;
163
+ transcriptions: {
164
+ ipa: string;
165
+ tags?: string[];
166
+ }[];
167
+ }; //#endregion
168
+ //#region src/types/dictionary.d.ts
169
+ type DictionaryEntry = KanjiDictionaryEntry | TermDictionaryEntry;
170
+ type DictionaryEntryType = DictionaryEntry['type'];
171
+ type Tag = {
172
+ name: string;
173
+ category: string;
174
+ order: number;
175
+ score: number;
176
+ content: string[];
177
+ dictionaries: string[];
178
+ redundant: boolean;
179
+ };
180
+ type KanjiDictionaryEntry = {
181
+ type: 'kanji';
182
+ character: string;
183
+ dictionary: string;
184
+ dictionaryIndex: number;
185
+ dictionaryAlias: string;
186
+ onyomi: string[];
187
+ kunyomi: string[];
188
+ tags: Tag[];
189
+ stats: KanjiStatGroups;
190
+ definitions: string[];
191
+ frequencies: KanjiFrequency[];
192
+ };
193
+ type KanjiStatGroups = {
194
+ [propName: string]: KanjiStat[];
195
+ };
196
+ type KanjiStat = {
197
+ name: string;
198
+ category: string;
199
+ content: string;
200
+ order: number;
201
+ score: number;
202
+ dictionary: string;
203
+ value: number | string;
204
+ };
205
+ type KanjiFrequency = {
206
+ index: number;
207
+ dictionary: string;
208
+ dictionaryIndex: number;
209
+ dictionaryAlias: string;
210
+ character: string;
211
+ frequency: number;
212
+ displayValue: string | null;
213
+ displayValueParsed: boolean;
214
+ };
215
+ type TermDictionaryEntry = {
216
+ type: 'term';
217
+ isPrimary: boolean;
218
+ textProcessorRuleChainCandidates: TextProcessorRuleChainCandidate[];
219
+ inflectionRuleChainCandidates: InflectionRuleChainCandidate[];
220
+ score: number;
221
+ frequencyOrder: number;
222
+ dictionaryIndex: number;
223
+ dictionaryAlias: string;
224
+ sourceTermExactMatchCount: number;
225
+ matchPrimaryReading: boolean;
226
+ maxOriginalTextLength: number;
227
+ headwords: TermHeadword[];
228
+ definitions: TermDefinition[];
229
+ pronunciations: TermPronunciation[];
230
+ frequencies: TermFrequency[];
231
+ };
232
+ type InflectionRuleChainCandidate = {
233
+ source: InflectionSource;
234
+ inflectionRules: InflectionRuleChain;
235
+ };
236
+ type TextProcessorRuleChainCandidate = string[];
237
+ type InflectionRuleChain = InflectionRule[];
238
+ type InflectionRule = {
239
+ name: string;
240
+ description?: string;
241
+ };
242
+ type InflectionSource = 'algorithm' | 'dictionary' | 'both';
243
+ type TermHeadword = {
244
+ index: number;
245
+ term: string;
246
+ reading: string;
247
+ sources: TermSource[];
248
+ tags: Tag[];
249
+ wordClasses: string[];
250
+ };
251
+ type TermDefinition = {
252
+ index: number;
253
+ headwordIndices: number[];
254
+ dictionary: string;
255
+ dictionaryIndex: number;
256
+ dictionaryAlias: string;
257
+ id: number;
258
+ score: number;
259
+ frequencyOrder: number;
260
+ sequences: number[];
261
+ isPrimary: boolean;
262
+ tags: Tag[];
263
+ entries: TermGlossaryContent[];
264
+ };
265
+ type TermPronunciation = {
266
+ index: number;
267
+ headwordIndex: number;
268
+ dictionary: string;
269
+ dictionaryIndex: number;
270
+ dictionaryAlias: string;
271
+ pronunciations: Pronunciation[];
272
+ };
273
+ type Pronunciation = PitchAccent | PhoneticTranscription;
274
+ type PitchAccent = {
275
+ type: 'pitch-accent';
276
+ positions: number | string;
277
+ nasalPositions: number[];
278
+ devoicePositions: number[];
279
+ tags: Tag[];
280
+ };
281
+ type PhoneticTranscription = {
282
+ type: 'phonetic-transcription';
283
+ ipa: string;
284
+ tags: Tag[];
285
+ };
286
+ type PronunciationType = Pronunciation['type'];
287
+ type PronunciationGeneric<T extends PronunciationType> = Extract<Pronunciation, {
288
+ type: T;
289
+ }>;
290
+ type TermFrequency = {
291
+ index: number;
292
+ headwordIndex: number;
293
+ dictionary: string;
294
+ dictionaryIndex: number;
295
+ dictionaryAlias: string;
296
+ hasReading: boolean;
297
+ frequency: number;
298
+ displayValue: string | null;
299
+ displayValueParsed: boolean;
300
+ };
301
+ type TermSourceMatchType = 'exact' | 'prefix' | 'suffix';
302
+ type TermSourceMatchSource = 'term' | 'reading' | 'sequence';
303
+ type TermSource = {
304
+ originalText: string;
305
+ transformedText: string;
306
+ deinflectedText: string;
307
+ matchType: TermSourceMatchType;
308
+ matchSource: TermSourceMatchSource;
309
+ isPrimary: boolean;
310
+ };
311
+
312
+ //#endregion
313
+ //# sourceMappingURL=dictionary.d.ts.map
314
+
315
+ export { Content, Data, DictionaryEntry, DictionaryEntryType, Element, FontStyle, FontWeight, GenericFrequencyData, Image, ImageAppearance, ImageElement, ImageElementBase, ImageRendering, InflectionRule, InflectionRuleChain, InflectionRuleChainCandidate, InflectionSource, KanjiDictionaryEntry, KanjiFrequency, KanjiStat, KanjiStatGroups, LineBreak, LinkElement, PhoneticTranscription, PitchAccent, Pronunciation, PronunciationGeneric, PronunciationType, SizeUnits, StructuredContentStyle, StyledElement, TableElement, Tag, TermDefinition, TermDictionaryEntry, TermFrequency, TermGlossary, TermGlossaryContent, TermGlossaryImage, TermHeadword, TermMetaFrequencyDataWithReading, TermMetaPhoneticData, TermMetaPitchData, TermPronunciation, TermSource, TermSourceMatchSource, TermSourceMatchType, TextAlign, TextDecorationLine, TextDecorationLineOrNone, TextDecorationStyle, TextProcessorRuleChainCandidate, UnstyledElement, VerticalAlign, WordBreak };
316
+ //# sourceMappingURL=dictionary-_vzfBLWi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dictionary-_vzfBLWi.d.ts","names":[],"sources":["../src/types/structured-content.ts","../src/types/dictionary-data.ts","../src/types/dictionary.ts"],"sourcesContent":null,"mappings":";AAEY,KAAA,aAAA,GAAa,UAAA,GAAA,KAAA,GAAA,OAAA,GAAA,UAAA,GAAA,aAAA,GAAA,QAAA,GAAA,KAAA,GAAA,QAAA;AACb,KAAA,kBAAA,GAAkB,WAAA,GAAA,UAAA,GAAA,cAAA;AAClB,KAAA,wBAAA,GAAwB,MAAY,GAAA,kBAAkB;AACtD,KAAA,mBAAA,GAAmB,OAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,MAAA;AACnB,KAAA,SAAA,GAAS,QAAA,GAAA,QAAA;AACT,KAAA,UAAA,GAAU,QAAA,GAAA,MAAA;AACV,KAAA,SAAA,GAAS,QAAA,GAAA,WAAA,GAAA,UAAA;AACT,KAAA,SAAA,GAAS,OAAA,GAAA,KAAA,GAAA,MAAA,GAAA,OAAA,GAAA,QAAA,GAAA,SAAA,GAAA,aAAA,GAAA,cAAA;AACT,KAAA,SAAA,GAAS,IAAA,GAAA,IAAA;AACT,KAAA,cAAA,GAAc,MAAA,GAAA,WAAA,GAAA,aAAA;AACd,KAAA,eAAA,GAAe,MAAA,GAAA,YAAA;AAEf,KAAA,KAAA,GAAQ,SAAH,GAAA;EAAA,aAAA,EACE,aADF;EAAA,MAAG,EAAA,MAAA;EAAS,YACV,EAAA,MAAA;EAAa,SAGjB,EAAA,SAAA;AAAS,CAAA;AAGZ,KAAA,IAAA,GAAI;EAIJ,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,MAAA;CAAsB;AAClB,KADJ,sBAAA,GACI;EAAS,SACR,CAAA,EADD,SACC;EAAU,UA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AAA,GAnFuB;EAA4B,KAQhD,EAAA,MAAA;EAAY,aACV,EAAA,MAAA;EAAc,UACX,EAAA,MAAA;EAAiB,eACpB,EAAA,MAAA;EAAa,eAAA,EAAA,MAAA;EAGlB,UAAA,EAAA,OAAA;EAA4B,SAAA,EAAA,MAAA;EAAA,YAC5B,EAAA,MAAA,GAAA,IAAA;EAAgB,kBACP,EAAA,OAAA;AAAmB,CAAA;AAG5B,KA4EA,mBAAA,GA5EA,OAA+B,GAAA,QAAA,GAAA,QAAA;AAE/B,KA4EA,qBAAA,GA5EmB,MAAG,GAAA,SAAc,GAAA,UAAA;AAEpC,KA4EA,UAAA,GA5Ec;EAKd,YAAA,EAAA,MAAgB;EAEhB,eAAY,EAAA,MAAA;EAAA,eAAA,EAAA,MAAA;EAAA,SAIX,EAqEE,mBArEF;EAAU,WACb,EAqEO,qBArEP;EAAG,SAAA,EAAA,OAAA;AAIb,CAAA"}
@@ -0,0 +1,378 @@
1
+ "use strict";
2
+
3
+ //#region src/util/dictionary-data-util.ts
4
+ /**
5
+ * Computes the harmonic mean of frequency values for a given headword in a dictionary entry.
6
+ */
7
+ function getFrequencyHarmonic(dictionaryEntry, headwordIndex) {
8
+ const dominated = dictionaryEntry.frequencies.filter((f) => f.headwordIndex === headwordIndex).map((f) => f.frequency);
9
+ if (dominated.length === 0) return 0;
10
+ let sum = 0;
11
+ for (const freq of dominated) {
12
+ if (freq <= 0) continue;
13
+ sum += 1 / freq;
14
+ }
15
+ return sum > 0 ? Math.round(dominated.length / sum) : 0;
16
+ }
17
+ function groupTermTags(dictionaryEntry) {
18
+ const { headwords } = dictionaryEntry;
19
+ const headwordCount = headwords.length;
20
+ const uniqueCheck = headwordCount > 1;
21
+ const resultsIndexMap = new Map();
22
+ const results = [];
23
+ for (let i = 0; i < headwordCount; ++i) {
24
+ const { tags } = headwords[i];
25
+ for (const tag of tags) {
26
+ if (uniqueCheck) {
27
+ const { name, category, content, dictionaries } = tag;
28
+ const key = createMapKey([
29
+ name,
30
+ category,
31
+ content,
32
+ dictionaries
33
+ ]);
34
+ const index = resultsIndexMap.get(key);
35
+ if (typeof index !== "undefined") {
36
+ results[index].headwordIndices.push(i);
37
+ continue;
38
+ }
39
+ resultsIndexMap.set(key, results.length);
40
+ }
41
+ results.push({
42
+ tag,
43
+ headwordIndices: [i]
44
+ });
45
+ }
46
+ }
47
+ return results;
48
+ }
49
+ function groupTermFrequencies(dictionaryEntry, dictionaryInfo) {
50
+ const { headwords, frequencies: sourceFrequencies } = dictionaryEntry;
51
+ const map1 = new Map();
52
+ const aliasMap = new Map();
53
+ for (const { headwordIndex, dictionary, dictionaryAlias, hasReading, frequency, displayValue } of sourceFrequencies) {
54
+ const { term, reading } = headwords[headwordIndex];
55
+ let map2 = map1.get(dictionary);
56
+ if (typeof map2 === "undefined") {
57
+ map2 = new Map();
58
+ map1.set(dictionary, map2);
59
+ aliasMap.set(dictionary, dictionaryAlias);
60
+ }
61
+ const readingKey = hasReading ? reading : null;
62
+ const key = createMapKey([term, readingKey]);
63
+ let frequencyData = map2.get(key);
64
+ if (typeof frequencyData === "undefined") {
65
+ frequencyData = {
66
+ term,
67
+ reading: readingKey,
68
+ values: new Map()
69
+ };
70
+ map2.set(key, frequencyData);
71
+ }
72
+ frequencyData.values.set(createMapKey([frequency, displayValue]), {
73
+ frequency,
74
+ displayValue
75
+ });
76
+ }
77
+ const results = [];
78
+ for (const [dictionary, map2] of map1.entries()) {
79
+ const frequencies = [];
80
+ const dictionaryAlias = aliasMap.get(dictionary) ?? dictionary;
81
+ for (const { term, reading, values } of map2.values()) frequencies.push({
82
+ term,
83
+ reading,
84
+ values: [...values.values()]
85
+ });
86
+ const currentDictionaryInfo = dictionaryInfo.find(({ title }) => title === dictionary);
87
+ const freqCount = currentDictionaryInfo?.counts?.termMeta.freq ?? 0;
88
+ results.push({
89
+ dictionary,
90
+ frequencies,
91
+ dictionaryAlias,
92
+ freqCount
93
+ });
94
+ }
95
+ const averageFrequencies = [];
96
+ for (let i = 0; i < dictionaryEntry.headwords.length; i++) {
97
+ const averageFrequency = getFrequencyHarmonic(dictionaryEntry, i);
98
+ averageFrequencies.push({
99
+ term: dictionaryEntry.headwords[i].term,
100
+ reading: dictionaryEntry.headwords[i].reading,
101
+ values: [{
102
+ frequency: averageFrequency,
103
+ displayValue: averageFrequency.toString()
104
+ }]
105
+ });
106
+ }
107
+ results.push({
108
+ dictionary: "Average",
109
+ frequencies: averageFrequencies,
110
+ dictionaryAlias: "Average",
111
+ freqCount: averageFrequencies.length
112
+ });
113
+ return results;
114
+ }
115
+ function groupKanjiFrequencies(sourceFrequencies, dictionaryInfo) {
116
+ const map1 = new Map();
117
+ const aliasMap = new Map();
118
+ for (const { dictionary, dictionaryAlias, character, frequency, displayValue } of sourceFrequencies) {
119
+ let map2 = map1.get(dictionary);
120
+ if (typeof map2 === "undefined") {
121
+ map2 = new Map();
122
+ map1.set(dictionary, map2);
123
+ aliasMap.set(dictionary, dictionaryAlias);
124
+ }
125
+ let frequencyData = map2.get(character);
126
+ if (typeof frequencyData === "undefined") {
127
+ frequencyData = {
128
+ character,
129
+ values: new Map()
130
+ };
131
+ map2.set(character, frequencyData);
132
+ }
133
+ frequencyData.values.set(createMapKey([frequency, displayValue]), {
134
+ frequency,
135
+ displayValue
136
+ });
137
+ }
138
+ const results = [];
139
+ for (const [dictionary, map2] of map1.entries()) {
140
+ const frequencies = [];
141
+ const dictionaryAlias = aliasMap.get(dictionary) ?? dictionary;
142
+ for (const { character, values } of map2.values()) frequencies.push({
143
+ character,
144
+ values: [...values.values()]
145
+ });
146
+ const currentDictionaryInfo = dictionaryInfo.find(({ title }) => title === dictionary);
147
+ const freqCount = currentDictionaryInfo?.counts?.kanjiMeta.freq ?? 0;
148
+ results.push({
149
+ dictionary,
150
+ frequencies,
151
+ dictionaryAlias,
152
+ freqCount
153
+ });
154
+ }
155
+ return results;
156
+ }
157
+ function getGroupedPronunciations(dictionaryEntry) {
158
+ const { headwords, pronunciations: termPronunciations } = dictionaryEntry;
159
+ const allTerms = new Set();
160
+ const allReadings = new Set();
161
+ const aliasMap = new Map();
162
+ for (const { term, reading } of headwords) {
163
+ allTerms.add(term);
164
+ allReadings.add(reading);
165
+ }
166
+ const groupedPronunciationsMap = new Map();
167
+ for (const { headwordIndex, dictionary, dictionaryAlias, pronunciations } of termPronunciations) {
168
+ const { term, reading } = headwords[headwordIndex];
169
+ let dictionaryGroupedPronunciationList = groupedPronunciationsMap.get(dictionary);
170
+ if (typeof dictionaryGroupedPronunciationList === "undefined") {
171
+ dictionaryGroupedPronunciationList = [];
172
+ groupedPronunciationsMap.set(dictionary, dictionaryGroupedPronunciationList);
173
+ aliasMap.set(dictionary, dictionaryAlias);
174
+ }
175
+ for (const pronunciation of pronunciations) {
176
+ let groupedPronunciation = findExistingGroupedPronunciation(reading, pronunciation, dictionaryGroupedPronunciationList);
177
+ if (groupedPronunciation === null) {
178
+ groupedPronunciation = {
179
+ pronunciation,
180
+ terms: new Set(),
181
+ reading
182
+ };
183
+ dictionaryGroupedPronunciationList.push(groupedPronunciation);
184
+ }
185
+ groupedPronunciation.terms.add(term);
186
+ }
187
+ }
188
+ const results = [];
189
+ const multipleReadings = allReadings.size > 1;
190
+ for (const [dictionary, dictionaryGroupedPronunciationList] of groupedPronunciationsMap.entries()) {
191
+ const pronunciations2 = [];
192
+ const dictionaryAlias = aliasMap.get(dictionary) ?? dictionary;
193
+ for (const groupedPronunciation of dictionaryGroupedPronunciationList) {
194
+ const { pronunciation, terms, reading } = groupedPronunciation;
195
+ const exclusiveTerms = !areSetsEqual(terms, allTerms) ? getSetIntersection(terms, allTerms) : [];
196
+ const exclusiveReadings = [];
197
+ if (multipleReadings) exclusiveReadings.push(reading);
198
+ pronunciations2.push({
199
+ pronunciation,
200
+ terms: [...terms],
201
+ reading,
202
+ exclusiveTerms,
203
+ exclusiveReadings
204
+ });
205
+ }
206
+ results.push({
207
+ dictionary,
208
+ dictionaryAlias,
209
+ pronunciations: pronunciations2
210
+ });
211
+ }
212
+ return results;
213
+ }
214
+ function getPronunciationsOfType(pronunciations, type) {
215
+ const results = [];
216
+ for (const pronunciation of pronunciations) if (pronunciation.type === type) results.push(pronunciation);
217
+ return results;
218
+ }
219
+ function getTermFrequency(termTags) {
220
+ let totalScore = 0;
221
+ for (const { score } of termTags) totalScore += score;
222
+ if (totalScore > 0) return "popular";
223
+ if (totalScore < 0) return "rare";
224
+ return "normal";
225
+ }
226
+ function getDisambiguations(headwords, headwordIndices, allTermsSet, allReadingsSet) {
227
+ if (allTermsSet.size <= 1 && allReadingsSet.size <= 1) return [];
228
+ const terms = new Set();
229
+ const readings = new Set();
230
+ for (const headwordIndex of headwordIndices) {
231
+ const { term, reading } = headwords[headwordIndex];
232
+ terms.add(term);
233
+ readings.add(reading);
234
+ }
235
+ const disambiguations = [];
236
+ const addTerms = !areSetsEqual(terms, allTermsSet);
237
+ const addReadings = !areSetsEqual(readings, allReadingsSet);
238
+ if (addTerms) disambiguations.push(...getSetIntersection(terms, allTermsSet));
239
+ if (addReadings) {
240
+ if (addTerms) for (const term of terms) readings.delete(term);
241
+ disambiguations.push(...getSetIntersection(readings, allReadingsSet));
242
+ }
243
+ return disambiguations;
244
+ }
245
+ function isNonNounVerbOrAdjective(wordClasses) {
246
+ let isVerbOrAdjective = false;
247
+ let isSuruVerb = false;
248
+ let isNoun = false;
249
+ for (const wordClass of wordClasses) switch (wordClass) {
250
+ case "v1":
251
+ case "v5":
252
+ case "vk":
253
+ case "vz":
254
+ case "adj-i":
255
+ isVerbOrAdjective = true;
256
+ break;
257
+ case "vs":
258
+ isVerbOrAdjective = true;
259
+ isSuruVerb = true;
260
+ break;
261
+ case "n":
262
+ isNoun = true;
263
+ break;
264
+ }
265
+ return isVerbOrAdjective && !(isSuruVerb && isNoun);
266
+ }
267
+ function compareRevisions(current, latest) {
268
+ const simpleVersionTest = /^(\d+\.)*\d+$/;
269
+ if (!simpleVersionTest.test(current) || !simpleVersionTest.test(latest)) return current < latest;
270
+ const currentParts = current.split(".").map((part) => Number.parseInt(part, 10));
271
+ const latestParts = latest.split(".").map((part) => Number.parseInt(part, 10));
272
+ if (currentParts.length !== latestParts.length) return current < latest;
273
+ for (let i = 0; i < currentParts.length; i++) if (currentParts[i] !== latestParts[i]) return currentParts[i] < latestParts[i];
274
+ return false;
275
+ }
276
+ function findExistingGroupedPronunciation(reading, pronunciation, groupedPronunciationList) {
277
+ return groupedPronunciationList.find((gp) => gp.reading === reading && arePronunciationsEquivalent(gp, pronunciation)) ?? null;
278
+ }
279
+ function arePronunciationsEquivalent({ pronunciation: pronunciation1 }, pronunciation2) {
280
+ if (pronunciation1.type !== pronunciation2.type || !areTagListsEqual(pronunciation1.tags, pronunciation2.tags)) return false;
281
+ switch (pronunciation1.type) {
282
+ case "pitch-accent": {
283
+ const pitchAccent2 = pronunciation2;
284
+ return pronunciation1.positions === pitchAccent2.positions && areSimpleArraysEqual(pronunciation1.nasalPositions, pitchAccent2.nasalPositions) && areSimpleArraysEqual(pronunciation1.devoicePositions, pitchAccent2.devoicePositions);
285
+ }
286
+ case "phonetic-transcription": {
287
+ const phoneticTranscription2 = pronunciation2;
288
+ return pronunciation1.ipa === phoneticTranscription2.ipa;
289
+ }
290
+ }
291
+ return true;
292
+ }
293
+ function areSimpleArraysEqual(array1, array2) {
294
+ const ii = array1.length;
295
+ if (ii !== array2.length) return false;
296
+ for (let i = 0; i < ii; ++i) if (array1[i] !== array2[i]) return false;
297
+ return true;
298
+ }
299
+ function areTagListsEqual(tagList1, tagList2) {
300
+ const ii = tagList1.length;
301
+ if (tagList2.length !== ii) return false;
302
+ for (let i = 0; i < ii; ++i) {
303
+ const tag1 = tagList1[i];
304
+ const tag2 = tagList2[i];
305
+ if (tag1.name !== tag2.name || !areSimpleArraysEqual(tag1.dictionaries, tag2.dictionaries)) return false;
306
+ }
307
+ return true;
308
+ }
309
+ function areSetsEqual(set1, set2) {
310
+ if (set1.size !== set2.size) return false;
311
+ for (const value of set1) if (!set2.has(value)) return false;
312
+ return true;
313
+ }
314
+ function getSetIntersection(set1, set2) {
315
+ const result = [];
316
+ for (const value of set1) if (set2.has(value)) result.push(value);
317
+ return result;
318
+ }
319
+ function createMapKey(array) {
320
+ return JSON.stringify(array);
321
+ }
322
+
323
+ //#endregion
324
+ Object.defineProperty(exports, 'compareRevisions', {
325
+ enumerable: true,
326
+ get: function () {
327
+ return compareRevisions;
328
+ }
329
+ });
330
+ Object.defineProperty(exports, 'getDisambiguations', {
331
+ enumerable: true,
332
+ get: function () {
333
+ return getDisambiguations;
334
+ }
335
+ });
336
+ Object.defineProperty(exports, 'getGroupedPronunciations', {
337
+ enumerable: true,
338
+ get: function () {
339
+ return getGroupedPronunciations;
340
+ }
341
+ });
342
+ Object.defineProperty(exports, 'getPronunciationsOfType', {
343
+ enumerable: true,
344
+ get: function () {
345
+ return getPronunciationsOfType;
346
+ }
347
+ });
348
+ Object.defineProperty(exports, 'getTermFrequency', {
349
+ enumerable: true,
350
+ get: function () {
351
+ return getTermFrequency;
352
+ }
353
+ });
354
+ Object.defineProperty(exports, 'groupKanjiFrequencies', {
355
+ enumerable: true,
356
+ get: function () {
357
+ return groupKanjiFrequencies;
358
+ }
359
+ });
360
+ Object.defineProperty(exports, 'groupTermFrequencies', {
361
+ enumerable: true,
362
+ get: function () {
363
+ return groupTermFrequencies;
364
+ }
365
+ });
366
+ Object.defineProperty(exports, 'groupTermTags', {
367
+ enumerable: true,
368
+ get: function () {
369
+ return groupTermTags;
370
+ }
371
+ });
372
+ Object.defineProperty(exports, 'isNonNounVerbOrAdjective', {
373
+ enumerable: true,
374
+ get: function () {
375
+ return isNonNounVerbOrAdjective;
376
+ }
377
+ });
378
+ //# sourceMappingURL=dictionary-data-util-CHnRdYZ9.cjs.map