indickit 0.0.0-stage → 0.4.2
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/LICENSE +21 -0
- package/README.md +238 -2
- package/dist/normalize.js +183 -0
- package/dist/phonetic.js +805 -0
- package/dist/segment.js +175 -0
- package/dist/stem.js +40 -0
- package/dist/types/js/normalize.d.ts +26 -0
- package/dist/types/js/phonetic.d.ts +28 -0
- package/dist/types/js/segment.d.ts +22 -0
- package/dist/types/js/stem.d.ts +24 -0
- package/package.json +41 -4
package/dist/phonetic.js
ADDED
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
// phonetic/rules.json
|
|
2
|
+
var rules_default = {
|
|
3
|
+
version: "2026-10-06",
|
|
4
|
+
folds: [
|
|
5
|
+
"bn-case",
|
|
6
|
+
"drop-vowels",
|
|
7
|
+
"drop-y",
|
|
8
|
+
"gu-case",
|
|
9
|
+
"latin-w-u",
|
|
10
|
+
"ml-case",
|
|
11
|
+
"nasal-all",
|
|
12
|
+
"ng-k",
|
|
13
|
+
"or-case",
|
|
14
|
+
"retroflex",
|
|
15
|
+
"s-c",
|
|
16
|
+
"ta-case",
|
|
17
|
+
"ta-k-h",
|
|
18
|
+
"te-case",
|
|
19
|
+
"ur-w-u",
|
|
20
|
+
"v-b"
|
|
21
|
+
],
|
|
22
|
+
brahmic: {
|
|
23
|
+
from: 2304,
|
|
24
|
+
to: 3455,
|
|
25
|
+
class_by_offset: {
|
|
26
|
+
"2": "ṁ",
|
|
27
|
+
"5": "a",
|
|
28
|
+
"6": "a",
|
|
29
|
+
"7": "i",
|
|
30
|
+
"8": "i",
|
|
31
|
+
"9": "u",
|
|
32
|
+
"10": "u",
|
|
33
|
+
"11": "r",
|
|
34
|
+
"12": "l",
|
|
35
|
+
"13": "e",
|
|
36
|
+
"14": "e",
|
|
37
|
+
"15": "e",
|
|
38
|
+
"16": "e",
|
|
39
|
+
"17": "o",
|
|
40
|
+
"18": "o",
|
|
41
|
+
"19": "o",
|
|
42
|
+
"20": "o",
|
|
43
|
+
"21": "k",
|
|
44
|
+
"22": "k",
|
|
45
|
+
"23": "k",
|
|
46
|
+
"24": "k",
|
|
47
|
+
"25": "ṅ",
|
|
48
|
+
"26": "c",
|
|
49
|
+
"27": "c",
|
|
50
|
+
"28": "c",
|
|
51
|
+
"29": "c",
|
|
52
|
+
"30": "ñ",
|
|
53
|
+
"31": "ṭ",
|
|
54
|
+
"32": "ṭ",
|
|
55
|
+
"33": "ṭ",
|
|
56
|
+
"34": "ṭ",
|
|
57
|
+
"35": "ṇ",
|
|
58
|
+
"36": "t",
|
|
59
|
+
"37": "t",
|
|
60
|
+
"38": "t",
|
|
61
|
+
"39": "t",
|
|
62
|
+
"40": "n",
|
|
63
|
+
"41": "n",
|
|
64
|
+
"42": "p",
|
|
65
|
+
"43": "p",
|
|
66
|
+
"44": "p",
|
|
67
|
+
"45": "p",
|
|
68
|
+
"46": "m",
|
|
69
|
+
"47": "y",
|
|
70
|
+
"48": "r",
|
|
71
|
+
"49": "r",
|
|
72
|
+
"50": "l",
|
|
73
|
+
"51": "l",
|
|
74
|
+
"52": "l",
|
|
75
|
+
"53": "v",
|
|
76
|
+
"54": "s",
|
|
77
|
+
"55": "s",
|
|
78
|
+
"56": "s",
|
|
79
|
+
"57": "h",
|
|
80
|
+
"62": "a",
|
|
81
|
+
"63": "i",
|
|
82
|
+
"64": "i",
|
|
83
|
+
"65": "u",
|
|
84
|
+
"66": "u",
|
|
85
|
+
"67": "r",
|
|
86
|
+
"68": "r",
|
|
87
|
+
"69": "e",
|
|
88
|
+
"70": "e",
|
|
89
|
+
"71": "e",
|
|
90
|
+
"72": "e",
|
|
91
|
+
"73": "o",
|
|
92
|
+
"74": "o",
|
|
93
|
+
"75": "o",
|
|
94
|
+
"76": "o",
|
|
95
|
+
"87": "o",
|
|
96
|
+
"96": "r",
|
|
97
|
+
"97": "l",
|
|
98
|
+
"98": "l",
|
|
99
|
+
"99": "l"
|
|
100
|
+
},
|
|
101
|
+
virama_offset: 77,
|
|
102
|
+
candrabindu_offset: 1,
|
|
103
|
+
candrabindu_class: "ṁ"
|
|
104
|
+
},
|
|
105
|
+
extra: {
|
|
106
|
+
ৎ: "t",
|
|
107
|
+
ৰ: "r",
|
|
108
|
+
ৱ: "v",
|
|
109
|
+
ୱ: "v",
|
|
110
|
+
"ੰ": "ṁ",
|
|
111
|
+
"ਂ": "ṁ",
|
|
112
|
+
ൺ: "ṇ",
|
|
113
|
+
ൻ: "n",
|
|
114
|
+
ർ: "r",
|
|
115
|
+
ൽ: "l",
|
|
116
|
+
ൾ: "l",
|
|
117
|
+
ൿ: "k",
|
|
118
|
+
ൔ: "m",
|
|
119
|
+
ൕ: "y",
|
|
120
|
+
ൖ: "l"
|
|
121
|
+
},
|
|
122
|
+
urdu: {
|
|
123
|
+
from: 1536,
|
|
124
|
+
to: 1791,
|
|
125
|
+
letters: {
|
|
126
|
+
ا: "a",
|
|
127
|
+
آ: "a",
|
|
128
|
+
أ: "a",
|
|
129
|
+
ب: "p",
|
|
130
|
+
پ: "p",
|
|
131
|
+
ت: "t",
|
|
132
|
+
ٹ: "ṭ",
|
|
133
|
+
ث: "s",
|
|
134
|
+
ج: "c",
|
|
135
|
+
چ: "c",
|
|
136
|
+
ح: "h",
|
|
137
|
+
خ: "k",
|
|
138
|
+
د: "t",
|
|
139
|
+
ڈ: "ṭ",
|
|
140
|
+
ذ: "c",
|
|
141
|
+
ر: "r",
|
|
142
|
+
ڑ: "ṭ",
|
|
143
|
+
ز: "c",
|
|
144
|
+
ژ: "c",
|
|
145
|
+
س: "s",
|
|
146
|
+
ش: "s",
|
|
147
|
+
ص: "s",
|
|
148
|
+
ض: "c",
|
|
149
|
+
ط: "t",
|
|
150
|
+
ظ: "c",
|
|
151
|
+
غ: "k",
|
|
152
|
+
ف: "p",
|
|
153
|
+
ق: "k",
|
|
154
|
+
ک: "k",
|
|
155
|
+
ك: "k",
|
|
156
|
+
گ: "k",
|
|
157
|
+
ل: "l",
|
|
158
|
+
م: "m",
|
|
159
|
+
ن: "n",
|
|
160
|
+
ں: "ṁ",
|
|
161
|
+
و: "v",
|
|
162
|
+
ؤ: "u",
|
|
163
|
+
ہ: "h",
|
|
164
|
+
ه: "h",
|
|
165
|
+
ۃ: "a",
|
|
166
|
+
ی: "y",
|
|
167
|
+
ي: "y",
|
|
168
|
+
ى: "y",
|
|
169
|
+
ئ: "y",
|
|
170
|
+
ے: "e",
|
|
171
|
+
ۓ: "e",
|
|
172
|
+
ٻ: "p",
|
|
173
|
+
ڀ: "p",
|
|
174
|
+
ٺ: "ṭ",
|
|
175
|
+
ٽ: "ṭ",
|
|
176
|
+
ٿ: "t",
|
|
177
|
+
ڄ: "c",
|
|
178
|
+
ڃ: "ñ",
|
|
179
|
+
ڇ: "c",
|
|
180
|
+
ڊ: "ṭ",
|
|
181
|
+
ڌ: "t",
|
|
182
|
+
ڍ: "ṭ",
|
|
183
|
+
ڏ: "t",
|
|
184
|
+
ڙ: "ṭ",
|
|
185
|
+
ڦ: "p",
|
|
186
|
+
ڪ: "k",
|
|
187
|
+
ڱ: "ṅ",
|
|
188
|
+
ڳ: "k",
|
|
189
|
+
ڻ: "ṇ",
|
|
190
|
+
ٲ: "a",
|
|
191
|
+
ٳ: "a",
|
|
192
|
+
ۆ: "o",
|
|
193
|
+
ۄ: "o",
|
|
194
|
+
ێ: "e",
|
|
195
|
+
ؠ: "y"
|
|
196
|
+
},
|
|
197
|
+
ain: "ع",
|
|
198
|
+
waw: "و",
|
|
199
|
+
waw_v_before: "اآ",
|
|
200
|
+
final_he: "ہه",
|
|
201
|
+
final_he_h_after: "اآو"
|
|
202
|
+
},
|
|
203
|
+
meetei: {
|
|
204
|
+
ranges: [
|
|
205
|
+
[
|
|
206
|
+
43744,
|
|
207
|
+
43775
|
|
208
|
+
],
|
|
209
|
+
[
|
|
210
|
+
43968,
|
|
211
|
+
44031
|
|
212
|
+
]
|
|
213
|
+
],
|
|
214
|
+
letters: {
|
|
215
|
+
ꯀ: "k",
|
|
216
|
+
ꯁ: "s",
|
|
217
|
+
ꯂ: "l",
|
|
218
|
+
ꯃ: "m",
|
|
219
|
+
ꯄ: "p",
|
|
220
|
+
ꯅ: "n",
|
|
221
|
+
ꯆ: "c",
|
|
222
|
+
ꯇ: "t",
|
|
223
|
+
ꯈ: "k",
|
|
224
|
+
ꯉ: "ṅ",
|
|
225
|
+
ꯊ: "t",
|
|
226
|
+
ꯋ: "v",
|
|
227
|
+
ꯌ: "y",
|
|
228
|
+
ꯍ: "h",
|
|
229
|
+
ꯎ: "u",
|
|
230
|
+
ꯏ: "i",
|
|
231
|
+
ꯐ: "p",
|
|
232
|
+
ꯑ: "a",
|
|
233
|
+
ꯒ: "k",
|
|
234
|
+
ꯓ: "c",
|
|
235
|
+
ꯔ: "r",
|
|
236
|
+
ꯕ: "p",
|
|
237
|
+
ꯖ: "c",
|
|
238
|
+
ꯗ: "t",
|
|
239
|
+
ꯘ: "k",
|
|
240
|
+
ꯙ: "t",
|
|
241
|
+
ꯚ: "p",
|
|
242
|
+
ꯛ: "k",
|
|
243
|
+
ꯜ: "l",
|
|
244
|
+
ꯝ: "m",
|
|
245
|
+
ꯞ: "p",
|
|
246
|
+
ꯟ: "n",
|
|
247
|
+
ꯠ: "t",
|
|
248
|
+
ꯡ: "ṅ",
|
|
249
|
+
ꯢ: "i",
|
|
250
|
+
"ꯣ": "o",
|
|
251
|
+
"ꯤ": "i",
|
|
252
|
+
"ꯥ": "a",
|
|
253
|
+
"ꯦ": "e",
|
|
254
|
+
"ꯧ": "o",
|
|
255
|
+
"ꯨ": "u",
|
|
256
|
+
"ꯩ": "e",
|
|
257
|
+
"ꯪ": "ṁ",
|
|
258
|
+
ꫠ: "e",
|
|
259
|
+
ꫡ: "o",
|
|
260
|
+
ꫢ: "c",
|
|
261
|
+
ꫣ: "ñ",
|
|
262
|
+
ꫤ: "ṭ",
|
|
263
|
+
ꫥ: "ṭ",
|
|
264
|
+
ꫦ: "ṭ",
|
|
265
|
+
ꫧ: "ṭ",
|
|
266
|
+
ꫨ: "ṇ",
|
|
267
|
+
ꫩ: "s",
|
|
268
|
+
ꫪ: "s",
|
|
269
|
+
"ꫫ": "i",
|
|
270
|
+
"ꫬ": "u",
|
|
271
|
+
"ꫭ": "e",
|
|
272
|
+
"ꫮ": "o",
|
|
273
|
+
"ꫯ": "o"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
ol_chiki: {
|
|
277
|
+
from: 7248,
|
|
278
|
+
to: 7295,
|
|
279
|
+
letters: {
|
|
280
|
+
ᱚ: "o",
|
|
281
|
+
ᱛ: "t",
|
|
282
|
+
ᱜ: "k",
|
|
283
|
+
ᱝ: "ṅ",
|
|
284
|
+
ᱞ: "l",
|
|
285
|
+
ᱟ: "a",
|
|
286
|
+
ᱠ: "k",
|
|
287
|
+
ᱡ: "c",
|
|
288
|
+
ᱢ: "m",
|
|
289
|
+
ᱣ: "v",
|
|
290
|
+
ᱤ: "i",
|
|
291
|
+
ᱥ: "s",
|
|
292
|
+
ᱦ: "h",
|
|
293
|
+
ᱧ: "ñ",
|
|
294
|
+
ᱨ: "r",
|
|
295
|
+
ᱩ: "u",
|
|
296
|
+
ᱪ: "c",
|
|
297
|
+
ᱫ: "t",
|
|
298
|
+
ᱬ: "ṇ",
|
|
299
|
+
ᱭ: "y",
|
|
300
|
+
ᱮ: "e",
|
|
301
|
+
ᱯ: "p",
|
|
302
|
+
ᱰ: "ṭ",
|
|
303
|
+
ᱱ: "n",
|
|
304
|
+
ᱲ: "ṭ",
|
|
305
|
+
ᱳ: "o",
|
|
306
|
+
ᱴ: "ṭ",
|
|
307
|
+
ᱵ: "p",
|
|
308
|
+
ᱶ: "v",
|
|
309
|
+
ᱷ: "h",
|
|
310
|
+
ᱸ: "ṁ"
|
|
311
|
+
},
|
|
312
|
+
aspiration: "ᱷ"
|
|
313
|
+
},
|
|
314
|
+
latin: {
|
|
315
|
+
groups: [
|
|
316
|
+
[
|
|
317
|
+
"chh",
|
|
318
|
+
"c"
|
|
319
|
+
],
|
|
320
|
+
[
|
|
321
|
+
"ch",
|
|
322
|
+
"c"
|
|
323
|
+
],
|
|
324
|
+
[
|
|
325
|
+
"jh",
|
|
326
|
+
"c"
|
|
327
|
+
],
|
|
328
|
+
[
|
|
329
|
+
"kh",
|
|
330
|
+
"k"
|
|
331
|
+
],
|
|
332
|
+
[
|
|
333
|
+
"gh",
|
|
334
|
+
"k"
|
|
335
|
+
],
|
|
336
|
+
[
|
|
337
|
+
"th",
|
|
338
|
+
"t"
|
|
339
|
+
],
|
|
340
|
+
[
|
|
341
|
+
"dh",
|
|
342
|
+
"t"
|
|
343
|
+
],
|
|
344
|
+
[
|
|
345
|
+
"ph",
|
|
346
|
+
"p"
|
|
347
|
+
],
|
|
348
|
+
[
|
|
349
|
+
"bh",
|
|
350
|
+
"p"
|
|
351
|
+
],
|
|
352
|
+
[
|
|
353
|
+
"sh",
|
|
354
|
+
"s"
|
|
355
|
+
],
|
|
356
|
+
[
|
|
357
|
+
"ck",
|
|
358
|
+
"k"
|
|
359
|
+
],
|
|
360
|
+
[
|
|
361
|
+
"aa",
|
|
362
|
+
"a"
|
|
363
|
+
],
|
|
364
|
+
[
|
|
365
|
+
"ai",
|
|
366
|
+
"e"
|
|
367
|
+
],
|
|
368
|
+
[
|
|
369
|
+
"ei",
|
|
370
|
+
"e"
|
|
371
|
+
],
|
|
372
|
+
[
|
|
373
|
+
"au",
|
|
374
|
+
"o"
|
|
375
|
+
],
|
|
376
|
+
[
|
|
377
|
+
"ee",
|
|
378
|
+
"i"
|
|
379
|
+
],
|
|
380
|
+
[
|
|
381
|
+
"oo",
|
|
382
|
+
"u"
|
|
383
|
+
],
|
|
384
|
+
[
|
|
385
|
+
"x",
|
|
386
|
+
"ks"
|
|
387
|
+
]
|
|
388
|
+
],
|
|
389
|
+
letters: {
|
|
390
|
+
a: "a",
|
|
391
|
+
e: "e",
|
|
392
|
+
i: "i",
|
|
393
|
+
o: "o",
|
|
394
|
+
u: "u",
|
|
395
|
+
k: "k",
|
|
396
|
+
g: "k",
|
|
397
|
+
q: "k",
|
|
398
|
+
j: "c",
|
|
399
|
+
z: "c",
|
|
400
|
+
t: "t",
|
|
401
|
+
d: "t",
|
|
402
|
+
n: "n",
|
|
403
|
+
m: "m",
|
|
404
|
+
p: "p",
|
|
405
|
+
b: "p",
|
|
406
|
+
f: "p",
|
|
407
|
+
v: "v",
|
|
408
|
+
w: "v",
|
|
409
|
+
y: "y",
|
|
410
|
+
r: "r",
|
|
411
|
+
l: "l",
|
|
412
|
+
s: "s",
|
|
413
|
+
h: "h"
|
|
414
|
+
},
|
|
415
|
+
w_ambiguous_unless_before: "aeiou"
|
|
416
|
+
},
|
|
417
|
+
class_map: {
|
|
418
|
+
m: "n",
|
|
419
|
+
s: "c",
|
|
420
|
+
v: "p",
|
|
421
|
+
w: "p",
|
|
422
|
+
ñ: "n",
|
|
423
|
+
ṁ: "n",
|
|
424
|
+
ṅ: "n",
|
|
425
|
+
ṇ: "n",
|
|
426
|
+
ṭ: "t"
|
|
427
|
+
},
|
|
428
|
+
vowels: "aeiou",
|
|
429
|
+
steps: {
|
|
430
|
+
"ng-k": true,
|
|
431
|
+
"initial-vowels-alike": false,
|
|
432
|
+
"drop-h": false,
|
|
433
|
+
"drop-y": true,
|
|
434
|
+
"drop-y-after-i": false,
|
|
435
|
+
"drop-vowels": true,
|
|
436
|
+
"drop-final-vowel": false
|
|
437
|
+
},
|
|
438
|
+
branches: [
|
|
439
|
+
{
|
|
440
|
+
from: 0,
|
|
441
|
+
to: 127,
|
|
442
|
+
class: "w",
|
|
443
|
+
also: "u"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
from: 2944,
|
|
447
|
+
to: 3071,
|
|
448
|
+
class: "k",
|
|
449
|
+
also: "h"
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
from: 1536,
|
|
453
|
+
to: 1791,
|
|
454
|
+
class: "w",
|
|
455
|
+
also: "u"
|
|
456
|
+
}
|
|
457
|
+
],
|
|
458
|
+
max_keys: 16,
|
|
459
|
+
suffixes: [
|
|
460
|
+
{
|
|
461
|
+
from: 2432,
|
|
462
|
+
to: 2559,
|
|
463
|
+
endings: [
|
|
464
|
+
"য়ের",
|
|
465
|
+
"দের",
|
|
466
|
+
"এর",
|
|
467
|
+
"ের",
|
|
468
|
+
"কে",
|
|
469
|
+
"তে"
|
|
470
|
+
]
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
from: 2688,
|
|
474
|
+
to: 2815,
|
|
475
|
+
endings: [
|
|
476
|
+
"માં",
|
|
477
|
+
"નું",
|
|
478
|
+
"થી",
|
|
479
|
+
"ના",
|
|
480
|
+
"ની",
|
|
481
|
+
"ને"
|
|
482
|
+
]
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
from: 3328,
|
|
486
|
+
to: 3455,
|
|
487
|
+
endings: [
|
|
488
|
+
"യ്ക്ക്",
|
|
489
|
+
"ന്റെ",
|
|
490
|
+
"യുടെ",
|
|
491
|
+
"യിലെ",
|
|
492
|
+
"ക്ക്",
|
|
493
|
+
"ുടെ",
|
|
494
|
+
"യിൽ",
|
|
495
|
+
"ിലെ",
|
|
496
|
+
"ോട്",
|
|
497
|
+
"ിന്",
|
|
498
|
+
"ിൽ",
|
|
499
|
+
"നെ",
|
|
500
|
+
"യെ",
|
|
501
|
+
"ും"
|
|
502
|
+
]
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
from: 2816,
|
|
506
|
+
to: 2943,
|
|
507
|
+
endings: [
|
|
508
|
+
"ଙ୍କର",
|
|
509
|
+
"ଙ୍କୁ",
|
|
510
|
+
"ଙ୍କ",
|
|
511
|
+
"ରେ",
|
|
512
|
+
"ରୁ",
|
|
513
|
+
"କୁ"
|
|
514
|
+
]
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
from: 2944,
|
|
518
|
+
to: 3071,
|
|
519
|
+
endings: [
|
|
520
|
+
"ுக்கு",
|
|
521
|
+
"யின்",
|
|
522
|
+
"வின்",
|
|
523
|
+
"க்கு",
|
|
524
|
+
"யில்",
|
|
525
|
+
"ிடம்",
|
|
526
|
+
"ுடன்",
|
|
527
|
+
"ின்",
|
|
528
|
+
"ில்",
|
|
529
|
+
"ால்",
|
|
530
|
+
"ும்"
|
|
531
|
+
]
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
from: 3072,
|
|
535
|
+
to: 3199,
|
|
536
|
+
endings: [
|
|
537
|
+
"యొక్క",
|
|
538
|
+
"లోని",
|
|
539
|
+
"గారు",
|
|
540
|
+
"లో",
|
|
541
|
+
"కు",
|
|
542
|
+
"కి",
|
|
543
|
+
"ని",
|
|
544
|
+
"తో",
|
|
545
|
+
"ను"
|
|
546
|
+
]
|
|
547
|
+
}
|
|
548
|
+
]
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
// js/phonetic.ts
|
|
552
|
+
function compile(rules) {
|
|
553
|
+
const b = rules.brahmic;
|
|
554
|
+
const byOffset = new Array(128);
|
|
555
|
+
for (const [o, c] of Object.entries(b.class_by_offset))
|
|
556
|
+
byOffset[Number(o)] = c;
|
|
557
|
+
const extra = new Map(Object.entries(rules.extra));
|
|
558
|
+
const urdu = new Map(Object.entries(rules.urdu.letters));
|
|
559
|
+
const meetei = new Map(Object.entries(rules.meetei.letters));
|
|
560
|
+
const olChiki = new Map(Object.entries(rules.ol_chiki.letters));
|
|
561
|
+
const latin = new Array(128);
|
|
562
|
+
for (const [l, c] of Object.entries(rules.latin.letters))
|
|
563
|
+
latin[l.charCodeAt(0)] = c;
|
|
564
|
+
const groups = rules.latin.groups;
|
|
565
|
+
const wUnlessNext = rules.latin.w_ambiguous_unless_before;
|
|
566
|
+
const classMap = new Map(Object.entries(rules.class_map));
|
|
567
|
+
const vowels = new Set(rules.vowels);
|
|
568
|
+
const steps = rules.steps;
|
|
569
|
+
const u = rules.urdu;
|
|
570
|
+
function inMeetei(o) {
|
|
571
|
+
return rules.meetei.ranges.some(([lo, hi]) => o >= lo && o <= hi);
|
|
572
|
+
}
|
|
573
|
+
function readBrahmic(word) {
|
|
574
|
+
let out = "";
|
|
575
|
+
for (let i = 0;i < word.length; i++) {
|
|
576
|
+
const ch = word[i];
|
|
577
|
+
const x = extra.get(ch);
|
|
578
|
+
if (x !== undefined) {
|
|
579
|
+
out += x;
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
const o = word.charCodeAt(i);
|
|
583
|
+
if (o < b.from || o > b.to)
|
|
584
|
+
continue;
|
|
585
|
+
const off = o & 127;
|
|
586
|
+
if (off === b.virama_offset)
|
|
587
|
+
continue;
|
|
588
|
+
if (off === b.candrabindu_offset) {
|
|
589
|
+
out += b.candrabindu_class;
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
const c = byOffset[off];
|
|
593
|
+
if (c !== undefined)
|
|
594
|
+
out += c;
|
|
595
|
+
}
|
|
596
|
+
return out;
|
|
597
|
+
}
|
|
598
|
+
function readLatin(word) {
|
|
599
|
+
let out = "";
|
|
600
|
+
let i = 0;
|
|
601
|
+
outer:
|
|
602
|
+
while (i < word.length) {
|
|
603
|
+
for (const [g, cls] of groups) {
|
|
604
|
+
if (word.startsWith(g, i)) {
|
|
605
|
+
out += cls;
|
|
606
|
+
i += g.length;
|
|
607
|
+
continue outer;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const ch = word.charCodeAt(i);
|
|
611
|
+
if (ch === 99) {
|
|
612
|
+
const next = word[i + 1];
|
|
613
|
+
out += next === "e" || next === "i" || next === "y" ? "s" : "k";
|
|
614
|
+
} else if (ch === 119 && i > 0 && !wUnlessNext.includes(word[i + 1] ?? " ")) {
|
|
615
|
+
out += "w";
|
|
616
|
+
} else {
|
|
617
|
+
out += latin[ch] ?? "";
|
|
618
|
+
}
|
|
619
|
+
i++;
|
|
620
|
+
}
|
|
621
|
+
return out;
|
|
622
|
+
}
|
|
623
|
+
function readUrdu(word) {
|
|
624
|
+
let out = word[0] === u.ain ? "a" : "";
|
|
625
|
+
for (let i = 0;i < word.length; i++) {
|
|
626
|
+
const ch = word[i];
|
|
627
|
+
if (ch === u.waw && i > 0 && !(i + 1 < word.length && u.waw_v_before.includes(word[i + 1])))
|
|
628
|
+
out += "w";
|
|
629
|
+
else
|
|
630
|
+
out += urdu.get(ch) ?? "";
|
|
631
|
+
}
|
|
632
|
+
const n = word.length;
|
|
633
|
+
if (n > 1 && u.final_he.includes(word[n - 1]) && !u.final_he_h_after.includes(word[n - 2])) {
|
|
634
|
+
out = out.slice(0, -1) + "a";
|
|
635
|
+
}
|
|
636
|
+
return out;
|
|
637
|
+
}
|
|
638
|
+
function readOlChiki(word) {
|
|
639
|
+
let out = "";
|
|
640
|
+
for (const ch of word) {
|
|
641
|
+
if (ch === rules.ol_chiki.aspiration && out && !vowels.has(out[out.length - 1]))
|
|
642
|
+
continue;
|
|
643
|
+
out += olChiki.get(ch) ?? "";
|
|
644
|
+
}
|
|
645
|
+
return out;
|
|
646
|
+
}
|
|
647
|
+
function readMeetei(word) {
|
|
648
|
+
let out = "";
|
|
649
|
+
for (const ch of word)
|
|
650
|
+
out += meetei.get(ch) ?? "";
|
|
651
|
+
return out;
|
|
652
|
+
}
|
|
653
|
+
function read(word) {
|
|
654
|
+
let ascii = true;
|
|
655
|
+
for (let i = 0;i < word.length; i++)
|
|
656
|
+
if (word.charCodeAt(i) > 127) {
|
|
657
|
+
ascii = false;
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
if (ascii)
|
|
661
|
+
return readLatin(word);
|
|
662
|
+
let ol = false, me = false;
|
|
663
|
+
for (let i = 0;i < word.length; i++) {
|
|
664
|
+
const o = word.charCodeAt(i);
|
|
665
|
+
if (o >= u.from && o <= u.to)
|
|
666
|
+
return readUrdu(word);
|
|
667
|
+
if (o >= rules.ol_chiki.from && o <= rules.ol_chiki.to)
|
|
668
|
+
ol = true;
|
|
669
|
+
else if (inMeetei(o))
|
|
670
|
+
me = true;
|
|
671
|
+
}
|
|
672
|
+
if (ol)
|
|
673
|
+
return readOlChiki(word);
|
|
674
|
+
if (me)
|
|
675
|
+
return readMeetei(word);
|
|
676
|
+
return readBrahmic(word);
|
|
677
|
+
}
|
|
678
|
+
function fold(codes) {
|
|
679
|
+
if (steps["ng-k"]) {
|
|
680
|
+
let s = "";
|
|
681
|
+
for (let i = 0;i < codes.length; i++) {
|
|
682
|
+
s += codes[i];
|
|
683
|
+
if (codes[i] === "ṅ" && codes[i + 1] !== "k")
|
|
684
|
+
s += "k";
|
|
685
|
+
}
|
|
686
|
+
codes = s;
|
|
687
|
+
}
|
|
688
|
+
let mapped = "";
|
|
689
|
+
for (let i = 0;i < codes.length; i++)
|
|
690
|
+
mapped += classMap.get(codes[i]) ?? codes[i];
|
|
691
|
+
if (!mapped)
|
|
692
|
+
return mapped;
|
|
693
|
+
let head = mapped[0];
|
|
694
|
+
if (steps["initial-vowels-alike"] && vowels.has(head))
|
|
695
|
+
head = "a";
|
|
696
|
+
let out = head;
|
|
697
|
+
for (let i = 1;i < mapped.length; i++) {
|
|
698
|
+
const c = mapped[i];
|
|
699
|
+
if (steps["drop-h"] && c === "h")
|
|
700
|
+
continue;
|
|
701
|
+
if (steps["drop-y"] && c === "y")
|
|
702
|
+
continue;
|
|
703
|
+
if (steps["drop-vowels"] && vowels.has(c))
|
|
704
|
+
continue;
|
|
705
|
+
out += c;
|
|
706
|
+
}
|
|
707
|
+
if (steps["drop-final-vowel"] && out.length > 1 && vowels.has(out[out.length - 1]))
|
|
708
|
+
out = out.slice(0, -1);
|
|
709
|
+
let runs = out[0];
|
|
710
|
+
for (let i = 1;i < out.length; i++)
|
|
711
|
+
if (out[i] !== out[i - 1])
|
|
712
|
+
runs += out[i];
|
|
713
|
+
return runs;
|
|
714
|
+
}
|
|
715
|
+
function variants(word) {
|
|
716
|
+
const classes = read(word);
|
|
717
|
+
let vs = [classes];
|
|
718
|
+
for (const br of rules.branches) {
|
|
719
|
+
if (!classes.includes(br.class))
|
|
720
|
+
continue;
|
|
721
|
+
let inScript = false;
|
|
722
|
+
for (let i = 0;i < word.length; i++) {
|
|
723
|
+
const o = word.charCodeAt(i);
|
|
724
|
+
if (o >= br.from && o <= br.to) {
|
|
725
|
+
inScript = true;
|
|
726
|
+
break;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
if (!inScript)
|
|
730
|
+
continue;
|
|
731
|
+
for (let i = 0;i < classes.length; i++) {
|
|
732
|
+
if (classes[i] === br.class && vs.length * 2 <= rules.max_keys) {
|
|
733
|
+
vs = vs.concat(vs.map((v) => v.slice(0, i) + br.also + v.slice(i + 1)));
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
return vs;
|
|
738
|
+
}
|
|
739
|
+
return function keys(word) {
|
|
740
|
+
const bases = [word];
|
|
741
|
+
const first = word.charCodeAt(0);
|
|
742
|
+
for (const sf of rules.suffixes) {
|
|
743
|
+
if (first < sf.from || first > sf.to)
|
|
744
|
+
continue;
|
|
745
|
+
for (const e of sf.endings) {
|
|
746
|
+
if (word.endsWith(e) && word.length - e.length >= 2) {
|
|
747
|
+
bases.push(word.slice(0, -e.length));
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
const out = new Set;
|
|
753
|
+
for (const base of bases)
|
|
754
|
+
for (const v of variants(base))
|
|
755
|
+
out.add(fold(v));
|
|
756
|
+
return [...out].sort();
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
var engine = compile(rules_default);
|
|
760
|
+
var RULES_VERSION = rules_default.version;
|
|
761
|
+
var MAX_NAME_KEYS = 256;
|
|
762
|
+
function normalize(word) {
|
|
763
|
+
const plain = word.normalize("NFD").replace(/\p{Mn}/gu, "");
|
|
764
|
+
return /^[\x00-\x7f]*$/.test(plain) ? plain.toLowerCase() : word.normalize("NFC");
|
|
765
|
+
}
|
|
766
|
+
function keys(word) {
|
|
767
|
+
const w = normalize(word);
|
|
768
|
+
return w ? engine(w) : [];
|
|
769
|
+
}
|
|
770
|
+
function words(name) {
|
|
771
|
+
return name.replace(/\([^)]*\)/g, " ").split(/[\s.\-,'’]+/u).filter(Boolean);
|
|
772
|
+
}
|
|
773
|
+
function nameKeys(name) {
|
|
774
|
+
let out = [""];
|
|
775
|
+
for (const w of words(name)) {
|
|
776
|
+
const ks = keys(w);
|
|
777
|
+
if (!ks.length)
|
|
778
|
+
continue;
|
|
779
|
+
const next = [];
|
|
780
|
+
for (const p of out)
|
|
781
|
+
for (const k of ks) {
|
|
782
|
+
if (next.length < MAX_NAME_KEYS)
|
|
783
|
+
next.push(p ? p + " " + k : k);
|
|
784
|
+
}
|
|
785
|
+
out = next;
|
|
786
|
+
}
|
|
787
|
+
return out[0] === "" ? [] : out;
|
|
788
|
+
}
|
|
789
|
+
function match(a, b) {
|
|
790
|
+
const wa = words(a), wb = words(b);
|
|
791
|
+
if (!wa.length || wa.length !== wb.length)
|
|
792
|
+
return false;
|
|
793
|
+
return wa.every((w, i) => {
|
|
794
|
+
const kb = new Set(keys(wb[i]));
|
|
795
|
+
return keys(w).some((k) => kb.has(k));
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
export {
|
|
799
|
+
words,
|
|
800
|
+
nameKeys,
|
|
801
|
+
match,
|
|
802
|
+
keys,
|
|
803
|
+
RULES_VERSION,
|
|
804
|
+
MAX_NAME_KEYS
|
|
805
|
+
};
|