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.
- package/README.md +485 -0
- package/dist/anki-connect-BQyCGW3O.cjs +513 -0
- package/dist/anki-connect-BQyCGW3O.cjs.map +1 -0
- package/dist/anki-connect-CPPuhyiQ.js +6 -0
- package/dist/anki-connect-DbrQHphS.js +495 -0
- package/dist/anki-connect-DbrQHphS.js.map +1 -0
- package/dist/anki-connect-DcheJrp-.cjs +6 -0
- package/dist/anki.cjs +1758 -0
- package/dist/anki.cjs.map +1 -0
- package/dist/anki.d.cts +751 -0
- package/dist/anki.d.cts.map +1 -0
- package/dist/anki.d.ts +751 -0
- package/dist/anki.d.ts.map +1 -0
- package/dist/anki.js +1751 -0
- package/dist/anki.js.map +1 -0
- package/dist/audio-D9DvYyB7.d.cts +48 -0
- package/dist/audio-D9DvYyB7.d.cts.map +1 -0
- package/dist/audio-DQulUkDM.d.ts +48 -0
- package/dist/audio-DQulUkDM.d.ts.map +1 -0
- package/dist/audio-url-generator-BXvQaqUi.cjs +4 -0
- package/dist/audio-url-generator-Dy2hb2Mm.cjs +414 -0
- package/dist/audio-url-generator-Dy2hb2Mm.cjs.map +1 -0
- package/dist/audio-url-generator-Qi0rfzHz.js +4 -0
- package/dist/audio-url-generator-pFQAB5Nb.js +390 -0
- package/dist/audio-url-generator-pFQAB5Nb.js.map +1 -0
- package/dist/audio.cjs +7 -0
- package/dist/audio.d.cts +86 -0
- package/dist/audio.d.cts.map +1 -0
- package/dist/audio.d.ts +86 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/audio.js +4 -0
- package/dist/batch-processor-BR-gB3H3.js +84 -0
- package/dist/batch-processor-BR-gB3H3.js.map +1 -0
- package/dist/batch-processor-CSF1acTw.cjs +3 -0
- package/dist/batch-processor-DFqM_L-_.cjs +91 -0
- package/dist/batch-processor-DFqM_L-_.cjs.map +1 -0
- package/dist/batch-processor-Quo9jUyf.js +3 -0
- package/dist/chunk-BCwAaXi7.cjs +31 -0
- package/dist/cjk-util-Dp0ZU0sh.cjs +167 -0
- package/dist/cjk-util-Dp0ZU0sh.cjs.map +1 -0
- package/dist/cjk-util-DubXBGDG.js +94 -0
- package/dist/cjk-util-DubXBGDG.js.map +1 -0
- package/dist/core-BUpclilG.d.cts +102 -0
- package/dist/core-BUpclilG.d.cts.map +1 -0
- package/dist/core-DFUj5GtA.d.ts +102 -0
- package/dist/core-DFUj5GtA.d.ts.map +1 -0
- package/dist/database.cjs +7 -0
- package/dist/database.d.cts +4 -0
- package/dist/database.d.ts +4 -0
- package/dist/database.js +5 -0
- package/dist/dictionary-D7l-qFt1.d.cts +316 -0
- package/dist/dictionary-D7l-qFt1.d.cts.map +1 -0
- package/dist/dictionary-_vzfBLWi.d.ts +316 -0
- package/dist/dictionary-_vzfBLWi.d.ts.map +1 -0
- package/dist/dictionary-data-util-CHnRdYZ9.cjs +378 -0
- package/dist/dictionary-data-util-CHnRdYZ9.cjs.map +1 -0
- package/dist/dictionary-data-util-CfOLfEDE.js +323 -0
- package/dist/dictionary-data-util-CfOLfEDE.js.map +1 -0
- package/dist/dictionary-database-BDC2f9zc.d.ts +58 -0
- package/dist/dictionary-database-BDC2f9zc.d.ts.map +1 -0
- package/dist/dictionary-database-CU4TsvCC.js +393 -0
- package/dist/dictionary-database-CU4TsvCC.js.map +1 -0
- package/dist/dictionary-database-DsOi04Sg.d.cts +58 -0
- package/dist/dictionary-database-DsOi04Sg.d.cts.map +1 -0
- package/dist/dictionary-database-lvFvftnO.cjs +412 -0
- package/dist/dictionary-database-lvFvftnO.cjs.map +1 -0
- package/dist/dictionary-importer-BkQQSBhm.d.ts +237 -0
- package/dist/dictionary-importer-BkQQSBhm.d.ts.map +1 -0
- package/dist/dictionary-importer-Cen1z6co.js +1821 -0
- package/dist/dictionary-importer-Cen1z6co.js.map +1 -0
- package/dist/dictionary-importer-DYmmWmcX.cjs +8 -0
- package/dist/dictionary-importer-Da3AuTZw.d.cts +237 -0
- package/dist/dictionary-importer-Da3AuTZw.d.cts.map +1 -0
- package/dist/dictionary-importer-Dhn75iZ4.cjs +1834 -0
- package/dist/dictionary-importer-Dhn75iZ4.cjs.map +1 -0
- package/dist/dictionary-importer-xWkel0h-.js +8 -0
- package/dist/dictionary-update-checker-BNE4pGTx.js +4 -0
- package/dist/dictionary-update-checker-Byjvifd2.cjs +75 -0
- package/dist/dictionary-update-checker-Byjvifd2.cjs.map +1 -0
- package/dist/dictionary-update-checker-YdpalZ41.cjs +4 -0
- package/dist/dictionary-update-checker-kKukiovj.js +69 -0
- package/dist/dictionary-update-checker-kKukiovj.js.map +1 -0
- package/dist/display-generator-BGVWiI0t.js +746 -0
- package/dist/display-generator-BGVWiI0t.js.map +1 -0
- package/dist/display-generator-BMQmG5Ov.cjs +9 -0
- package/dist/display-generator-BxZ7mBjP.js +9 -0
- package/dist/display-generator-DyP-HNzP.cjs +758 -0
- package/dist/display-generator-DyP-HNzP.cjs.map +1 -0
- package/dist/errors-BSezaJwm.cjs +35 -0
- package/dist/errors-BSezaJwm.cjs.map +1 -0
- package/dist/errors-DuuDSO5N.js +22 -0
- package/dist/errors-DuuDSO5N.js.map +1 -0
- package/dist/frequency-ranking-BXjfhhUQ.js +3 -0
- package/dist/frequency-ranking-Cx1kkIrw.cjs +3 -0
- package/dist/frequency-ranking-DEJMTMdg.js +159 -0
- package/dist/frequency-ranking-DEJMTMdg.js.map +1 -0
- package/dist/frequency-ranking-DVYxTXN-.cjs +166 -0
- package/dist/frequency-ranking-DVYxTXN-.cjs.map +1 -0
- package/dist/furigana-5HK97CY8.js +4 -0
- package/dist/furigana-9bBI9-qe.d.ts +47 -0
- package/dist/furigana-9bBI9-qe.d.ts.map +1 -0
- package/dist/furigana-B3-0y231.js +471 -0
- package/dist/furigana-B3-0y231.js.map +1 -0
- package/dist/furigana-CjOhzvZt.d.cts +47 -0
- package/dist/furigana-CjOhzvZt.d.cts.map +1 -0
- package/dist/furigana-DpZLcues.cjs +609 -0
- package/dist/furigana-DpZLcues.cjs.map +1 -0
- package/dist/furigana-h3v2ub4-.cjs +4 -0
- package/dist/import.cjs +12 -0
- package/dist/import.d.cts +107 -0
- package/dist/import.d.cts.map +1 -0
- package/dist/import.d.ts +107 -0
- package/dist/import.d.ts.map +1 -0
- package/dist/import.js +9 -0
- package/dist/index.cjs +275 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +211 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +211 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +238 -0
- package/dist/index.js.map +1 -0
- package/dist/json-DGd-cunA.js +17 -0
- package/dist/json-DGd-cunA.js.map +1 -0
- package/dist/json-DKWp-B7Y.cjs +30 -0
- package/dist/json-DKWp-B7Y.cjs.map +1 -0
- package/dist/language-KN_u-nTR.d.ts +104 -0
- package/dist/language-KN_u-nTR.d.ts.map +1 -0
- package/dist/language-xAbQxgXc.d.cts +104 -0
- package/dist/language-xAbQxgXc.d.cts.map +1 -0
- package/dist/language.cjs +15626 -0
- package/dist/language.cjs.map +1 -0
- package/dist/language.d.cts +959 -0
- package/dist/language.d.cts.map +1 -0
- package/dist/language.d.ts +959 -0
- package/dist/language.d.ts.map +1 -0
- package/dist/language.js +15522 -0
- package/dist/language.js.map +1 -0
- package/dist/log-D8KtR3aP.cjs +67 -0
- package/dist/log-D8KtR3aP.cjs.map +1 -0
- package/dist/log-hgSll-dS.js +60 -0
- package/dist/log-hgSll-dS.js.map +1 -0
- package/dist/lookup.cjs +13 -0
- package/dist/lookup.d.cts +161 -0
- package/dist/lookup.d.cts.map +1 -0
- package/dist/lookup.d.ts +161 -0
- package/dist/lookup.d.ts.map +1 -0
- package/dist/lookup.js +10 -0
- package/dist/media-loader-BABA_E4W.js +3 -0
- package/dist/media-loader-Ce9cuANS.cjs +21 -0
- package/dist/media-loader-Ce9cuANS.cjs.map +1 -0
- package/dist/media-loader-qRti-Q6h.js +14 -0
- package/dist/media-loader-qRti-Q6h.js.map +1 -0
- package/dist/media-loader-xlUGaJrx.cjs +3 -0
- package/dist/multi-language-transformer-AlxOM6b3.js +637 -0
- package/dist/multi-language-transformer-AlxOM6b3.js.map +1 -0
- package/dist/multi-language-transformer-MdbQBBOt.cjs +685 -0
- package/dist/multi-language-transformer-MdbQBBOt.cjs.map +1 -0
- package/dist/multi-language-transformer-SEhcJXEB.d.ts +63 -0
- package/dist/multi-language-transformer-SEhcJXEB.d.ts.map +1 -0
- package/dist/multi-language-transformer-Ul9mbRce.d.cts +63 -0
- package/dist/multi-language-transformer-Ul9mbRce.d.cts.map +1 -0
- package/dist/pronunciation-generator-BtBc4q_V.js +397 -0
- package/dist/pronunciation-generator-BtBc4q_V.js.map +1 -0
- package/dist/pronunciation-generator-CBYdXYou.js +4 -0
- package/dist/pronunciation-generator-CFbZlf5J.cjs +445 -0
- package/dist/pronunciation-generator-CFbZlf5J.cjs.map +1 -0
- package/dist/pronunciation-generator-DOz9hEuk.cjs +4 -0
- package/dist/render.cjs +2796 -0
- package/dist/render.cjs.map +1 -0
- package/dist/render.d.cts +424 -0
- package/dist/render.d.cts.map +1 -0
- package/dist/render.d.ts +424 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +2777 -0
- package/dist/render.js.map +1 -0
- package/dist/sentence-parser-BPAJNzqW.js +126 -0
- package/dist/sentence-parser-BPAJNzqW.js.map +1 -0
- package/dist/sentence-parser-BVIOI64h.cjs +132 -0
- package/dist/sentence-parser-BVIOI64h.cjs.map +1 -0
- package/dist/sentence-parser-BoHO3cHn.js +5 -0
- package/dist/sentence-parser-DQVLSW0z.cjs +5 -0
- package/dist/structured-content-generator-BtOApkTW.cjs +4 -0
- package/dist/structured-content-generator-Bx62RYa8.js +4 -0
- package/dist/structured-content-generator-CLnybumI.js +276 -0
- package/dist/structured-content-generator-CLnybumI.js.map +1 -0
- package/dist/structured-content-generator-DrwkB0-k.cjs +282 -0
- package/dist/structured-content-generator-DrwkB0-k.cjs.map +1 -0
- package/dist/text-utilities-B7PIythe.js +8 -0
- package/dist/text-utilities-B7PIythe.js.map +1 -0
- package/dist/text-utilities-Del2Ivkg.cjs +15 -0
- package/dist/text-utilities-Del2Ivkg.cjs.map +1 -0
- package/dist/translator-CRPlPzqi.cjs +1545 -0
- package/dist/translator-CRPlPzqi.cjs.map +1 -0
- package/dist/translator-CWgG5drA.js +1539 -0
- package/dist/translator-CWgG5drA.js.map +1 -0
- package/dist/translator-CaGtJvnQ.cjs +6 -0
- package/dist/translator-Cc6OGxrW.d.ts +180 -0
- package/dist/translator-Cc6OGxrW.d.ts.map +1 -0
- package/dist/translator-CcA-s-W4.d.cts +180 -0
- package/dist/translator-CcA-s-W4.d.cts.map +1 -0
- package/dist/translator-CuJOTK6l.js +6 -0
- package/dist/utilities-C-lbZaJE.cjs +52 -0
- package/dist/utilities-C-lbZaJE.cjs.map +1 -0
- package/dist/utilities-bi3EF-q5.js +33 -0
- package/dist/utilities-bi3EF-q5.js.map +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
import { log } from "./log-hgSll-dS.js";
|
|
2
|
+
import { capitalizeFirstLetter, decapitalize, normalizeRadicalCharacters, removeAlphabeticDiacritics } from "./cjk-util-DubXBGDG.js";
|
|
3
|
+
|
|
4
|
+
//#region src/language/language-descriptors.ts
|
|
5
|
+
const capitalizationPreprocessors = {
|
|
6
|
+
decapitalize,
|
|
7
|
+
capitalizeFirstLetter
|
|
8
|
+
};
|
|
9
|
+
const languageDescriptors = [
|
|
10
|
+
{
|
|
11
|
+
iso: "bg",
|
|
12
|
+
iso639_3: "bul",
|
|
13
|
+
name: "Bulgarian",
|
|
14
|
+
exampleText: "чета",
|
|
15
|
+
textPreprocessors: capitalizationPreprocessors
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
iso: "cs",
|
|
19
|
+
iso639_3: "ces",
|
|
20
|
+
name: "Czech",
|
|
21
|
+
exampleText: "číst",
|
|
22
|
+
textPreprocessors: capitalizationPreprocessors
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
iso: "da",
|
|
26
|
+
iso639_3: "dan",
|
|
27
|
+
name: "Danish",
|
|
28
|
+
exampleText: "læse",
|
|
29
|
+
textPreprocessors: { ...capitalizationPreprocessors }
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
iso: "de",
|
|
33
|
+
iso639_3: "deu",
|
|
34
|
+
name: "German",
|
|
35
|
+
exampleText: "lesen",
|
|
36
|
+
textPreprocessors: { ...capitalizationPreprocessors }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
iso: "el",
|
|
40
|
+
iso639_3: "ell",
|
|
41
|
+
name: "Greek",
|
|
42
|
+
exampleText: "διαβάζω",
|
|
43
|
+
textPreprocessors: { ...capitalizationPreprocessors }
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
iso: "en",
|
|
47
|
+
iso639_3: "eng",
|
|
48
|
+
name: "English",
|
|
49
|
+
exampleText: "read",
|
|
50
|
+
textPreprocessors: capitalizationPreprocessors
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
iso: "eo",
|
|
54
|
+
iso639_3: "epo",
|
|
55
|
+
name: "Esperanto",
|
|
56
|
+
exampleText: "legi",
|
|
57
|
+
textPreprocessors: capitalizationPreprocessors
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
iso: "es",
|
|
61
|
+
iso639_3: "spa",
|
|
62
|
+
name: "Spanish",
|
|
63
|
+
exampleText: "leer",
|
|
64
|
+
textPreprocessors: capitalizationPreprocessors
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
iso: "et",
|
|
68
|
+
iso639_3: "est",
|
|
69
|
+
name: "Estonian",
|
|
70
|
+
exampleText: "lugema",
|
|
71
|
+
textPreprocessors: capitalizationPreprocessors
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
iso: "fi",
|
|
75
|
+
iso639_3: "fin",
|
|
76
|
+
name: "Finnish",
|
|
77
|
+
exampleText: "lukea",
|
|
78
|
+
textPreprocessors: capitalizationPreprocessors
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
iso: "fr",
|
|
82
|
+
iso639_3: "fra",
|
|
83
|
+
name: "French",
|
|
84
|
+
exampleText: "lire",
|
|
85
|
+
textPreprocessors: { ...capitalizationPreprocessors }
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
iso: "ga",
|
|
89
|
+
iso639_3: "gle",
|
|
90
|
+
name: "Irish",
|
|
91
|
+
exampleText: "léigh",
|
|
92
|
+
textPreprocessors: capitalizationPreprocessors
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
iso: "grc",
|
|
96
|
+
iso639_3: "grc",
|
|
97
|
+
name: "Ancient Greek",
|
|
98
|
+
exampleText: "γράφω",
|
|
99
|
+
textPreprocessors: {
|
|
100
|
+
...capitalizationPreprocessors,
|
|
101
|
+
removeAlphabeticDiacritics
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
iso: "he",
|
|
106
|
+
iso639_3: "heb",
|
|
107
|
+
name: "Hebrew",
|
|
108
|
+
exampleText: "קריאה"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
iso: "hi",
|
|
112
|
+
iso639_3: "hin",
|
|
113
|
+
name: "Hindi",
|
|
114
|
+
exampleText: "पढ़ने के लिए"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
iso: "hu",
|
|
118
|
+
iso639_3: "hun",
|
|
119
|
+
name: "Hungarian",
|
|
120
|
+
exampleText: "olvasni",
|
|
121
|
+
textPreprocessors: capitalizationPreprocessors
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
iso: "id",
|
|
125
|
+
iso639_3: "ind",
|
|
126
|
+
name: "Indonesian",
|
|
127
|
+
exampleText: "baca",
|
|
128
|
+
textPreprocessors: {
|
|
129
|
+
...capitalizationPreprocessors,
|
|
130
|
+
removeAlphabeticDiacritics
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
iso: "it",
|
|
135
|
+
iso639_3: "ita",
|
|
136
|
+
name: "Italian",
|
|
137
|
+
exampleText: "leggere",
|
|
138
|
+
textPreprocessors: {
|
|
139
|
+
...capitalizationPreprocessors,
|
|
140
|
+
removeAlphabeticDiacritics
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
iso: "la",
|
|
145
|
+
iso639_3: "lat",
|
|
146
|
+
name: "Latin",
|
|
147
|
+
exampleText: "legō",
|
|
148
|
+
textPreprocessors: {
|
|
149
|
+
...capitalizationPreprocessors,
|
|
150
|
+
removeAlphabeticDiacritics
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
iso: "lo",
|
|
155
|
+
iso639_3: "lao",
|
|
156
|
+
name: "Lao",
|
|
157
|
+
exampleText: "ອ່ານ"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
iso: "lv",
|
|
161
|
+
iso639_3: "lav",
|
|
162
|
+
name: "Latvian",
|
|
163
|
+
exampleText: "lasīt",
|
|
164
|
+
textPreprocessors: capitalizationPreprocessors
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
iso: "ja",
|
|
168
|
+
iso639_3: "jpn",
|
|
169
|
+
name: "Japanese",
|
|
170
|
+
exampleText: "読め"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
iso: "ka",
|
|
174
|
+
iso639_3: "kat",
|
|
175
|
+
name: "Georgian",
|
|
176
|
+
exampleText: "კითხვა"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
iso: "kn",
|
|
180
|
+
iso639_3: "kan",
|
|
181
|
+
name: "Kannada",
|
|
182
|
+
exampleText: "ಓದು"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
iso: "km",
|
|
186
|
+
iso639_3: "khm",
|
|
187
|
+
name: "Khmer",
|
|
188
|
+
exampleText: "អាន"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
iso: "ko",
|
|
192
|
+
iso639_3: "kor",
|
|
193
|
+
name: "Korean",
|
|
194
|
+
exampleText: "읽어"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
iso: "mn",
|
|
198
|
+
iso639_3: "mon",
|
|
199
|
+
name: "Mongolian",
|
|
200
|
+
exampleText: "унших",
|
|
201
|
+
textPreprocessors: capitalizationPreprocessors
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
iso: "mt",
|
|
205
|
+
iso639_3: "mlt",
|
|
206
|
+
name: "Maltese",
|
|
207
|
+
exampleText: "kiteb",
|
|
208
|
+
textPreprocessors: capitalizationPreprocessors
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
iso: "nl",
|
|
212
|
+
iso639_3: "nld",
|
|
213
|
+
name: "Dutch",
|
|
214
|
+
exampleText: "lezen",
|
|
215
|
+
textPreprocessors: capitalizationPreprocessors
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
iso: "no",
|
|
219
|
+
iso639_3: "nor",
|
|
220
|
+
name: "Norwegian",
|
|
221
|
+
exampleText: "lese",
|
|
222
|
+
textPreprocessors: { ...capitalizationPreprocessors }
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
iso: "pl",
|
|
226
|
+
iso639_3: "pol",
|
|
227
|
+
name: "Polish",
|
|
228
|
+
exampleText: "czytać",
|
|
229
|
+
textPreprocessors: capitalizationPreprocessors
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
iso: "pt",
|
|
233
|
+
iso639_3: "por",
|
|
234
|
+
name: "Portuguese",
|
|
235
|
+
exampleText: "ler",
|
|
236
|
+
textPreprocessors: capitalizationPreprocessors
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
iso: "ro",
|
|
240
|
+
iso639_3: "ron",
|
|
241
|
+
name: "Romanian",
|
|
242
|
+
exampleText: "citi",
|
|
243
|
+
textPreprocessors: {
|
|
244
|
+
...capitalizationPreprocessors,
|
|
245
|
+
removeAlphabeticDiacritics
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
iso: "ru",
|
|
250
|
+
iso639_3: "rus",
|
|
251
|
+
name: "Russian",
|
|
252
|
+
exampleText: "читать",
|
|
253
|
+
textPreprocessors: { ...capitalizationPreprocessors }
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
iso: "sga",
|
|
257
|
+
iso639_3: "sga",
|
|
258
|
+
name: "Old Irish",
|
|
259
|
+
exampleText: "légaid",
|
|
260
|
+
textPreprocessors: {
|
|
261
|
+
...capitalizationPreprocessors,
|
|
262
|
+
removeAlphabeticDiacritics
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
iso: "sh",
|
|
267
|
+
iso639_3: "hbs",
|
|
268
|
+
name: "Serbo-Croatian",
|
|
269
|
+
exampleText: "čìtati",
|
|
270
|
+
textPreprocessors: { ...capitalizationPreprocessors }
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
iso: "sq",
|
|
274
|
+
iso639_3: "sqi",
|
|
275
|
+
name: "Albanian",
|
|
276
|
+
exampleText: "ndihmoj",
|
|
277
|
+
textPreprocessors: capitalizationPreprocessors
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
iso: "sv",
|
|
281
|
+
iso639_3: "swe",
|
|
282
|
+
name: "Swedish",
|
|
283
|
+
exampleText: "läsa",
|
|
284
|
+
textPreprocessors: capitalizationPreprocessors
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
iso: "th",
|
|
288
|
+
iso639_3: "tha",
|
|
289
|
+
name: "Thai",
|
|
290
|
+
exampleText: "อ่าน"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
iso: "tl",
|
|
294
|
+
iso639_3: "tgl",
|
|
295
|
+
name: "Tagalog",
|
|
296
|
+
exampleText: "basahin",
|
|
297
|
+
textPreprocessors: {
|
|
298
|
+
...capitalizationPreprocessors,
|
|
299
|
+
removeAlphabeticDiacritics
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
iso: "tr",
|
|
304
|
+
iso639_3: "tur",
|
|
305
|
+
name: "Turkish",
|
|
306
|
+
exampleText: "okumak",
|
|
307
|
+
textPreprocessors: capitalizationPreprocessors
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
iso: "tok",
|
|
311
|
+
iso639_3: "tok",
|
|
312
|
+
name: "Toki Pona",
|
|
313
|
+
exampleText: "wile",
|
|
314
|
+
textPreprocessors: capitalizationPreprocessors
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
iso: "uk",
|
|
318
|
+
iso639_3: "ukr",
|
|
319
|
+
name: "Ukrainian",
|
|
320
|
+
exampleText: "читати",
|
|
321
|
+
textPreprocessors: capitalizationPreprocessors
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
iso: "vi",
|
|
325
|
+
iso639_3: "vie",
|
|
326
|
+
name: "Vietnamese",
|
|
327
|
+
exampleText: "đọc",
|
|
328
|
+
textPreprocessors: { ...capitalizationPreprocessors }
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
iso: "cy",
|
|
332
|
+
iso639_3: "cym",
|
|
333
|
+
name: "Welsh",
|
|
334
|
+
exampleText: "ddarllen",
|
|
335
|
+
textPreprocessors: capitalizationPreprocessors
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
iso: "yi",
|
|
339
|
+
iso639_3: "yid",
|
|
340
|
+
name: "Yiddish",
|
|
341
|
+
exampleText: "באַשאַפֿן"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
iso: "yue",
|
|
345
|
+
iso639_3: "yue",
|
|
346
|
+
name: "Cantonese",
|
|
347
|
+
exampleText: "讀",
|
|
348
|
+
textPreprocessors: { normalizeRadicalCharacters }
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
iso: "zh",
|
|
352
|
+
iso639_3: "zho",
|
|
353
|
+
name: "Chinese",
|
|
354
|
+
exampleText: "读",
|
|
355
|
+
textPreprocessors: { normalizeRadicalCharacters }
|
|
356
|
+
}
|
|
357
|
+
];
|
|
358
|
+
const languageDescriptorMap = new Map();
|
|
359
|
+
for (const languageDescriptor of languageDescriptors) languageDescriptorMap.set(languageDescriptor.iso, languageDescriptor);
|
|
360
|
+
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/language/languages.ts
|
|
363
|
+
function getLanguageSummaries() {
|
|
364
|
+
const results = [];
|
|
365
|
+
for (const { name, iso, iso639_3, exampleText } of languageDescriptorMap.values()) results.push({
|
|
366
|
+
name,
|
|
367
|
+
iso,
|
|
368
|
+
iso639_3,
|
|
369
|
+
exampleText
|
|
370
|
+
});
|
|
371
|
+
return results;
|
|
372
|
+
}
|
|
373
|
+
function getAllLanguageReadingNormalizers() {
|
|
374
|
+
const results = [];
|
|
375
|
+
for (const { iso, readingNormalizer } of languageDescriptorMap.values()) {
|
|
376
|
+
if (typeof readingNormalizer === "undefined") continue;
|
|
377
|
+
results.push({
|
|
378
|
+
iso,
|
|
379
|
+
readingNormalizer
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
return results;
|
|
383
|
+
}
|
|
384
|
+
function getAllLanguageTextProcessors() {
|
|
385
|
+
const results = [];
|
|
386
|
+
for (const { iso, textPreprocessors = {}, textPostprocessors = {} } of languageDescriptorMap.values()) {
|
|
387
|
+
const textPreprocessorsArray = [];
|
|
388
|
+
for (const [id, textPreprocessor] of Object.entries(textPreprocessors)) textPreprocessorsArray.push({
|
|
389
|
+
id,
|
|
390
|
+
textProcessor: textPreprocessor
|
|
391
|
+
});
|
|
392
|
+
const textPostprocessorsArray = [];
|
|
393
|
+
for (const [id, textPostprocessor] of Object.entries(textPostprocessors)) textPostprocessorsArray.push({
|
|
394
|
+
id,
|
|
395
|
+
textProcessor: textPostprocessor
|
|
396
|
+
});
|
|
397
|
+
results.push({
|
|
398
|
+
iso,
|
|
399
|
+
textPreprocessors: textPreprocessorsArray,
|
|
400
|
+
textPostprocessors: textPostprocessorsArray
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
return results;
|
|
404
|
+
}
|
|
405
|
+
function isTextLookupWorthy(text, language) {
|
|
406
|
+
const descriptor = languageDescriptorMap.get(language);
|
|
407
|
+
if (typeof descriptor === "undefined") return false;
|
|
408
|
+
return typeof descriptor.isTextLookupWorthy === "undefined" || descriptor.isTextLookupWorthy(text);
|
|
409
|
+
}
|
|
410
|
+
function getAllLanguageTransformDescriptors() {
|
|
411
|
+
const results = [];
|
|
412
|
+
for (const { iso, languageTransforms } of languageDescriptorMap.values()) if (languageTransforms) results.push({
|
|
413
|
+
iso,
|
|
414
|
+
languageTransforms
|
|
415
|
+
});
|
|
416
|
+
return results;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/language/language-transformer.ts
|
|
421
|
+
var LanguageTransformer = class LanguageTransformer {
|
|
422
|
+
_nextFlagIndex;
|
|
423
|
+
_transforms;
|
|
424
|
+
_conditionTypeToConditionFlagsMap;
|
|
425
|
+
_partOfSpeechToConditionFlagsMap;
|
|
426
|
+
constructor() {
|
|
427
|
+
this._nextFlagIndex = 0;
|
|
428
|
+
this._transforms = [];
|
|
429
|
+
this._conditionTypeToConditionFlagsMap = new Map();
|
|
430
|
+
this._partOfSpeechToConditionFlagsMap = new Map();
|
|
431
|
+
}
|
|
432
|
+
clear() {
|
|
433
|
+
this._nextFlagIndex = 0;
|
|
434
|
+
this._transforms = [];
|
|
435
|
+
this._conditionTypeToConditionFlagsMap.clear();
|
|
436
|
+
this._partOfSpeechToConditionFlagsMap.clear();
|
|
437
|
+
}
|
|
438
|
+
addDescriptor(descriptor) {
|
|
439
|
+
const { conditions, transforms } = descriptor;
|
|
440
|
+
const conditionEntries = Object.entries(conditions);
|
|
441
|
+
const { conditionFlagsMap, nextFlagIndex } = this._getConditionFlagsMap(conditionEntries, this._nextFlagIndex);
|
|
442
|
+
const transforms2 = [];
|
|
443
|
+
for (const [transformId, transform] of Object.entries(transforms)) {
|
|
444
|
+
const { name, description, rules } = transform;
|
|
445
|
+
const rules2 = [];
|
|
446
|
+
for (let j = 0, jj = rules.length; j < jj; ++j) {
|
|
447
|
+
const { type, isInflected, deinflect, conditionsIn, conditionsOut } = rules[j];
|
|
448
|
+
const conditionFlagsIn = this._getConditionFlagsStrict(conditionFlagsMap, conditionsIn);
|
|
449
|
+
if (conditionFlagsIn === null) throw new Error(`Invalid conditionsIn for transform ${transformId}.rules[${j}]`);
|
|
450
|
+
const conditionFlagsOut = this._getConditionFlagsStrict(conditionFlagsMap, conditionsOut);
|
|
451
|
+
if (conditionFlagsOut === null) throw new Error(`Invalid conditionsOut for transform ${transformId}.rules[${j}]`);
|
|
452
|
+
rules2.push({
|
|
453
|
+
type,
|
|
454
|
+
isInflected,
|
|
455
|
+
deinflect,
|
|
456
|
+
conditionsIn: conditionFlagsIn,
|
|
457
|
+
conditionsOut: conditionFlagsOut
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
const isInflectedTests = rules.map((rule) => rule.isInflected);
|
|
461
|
+
const heuristic = new RegExp(isInflectedTests.map((regExp) => regExp.source).join("|"));
|
|
462
|
+
transforms2.push({
|
|
463
|
+
id: transformId,
|
|
464
|
+
name,
|
|
465
|
+
description,
|
|
466
|
+
rules: rules2,
|
|
467
|
+
heuristic
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
this._nextFlagIndex = nextFlagIndex;
|
|
471
|
+
for (const transform of transforms2) this._transforms.push(transform);
|
|
472
|
+
for (const [type, { isDictionaryForm }] of conditionEntries) {
|
|
473
|
+
const flags = conditionFlagsMap.get(type);
|
|
474
|
+
if (typeof flags === "undefined") continue;
|
|
475
|
+
this._conditionTypeToConditionFlagsMap.set(type, flags);
|
|
476
|
+
if (isDictionaryForm) this._partOfSpeechToConditionFlagsMap.set(type, flags);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
getConditionFlagsFromPartsOfSpeech(partsOfSpeech) {
|
|
480
|
+
return this._getConditionFlags(this._partOfSpeechToConditionFlagsMap, partsOfSpeech);
|
|
481
|
+
}
|
|
482
|
+
getConditionFlagsFromConditionTypes(conditionTypes) {
|
|
483
|
+
return this._getConditionFlags(this._conditionTypeToConditionFlagsMap, conditionTypes);
|
|
484
|
+
}
|
|
485
|
+
getConditionFlagsFromConditionType(conditionType) {
|
|
486
|
+
return this._getConditionFlags(this._conditionTypeToConditionFlagsMap, [conditionType]);
|
|
487
|
+
}
|
|
488
|
+
transform(sourceText) {
|
|
489
|
+
const results = [LanguageTransformer.createTransformedText(sourceText, 0, [])];
|
|
490
|
+
for (let i = 0; i < results.length; ++i) {
|
|
491
|
+
const { text, conditions, trace } = results[i];
|
|
492
|
+
for (const transform of this._transforms) {
|
|
493
|
+
if (!transform.heuristic.test(text)) continue;
|
|
494
|
+
const { id, rules } = transform;
|
|
495
|
+
for (let j = 0, jj = rules.length; j < jj; ++j) {
|
|
496
|
+
const rule = rules[j];
|
|
497
|
+
if (!LanguageTransformer.conditionsMatch(conditions, rule.conditionsIn)) continue;
|
|
498
|
+
const { isInflected, deinflect } = rule;
|
|
499
|
+
if (!isInflected.test(text)) continue;
|
|
500
|
+
const isCycle = trace.some((frame) => frame.transform === id && frame.ruleIndex === j && frame.text === text);
|
|
501
|
+
if (isCycle) {
|
|
502
|
+
log.warn(new Error(`Cycle detected in transform[${id}] rule[${j}] for text: ${text}\nTrace: ${JSON.stringify(trace)}`));
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
results.push(LanguageTransformer.createTransformedText(deinflect(text), rule.conditionsOut, this._extendTrace(trace, {
|
|
506
|
+
transform: id,
|
|
507
|
+
ruleIndex: j,
|
|
508
|
+
text
|
|
509
|
+
})));
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return results;
|
|
514
|
+
}
|
|
515
|
+
getUserFacingInflectionRules(inflectionRules) {
|
|
516
|
+
return inflectionRules.map((rule) => {
|
|
517
|
+
const fullRule = this._transforms.find((transform) => transform.id === rule);
|
|
518
|
+
if (typeof fullRule === "undefined") return { name: rule };
|
|
519
|
+
const { name, description } = fullRule;
|
|
520
|
+
return description ? {
|
|
521
|
+
name,
|
|
522
|
+
description
|
|
523
|
+
} : { name };
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
static createTransformedText(text, conditions, trace) {
|
|
527
|
+
return {
|
|
528
|
+
text,
|
|
529
|
+
conditions,
|
|
530
|
+
trace
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
static conditionsMatch(currentConditions, nextConditions) {
|
|
534
|
+
return currentConditions === 0 || (currentConditions & nextConditions) !== 0;
|
|
535
|
+
}
|
|
536
|
+
_getConditionFlagsMap(conditions, nextFlagIndex) {
|
|
537
|
+
const conditionFlagsMap = new Map();
|
|
538
|
+
let targets = conditions;
|
|
539
|
+
while (targets.length > 0) {
|
|
540
|
+
const nextTargets = [];
|
|
541
|
+
for (const target of targets) {
|
|
542
|
+
const [type, condition] = target;
|
|
543
|
+
const { subConditions } = condition;
|
|
544
|
+
let flags = 0;
|
|
545
|
+
if (typeof subConditions === "undefined") {
|
|
546
|
+
if (nextFlagIndex >= 32) throw new Error("Maximum number of conditions was exceeded");
|
|
547
|
+
flags = 1 << nextFlagIndex;
|
|
548
|
+
++nextFlagIndex;
|
|
549
|
+
} else {
|
|
550
|
+
const multiFlags = this._getConditionFlagsStrict(conditionFlagsMap, subConditions);
|
|
551
|
+
if (multiFlags === null) {
|
|
552
|
+
nextTargets.push(target);
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
flags = multiFlags;
|
|
556
|
+
}
|
|
557
|
+
conditionFlagsMap.set(type, flags);
|
|
558
|
+
}
|
|
559
|
+
if (nextTargets.length === targets.length) throw new Error("Maximum number of conditions was exceeded");
|
|
560
|
+
targets = nextTargets;
|
|
561
|
+
}
|
|
562
|
+
return {
|
|
563
|
+
conditionFlagsMap,
|
|
564
|
+
nextFlagIndex
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
_getConditionFlagsStrict(conditionFlagsMap, conditionTypes) {
|
|
568
|
+
let flags = 0;
|
|
569
|
+
for (const conditionType of conditionTypes) {
|
|
570
|
+
const flags2 = conditionFlagsMap.get(conditionType);
|
|
571
|
+
if (typeof flags2 === "undefined") return null;
|
|
572
|
+
flags |= flags2;
|
|
573
|
+
}
|
|
574
|
+
return flags;
|
|
575
|
+
}
|
|
576
|
+
_getConditionFlags(conditionFlagsMap, conditionTypes) {
|
|
577
|
+
let flags = 0;
|
|
578
|
+
for (const conditionType of conditionTypes) {
|
|
579
|
+
let flags2 = conditionFlagsMap.get(conditionType);
|
|
580
|
+
if (typeof flags2 === "undefined") flags2 = 0;
|
|
581
|
+
flags |= flags2;
|
|
582
|
+
}
|
|
583
|
+
return flags;
|
|
584
|
+
}
|
|
585
|
+
_extendTrace(trace, newFrame) {
|
|
586
|
+
const newTrace = [newFrame];
|
|
587
|
+
for (const { transform, ruleIndex, text } of trace) newTrace.push({
|
|
588
|
+
transform,
|
|
589
|
+
ruleIndex,
|
|
590
|
+
text
|
|
591
|
+
});
|
|
592
|
+
return newTrace;
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region src/language/multi-language-transformer.ts
|
|
598
|
+
var MultiLanguageTransformer = class {
|
|
599
|
+
_languageTransformers;
|
|
600
|
+
constructor() {
|
|
601
|
+
this._languageTransformers = new Map();
|
|
602
|
+
}
|
|
603
|
+
prepare() {
|
|
604
|
+
const languagesWithTransforms = getAllLanguageTransformDescriptors();
|
|
605
|
+
for (const { languageTransforms: descriptor } of languagesWithTransforms) {
|
|
606
|
+
const languageTransformer = new LanguageTransformer();
|
|
607
|
+
languageTransformer.addDescriptor(descriptor);
|
|
608
|
+
this._languageTransformers.set(descriptor.language, languageTransformer);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
getConditionFlagsFromPartsOfSpeech(language, partsOfSpeech) {
|
|
612
|
+
const languageTransformer = this._languageTransformers.get(language);
|
|
613
|
+
return typeof languageTransformer !== "undefined" ? languageTransformer.getConditionFlagsFromPartsOfSpeech(partsOfSpeech) : 0;
|
|
614
|
+
}
|
|
615
|
+
getConditionFlagsFromConditionTypes(language, conditionTypes) {
|
|
616
|
+
const languageTransformer = this._languageTransformers.get(language);
|
|
617
|
+
return typeof languageTransformer !== "undefined" ? languageTransformer.getConditionFlagsFromConditionTypes(conditionTypes) : 0;
|
|
618
|
+
}
|
|
619
|
+
getConditionFlagsFromConditionType(language, conditionType) {
|
|
620
|
+
const languageTransformer = this._languageTransformers.get(language);
|
|
621
|
+
return typeof languageTransformer !== "undefined" ? languageTransformer.getConditionFlagsFromConditionType(conditionType) : 0;
|
|
622
|
+
}
|
|
623
|
+
transform(language, sourceText) {
|
|
624
|
+
const languageTransformer = this._languageTransformers.get(language);
|
|
625
|
+
if (typeof languageTransformer === "undefined") return [LanguageTransformer.createTransformedText(sourceText, 0, [])];
|
|
626
|
+
return languageTransformer.transform(sourceText);
|
|
627
|
+
}
|
|
628
|
+
getUserFacingInflectionRules(language, inflectionRules) {
|
|
629
|
+
const languageTransformer = this._languageTransformers.get(language);
|
|
630
|
+
if (typeof languageTransformer === "undefined") return inflectionRules.map((rule) => ({ name: rule }));
|
|
631
|
+
return languageTransformer.getUserFacingInflectionRules(inflectionRules);
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
//#endregion
|
|
636
|
+
export { LanguageTransformer, MultiLanguageTransformer, getAllLanguageReadingNormalizers, getAllLanguageTextProcessors, getAllLanguageTransformDescriptors, getLanguageSummaries, isTextLookupWorthy, languageDescriptorMap };
|
|
637
|
+
//# sourceMappingURL=multi-language-transformer-AlxOM6b3.js.map
|