@delali/narsil 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/LICENSE +201 -0
- package/dist/adapters/filesystem.d.ts +8 -0
- package/dist/adapters/filesystem.mjs +107 -0
- package/dist/adapters/indexeddb.d.ts +9 -0
- package/dist/adapters/indexeddb.mjs +153 -0
- package/dist/adapters/memory.d.ts +5 -0
- package/dist/adapters/memory.mjs +30 -0
- package/dist/adapters-XODT2F3h.d.ts +30 -0
- package/dist/chunk-5HXMVMSM.mjs +3147 -0
- package/dist/chunk-JKIBUPAY.mjs +42 -0
- package/dist/chunk-N37VMC62.mjs +18 -0
- package/dist/chunk-WYC635GI.mjs +335 -0
- package/dist/direct-executor-MQD7JRD4.mjs +3 -0
- package/dist/index.d.ts +386 -0
- package/dist/index.mjs +1099 -0
- package/dist/invalidation/broadcast-channel.d.ts +8 -0
- package/dist/invalidation/broadcast-channel.mjs +46 -0
- package/dist/invalidation/filesystem.d.ts +10 -0
- package/dist/invalidation/filesystem.mjs +159 -0
- package/dist/invalidation/noop.d.ts +5 -0
- package/dist/invalidation/noop.mjs +13 -0
- package/dist/language-ClUGLuoC.d.ts +13 -0
- package/dist/languages/arabic.d.ts +5 -0
- package/dist/languages/arabic.mjs +631 -0
- package/dist/languages/armenian.d.ts +5 -0
- package/dist/languages/armenian.mjs +306 -0
- package/dist/languages/bulgarian.d.ts +5 -0
- package/dist/languages/bulgarian.mjs +330 -0
- package/dist/languages/chinese.d.ts +5 -0
- package/dist/languages/chinese.mjs +250 -0
- package/dist/languages/dagbani.d.ts +5 -0
- package/dist/languages/dagbani.mjs +85 -0
- package/dist/languages/danish.d.ts +5 -0
- package/dist/languages/danish.mjs +224 -0
- package/dist/languages/dutch.d.ts +5 -0
- package/dist/languages/dutch.mjs +296 -0
- package/dist/languages/english.d.ts +5 -0
- package/dist/languages/english.mjs +1 -0
- package/dist/languages/ewe.d.ts +5 -0
- package/dist/languages/ewe.mjs +85 -0
- package/dist/languages/finnish.d.ts +5 -0
- package/dist/languages/finnish.mjs +536 -0
- package/dist/languages/french.d.ts +5 -0
- package/dist/languages/french.mjs +635 -0
- package/dist/languages/ga.d.ts +5 -0
- package/dist/languages/ga.mjs +69 -0
- package/dist/languages/german.d.ts +5 -0
- package/dist/languages/german.mjs +414 -0
- package/dist/languages/greek.d.ts +5 -0
- package/dist/languages/greek.mjs +888 -0
- package/dist/languages/hausa.d.ts +5 -0
- package/dist/languages/hausa.mjs +243 -0
- package/dist/languages/hindi.d.ts +5 -0
- package/dist/languages/hindi.mjs +333 -0
- package/dist/languages/hungarian.d.ts +5 -0
- package/dist/languages/hungarian.mjs +600 -0
- package/dist/languages/igbo.d.ts +5 -0
- package/dist/languages/igbo.mjs +96 -0
- package/dist/languages/indonesian.d.ts +5 -0
- package/dist/languages/indonesian.mjs +896 -0
- package/dist/languages/irish.d.ts +5 -0
- package/dist/languages/irish.mjs +268 -0
- package/dist/languages/italian.d.ts +5 -0
- package/dist/languages/italian.mjs +713 -0
- package/dist/languages/japanese.d.ts +5 -0
- package/dist/languages/japanese.mjs +210 -0
- package/dist/languages/nepali.d.ts +5 -0
- package/dist/languages/nepali.mjs +262 -0
- package/dist/languages/norwegian.d.ts +5 -0
- package/dist/languages/norwegian.mjs +274 -0
- package/dist/languages/portuguese.d.ts +5 -0
- package/dist/languages/portuguese.mjs +606 -0
- package/dist/languages/romanian.d.ts +5 -0
- package/dist/languages/romanian.mjs +634 -0
- package/dist/languages/russian.d.ts +5 -0
- package/dist/languages/russian.mjs +424 -0
- package/dist/languages/sanskrit.d.ts +5 -0
- package/dist/languages/sanskrit.mjs +155 -0
- package/dist/languages/serbian.d.ts +5 -0
- package/dist/languages/serbian.mjs +277 -0
- package/dist/languages/slovenian.d.ts +5 -0
- package/dist/languages/slovenian.mjs +522 -0
- package/dist/languages/spanish.d.ts +5 -0
- package/dist/languages/spanish.mjs +606 -0
- package/dist/languages/swahili.d.ts +5 -0
- package/dist/languages/swahili.mjs +212 -0
- package/dist/languages/swedish.d.ts +5 -0
- package/dist/languages/swedish.mjs +224 -0
- package/dist/languages/tamil.d.ts +5 -0
- package/dist/languages/tamil.mjs +186 -0
- package/dist/languages/turkish.d.ts +5 -0
- package/dist/languages/turkish.mjs +675 -0
- package/dist/languages/twi.d.ts +5 -0
- package/dist/languages/twi.mjs +84 -0
- package/dist/languages/ukrainian.d.ts +5 -0
- package/dist/languages/ukrainian.mjs +444 -0
- package/dist/languages/yoruba.d.ts +5 -0
- package/dist/languages/yoruba.mjs +103 -0
- package/dist/languages/zulu.d.ts +5 -0
- package/dist/languages/zulu.mjs +113 -0
- package/dist/workers/entry.d.ts +3 -0
- package/dist/workers/entry.mjs +106 -0
- package/package.json +87 -0
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
// src/languages/french.ts
|
|
2
|
+
var VOWELS = "aeiouy\xE2\xE0\xEB\xE9\xE8\xEF\xEE\xF4\xF9\xFB\xFC";
|
|
3
|
+
function isVowel(ch) {
|
|
4
|
+
return VOWELS.includes(ch);
|
|
5
|
+
}
|
|
6
|
+
function findRegions(word) {
|
|
7
|
+
let rv = word.length;
|
|
8
|
+
let r1 = word.length;
|
|
9
|
+
let r2 = word.length;
|
|
10
|
+
if (word.length >= 2 && isVowel(word[0]) && isVowel(word[1])) {
|
|
11
|
+
rv = 3;
|
|
12
|
+
} else if (word.startsWith("par") || word.startsWith("col") || word.startsWith("tap")) {
|
|
13
|
+
rv = 3;
|
|
14
|
+
} else {
|
|
15
|
+
for (let i = 1; i < word.length; i++) {
|
|
16
|
+
if (isVowel(word[i])) {
|
|
17
|
+
rv = i + 1;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
for (let i = 0; i < word.length - 1; i++) {
|
|
23
|
+
if (isVowel(word[i]) && !isVowel(word[i + 1])) {
|
|
24
|
+
r1 = i + 2;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (let i = r1; i < word.length - 1; i++) {
|
|
29
|
+
if (isVowel(word[i]) && !isVowel(word[i + 1])) {
|
|
30
|
+
r2 = i + 2;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { rv, r1, r2 };
|
|
35
|
+
}
|
|
36
|
+
function markVowelConsonantForms(word) {
|
|
37
|
+
const chars = word.split("");
|
|
38
|
+
for (let i = 0; i < chars.length; i++) {
|
|
39
|
+
if (chars[i] === "u" && i > 0 && i < chars.length - 1 && isVowel(chars[i - 1]) && isVowel(chars[i + 1])) {
|
|
40
|
+
chars[i] = "U";
|
|
41
|
+
}
|
|
42
|
+
if (chars[i] === "i" && i > 0 && i < chars.length - 1 && isVowel(chars[i - 1]) && isVowel(chars[i + 1])) {
|
|
43
|
+
chars[i] = "I";
|
|
44
|
+
}
|
|
45
|
+
if (chars[i] === "y" && i > 0 && isVowel(chars[i - 1])) {
|
|
46
|
+
chars[i] = "Y";
|
|
47
|
+
}
|
|
48
|
+
if (chars[i] === "y" && i < chars.length - 1 && isVowel(chars[i + 1])) {
|
|
49
|
+
chars[i] = "Y";
|
|
50
|
+
}
|
|
51
|
+
if (chars[i] === "u" && i > 0 && chars[i - 1] === "q") {
|
|
52
|
+
chars[i] = "U";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return chars.join("");
|
|
56
|
+
}
|
|
57
|
+
function restoreMarkedLetters(word) {
|
|
58
|
+
return word.replace(/I/g, "i").replace(/U/g, "u").replace(/Y/g, "y");
|
|
59
|
+
}
|
|
60
|
+
function endsWith(word, suffix) {
|
|
61
|
+
return word.endsWith(suffix);
|
|
62
|
+
}
|
|
63
|
+
function removeSuffix(word, suffix) {
|
|
64
|
+
return word.slice(0, word.length - suffix.length);
|
|
65
|
+
}
|
|
66
|
+
function suffixInRegion(word, suffix, regionStart) {
|
|
67
|
+
return word.length - suffix.length >= regionStart;
|
|
68
|
+
}
|
|
69
|
+
function findLongestAmong(word, suffixes, regionStart) {
|
|
70
|
+
let longestMatch = null;
|
|
71
|
+
for (const suffix of suffixes) {
|
|
72
|
+
if (endsWith(word, suffix) && suffixInRegion(word, suffix, regionStart)) {
|
|
73
|
+
if (longestMatch === null || suffix.length > longestMatch.length) {
|
|
74
|
+
longestMatch = suffix;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return longestMatch;
|
|
79
|
+
}
|
|
80
|
+
function step1StandardSuffix(word, rv, r1, r2) {
|
|
81
|
+
const standardSuffixes = [
|
|
82
|
+
"issements",
|
|
83
|
+
"issement",
|
|
84
|
+
"atrices",
|
|
85
|
+
"atrice",
|
|
86
|
+
"ateurs",
|
|
87
|
+
"ateur",
|
|
88
|
+
"ations",
|
|
89
|
+
"ation",
|
|
90
|
+
"usions",
|
|
91
|
+
"ution",
|
|
92
|
+
"usion",
|
|
93
|
+
"utions",
|
|
94
|
+
"logies",
|
|
95
|
+
"logie",
|
|
96
|
+
"ements",
|
|
97
|
+
"ement",
|
|
98
|
+
"ences",
|
|
99
|
+
"ence",
|
|
100
|
+
"ances",
|
|
101
|
+
"ance",
|
|
102
|
+
"ables",
|
|
103
|
+
"able",
|
|
104
|
+
"ismes",
|
|
105
|
+
"isme",
|
|
106
|
+
"istes",
|
|
107
|
+
"iste",
|
|
108
|
+
"euses",
|
|
109
|
+
"euse",
|
|
110
|
+
"ments",
|
|
111
|
+
"ment",
|
|
112
|
+
"iqUes",
|
|
113
|
+
"iqUe",
|
|
114
|
+
"it\xE9s",
|
|
115
|
+
"it\xE9",
|
|
116
|
+
"ives",
|
|
117
|
+
"ive",
|
|
118
|
+
"eaux",
|
|
119
|
+
"ifs",
|
|
120
|
+
"if",
|
|
121
|
+
"aux",
|
|
122
|
+
"eux"
|
|
123
|
+
];
|
|
124
|
+
const suffix = findLongestAmong(word, standardSuffixes, 0);
|
|
125
|
+
if (!suffix) return { word, changed: false };
|
|
126
|
+
if (["ance", "ances", "iqUe", "iqUes", "isme", "ismes", "able", "ables", "iste", "istes"].includes(suffix)) {
|
|
127
|
+
if (suffixInRegion(word, suffix, r2)) {
|
|
128
|
+
return { word: removeSuffix(word, suffix), changed: true };
|
|
129
|
+
}
|
|
130
|
+
return { word, changed: false };
|
|
131
|
+
}
|
|
132
|
+
if (["atrice", "atrices", "ateur", "ateurs", "ation", "ations"].includes(suffix)) {
|
|
133
|
+
if (suffixInRegion(word, suffix, r2)) {
|
|
134
|
+
word = removeSuffix(word, suffix);
|
|
135
|
+
if (endsWith(word, "ic")) {
|
|
136
|
+
if (suffixInRegion(word, "ic", r2)) {
|
|
137
|
+
word = removeSuffix(word, "ic");
|
|
138
|
+
} else {
|
|
139
|
+
word = `${removeSuffix(word, "ic")}iqU`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { word, changed: true };
|
|
143
|
+
}
|
|
144
|
+
return { word, changed: false };
|
|
145
|
+
}
|
|
146
|
+
if (["logie", "logies"].includes(suffix)) {
|
|
147
|
+
if (suffixInRegion(word, suffix, r2)) {
|
|
148
|
+
return { word: `${removeSuffix(word, suffix)}log`, changed: true };
|
|
149
|
+
}
|
|
150
|
+
return { word, changed: false };
|
|
151
|
+
}
|
|
152
|
+
if (["usion", "usions", "ution", "utions"].includes(suffix)) {
|
|
153
|
+
if (suffixInRegion(word, suffix, r2)) {
|
|
154
|
+
return { word: `${removeSuffix(word, suffix)}u`, changed: true };
|
|
155
|
+
}
|
|
156
|
+
return { word, changed: false };
|
|
157
|
+
}
|
|
158
|
+
if (["ence", "ences"].includes(suffix)) {
|
|
159
|
+
if (suffixInRegion(word, suffix, r2)) {
|
|
160
|
+
return { word: `${removeSuffix(word, suffix)}ent`, changed: true };
|
|
161
|
+
}
|
|
162
|
+
return { word, changed: false };
|
|
163
|
+
}
|
|
164
|
+
if (suffix === "ement" || suffix === "ements") {
|
|
165
|
+
if (suffixInRegion(word, suffix, rv)) {
|
|
166
|
+
word = removeSuffix(word, suffix);
|
|
167
|
+
if (endsWith(word, "iv") && suffixInRegion(word, "iv", r2)) {
|
|
168
|
+
word = removeSuffix(word, "iv");
|
|
169
|
+
if (endsWith(word, "at") && suffixInRegion(word, "at", r2)) {
|
|
170
|
+
word = removeSuffix(word, "at");
|
|
171
|
+
}
|
|
172
|
+
} else if (endsWith(word, "eus")) {
|
|
173
|
+
if (suffixInRegion(word, "eus", r2)) {
|
|
174
|
+
word = removeSuffix(word, "eus");
|
|
175
|
+
} else if (suffixInRegion(word, "eus", r1)) {
|
|
176
|
+
word = `${removeSuffix(word, "eus")}eux`;
|
|
177
|
+
}
|
|
178
|
+
} else if (endsWith(word, "abl") && suffixInRegion(word, "abl", r2)) {
|
|
179
|
+
word = removeSuffix(word, "abl");
|
|
180
|
+
} else if (endsWith(word, "iqU") && suffixInRegion(word, "iqU", r2)) {
|
|
181
|
+
word = removeSuffix(word, "iqU");
|
|
182
|
+
} else if ((endsWith(word, "i\xE8r") || endsWith(word, "I\xE8r")) && suffixInRegion(word, "i\xE8r", rv)) {
|
|
183
|
+
const sSuffix = endsWith(word, "I\xE8r") ? "I\xE8r" : "i\xE8r";
|
|
184
|
+
word = `${removeSuffix(word, sSuffix)}i`;
|
|
185
|
+
}
|
|
186
|
+
return { word, changed: true };
|
|
187
|
+
}
|
|
188
|
+
return { word, changed: false };
|
|
189
|
+
}
|
|
190
|
+
if (["it\xE9", "it\xE9s"].includes(suffix)) {
|
|
191
|
+
if (suffixInRegion(word, suffix, r2)) {
|
|
192
|
+
word = removeSuffix(word, suffix);
|
|
193
|
+
if (endsWith(word, "abil") && suffixInRegion(word, "abil", r2)) {
|
|
194
|
+
word = removeSuffix(word, "abil");
|
|
195
|
+
} else if (endsWith(word, "abil")) {
|
|
196
|
+
word = `${removeSuffix(word, "abil")}abl`;
|
|
197
|
+
} else if (endsWith(word, "ic")) {
|
|
198
|
+
if (suffixInRegion(word, "ic", r2)) {
|
|
199
|
+
word = removeSuffix(word, "ic");
|
|
200
|
+
} else {
|
|
201
|
+
word = `${removeSuffix(word, "ic")}iqU`;
|
|
202
|
+
}
|
|
203
|
+
} else if (endsWith(word, "iv") && suffixInRegion(word, "iv", r2)) {
|
|
204
|
+
word = removeSuffix(word, "iv");
|
|
205
|
+
}
|
|
206
|
+
return { word, changed: true };
|
|
207
|
+
}
|
|
208
|
+
return { word, changed: false };
|
|
209
|
+
}
|
|
210
|
+
if (["if", "ifs", "ive", "ives"].includes(suffix)) {
|
|
211
|
+
if (suffixInRegion(word, suffix, r2)) {
|
|
212
|
+
word = removeSuffix(word, suffix);
|
|
213
|
+
if (endsWith(word, "at") && suffixInRegion(word, "at", r2)) {
|
|
214
|
+
word = removeSuffix(word, "at");
|
|
215
|
+
if (endsWith(word, "ic")) {
|
|
216
|
+
if (suffixInRegion(word, "ic", r2)) {
|
|
217
|
+
word = removeSuffix(word, "ic");
|
|
218
|
+
} else {
|
|
219
|
+
word = `${removeSuffix(word, "ic")}iqU`;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return { word, changed: true };
|
|
224
|
+
}
|
|
225
|
+
return { word, changed: false };
|
|
226
|
+
}
|
|
227
|
+
if (suffix === "eaux") {
|
|
228
|
+
return { word: `${removeSuffix(word, "eaux")}eau`, changed: true };
|
|
229
|
+
}
|
|
230
|
+
if (suffix === "aux") {
|
|
231
|
+
if (suffixInRegion(word, suffix, r1)) {
|
|
232
|
+
return { word: `${removeSuffix(word, "aux")}al`, changed: true };
|
|
233
|
+
}
|
|
234
|
+
return { word, changed: false };
|
|
235
|
+
}
|
|
236
|
+
if (["euse", "euses"].includes(suffix)) {
|
|
237
|
+
if (suffixInRegion(word, suffix, r2)) {
|
|
238
|
+
return { word: removeSuffix(word, suffix), changed: true };
|
|
239
|
+
}
|
|
240
|
+
if (suffixInRegion(word, suffix, r1)) {
|
|
241
|
+
return { word: `${removeSuffix(word, suffix)}eux`, changed: true };
|
|
242
|
+
}
|
|
243
|
+
return { word, changed: false };
|
|
244
|
+
}
|
|
245
|
+
if (suffix === "issement" || suffix === "issements") {
|
|
246
|
+
if (suffixInRegion(word, suffix, r1)) {
|
|
247
|
+
const stemmed = removeSuffix(word, suffix);
|
|
248
|
+
if (stemmed.length > 0 && !isVowel(stemmed[stemmed.length - 1])) {
|
|
249
|
+
return { word: stemmed, changed: true };
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return { word, changed: false };
|
|
253
|
+
}
|
|
254
|
+
if (suffix === "amment") {
|
|
255
|
+
if (suffixInRegion(word, suffix, rv)) {
|
|
256
|
+
return { word: `${removeSuffix(word, "amment")}ant`, changed: true };
|
|
257
|
+
}
|
|
258
|
+
return { word, changed: false };
|
|
259
|
+
}
|
|
260
|
+
if (suffix === "emment") {
|
|
261
|
+
if (suffixInRegion(word, suffix, rv)) {
|
|
262
|
+
return { word: `${removeSuffix(word, "emment")}ent`, changed: true };
|
|
263
|
+
}
|
|
264
|
+
return { word, changed: false };
|
|
265
|
+
}
|
|
266
|
+
if (suffix === "ment" || suffix === "ments") {
|
|
267
|
+
if (suffixInRegion(word, suffix, rv)) {
|
|
268
|
+
const stemmed = removeSuffix(word, suffix);
|
|
269
|
+
if (stemmed.length > 0 && isVowel(stemmed[stemmed.length - 1])) {
|
|
270
|
+
return { word: stemmed, changed: true };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return { word, changed: false };
|
|
274
|
+
}
|
|
275
|
+
if (suffix === "eux") {
|
|
276
|
+
if (suffixInRegion(word, suffix, r2)) {
|
|
277
|
+
return { word: removeSuffix(word, suffix), changed: true };
|
|
278
|
+
}
|
|
279
|
+
return { word, changed: false };
|
|
280
|
+
}
|
|
281
|
+
return { word, changed: false };
|
|
282
|
+
}
|
|
283
|
+
function step2aIVerbSuffix(word, rv) {
|
|
284
|
+
const suffixes = [
|
|
285
|
+
"issantes",
|
|
286
|
+
"issante",
|
|
287
|
+
"issants",
|
|
288
|
+
"issant",
|
|
289
|
+
"issions",
|
|
290
|
+
"issons",
|
|
291
|
+
"issais",
|
|
292
|
+
"issait",
|
|
293
|
+
"issiez",
|
|
294
|
+
"issez",
|
|
295
|
+
"isses",
|
|
296
|
+
"isse",
|
|
297
|
+
"iraIent",
|
|
298
|
+
"issaIent",
|
|
299
|
+
"irions",
|
|
300
|
+
"iront",
|
|
301
|
+
"irais",
|
|
302
|
+
"irait",
|
|
303
|
+
"iriez",
|
|
304
|
+
"irons",
|
|
305
|
+
"irent",
|
|
306
|
+
"irez",
|
|
307
|
+
"irai",
|
|
308
|
+
"iras",
|
|
309
|
+
"\xEEmes",
|
|
310
|
+
"\xEEtes",
|
|
311
|
+
"ies",
|
|
312
|
+
"ira",
|
|
313
|
+
"ir",
|
|
314
|
+
"is",
|
|
315
|
+
"it",
|
|
316
|
+
"ie",
|
|
317
|
+
"i",
|
|
318
|
+
"\xEEt"
|
|
319
|
+
];
|
|
320
|
+
const suffix = findLongestAmong(word, suffixes, rv);
|
|
321
|
+
if (!suffix) return { word, changed: false };
|
|
322
|
+
const stemmed = removeSuffix(word, suffix);
|
|
323
|
+
if (stemmed.length > 0 && !isVowel(stemmed[stemmed.length - 1]) && stemmed[stemmed.length - 1] !== "H") {
|
|
324
|
+
return { word: stemmed, changed: true };
|
|
325
|
+
}
|
|
326
|
+
return { word, changed: false };
|
|
327
|
+
}
|
|
328
|
+
function step2bOtherVerbSuffix(word, rv, r2) {
|
|
329
|
+
const group1Suffixes = [
|
|
330
|
+
"eraIent",
|
|
331
|
+
"erions",
|
|
332
|
+
"assions",
|
|
333
|
+
"assent",
|
|
334
|
+
"assiez",
|
|
335
|
+
"erais",
|
|
336
|
+
"erait",
|
|
337
|
+
"eriez",
|
|
338
|
+
"erons",
|
|
339
|
+
"eront",
|
|
340
|
+
"erez",
|
|
341
|
+
"antes",
|
|
342
|
+
"asses",
|
|
343
|
+
"eras",
|
|
344
|
+
"ante",
|
|
345
|
+
"asse",
|
|
346
|
+
"\xE2mes",
|
|
347
|
+
"\xE2tes",
|
|
348
|
+
"\xE9es",
|
|
349
|
+
"era",
|
|
350
|
+
"erai",
|
|
351
|
+
"ais",
|
|
352
|
+
"ait",
|
|
353
|
+
"ant",
|
|
354
|
+
"\xE9e",
|
|
355
|
+
"\xE9s",
|
|
356
|
+
"er",
|
|
357
|
+
"ez",
|
|
358
|
+
"ai",
|
|
359
|
+
"as",
|
|
360
|
+
"a",
|
|
361
|
+
"\xE9",
|
|
362
|
+
"\xE2t",
|
|
363
|
+
"\xE8rent"
|
|
364
|
+
];
|
|
365
|
+
const ionsSuffix = "ions";
|
|
366
|
+
if (endsWith(word, ionsSuffix) && suffixInRegion(word, ionsSuffix, r2)) {
|
|
367
|
+
return { word: removeSuffix(word, ionsSuffix), changed: true };
|
|
368
|
+
}
|
|
369
|
+
const suffix = findLongestAmong(word, group1Suffixes, rv);
|
|
370
|
+
if (suffix) {
|
|
371
|
+
return { word: removeSuffix(word, suffix), changed: true };
|
|
372
|
+
}
|
|
373
|
+
return { word, changed: false };
|
|
374
|
+
}
|
|
375
|
+
function step3ResidualSuffix(word, rv, r2) {
|
|
376
|
+
if (endsWith(word, "s")) {
|
|
377
|
+
const beforeS = word.slice(0, -1);
|
|
378
|
+
if (beforeS.length > 0) {
|
|
379
|
+
const lastChar = beforeS[beforeS.length - 1];
|
|
380
|
+
if (lastChar !== "a" && lastChar !== "i" && lastChar !== "o" && lastChar !== "u" && lastChar !== "\xE8" && lastChar !== "s") {
|
|
381
|
+
word = beforeS;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
const ionSuffix = "ion";
|
|
386
|
+
if (endsWith(word, ionSuffix) && suffixInRegion(word, ionSuffix, r2)) {
|
|
387
|
+
const stemmed = removeSuffix(word, ionSuffix);
|
|
388
|
+
if (stemmed.length > 0 && (stemmed[stemmed.length - 1] === "s" || stemmed[stemmed.length - 1] === "t") && suffixInRegion(word, ionSuffix, rv)) {
|
|
389
|
+
return stemmed;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const residualSuffixes = ["I\xE8re", "i\xE8re", "Ier", "ier"];
|
|
393
|
+
for (const suffix of residualSuffixes) {
|
|
394
|
+
if (endsWith(word, suffix) && suffixInRegion(word, suffix, rv)) {
|
|
395
|
+
return `${removeSuffix(word, suffix)}i`;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (endsWith(word, "e") && suffixInRegion(word, "e", rv)) {
|
|
399
|
+
return removeSuffix(word, "e");
|
|
400
|
+
}
|
|
401
|
+
return word;
|
|
402
|
+
}
|
|
403
|
+
function step4Undouble(word) {
|
|
404
|
+
const doublePatterns = ["enn", "onn", "ett", "ell", "eill"];
|
|
405
|
+
for (const pattern of doublePatterns) {
|
|
406
|
+
if (endsWith(word, pattern)) {
|
|
407
|
+
return word.slice(0, -1);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return word;
|
|
411
|
+
}
|
|
412
|
+
function step5UnAccent(word) {
|
|
413
|
+
if (word.length < 2) return word;
|
|
414
|
+
const lastChar = word[word.length - 1];
|
|
415
|
+
const secondLastChar = word[word.length - 2];
|
|
416
|
+
if ((lastChar === "\xE9" || lastChar === "\xE8") && !isVowel(secondLastChar)) {
|
|
417
|
+
return `${word.slice(0, -1)}e`;
|
|
418
|
+
}
|
|
419
|
+
if (!isVowel(lastChar) && (secondLastChar === "\xE9" || secondLastChar === "\xE8")) {
|
|
420
|
+
return `${word.slice(0, -2)}e${lastChar}`;
|
|
421
|
+
}
|
|
422
|
+
return word;
|
|
423
|
+
}
|
|
424
|
+
function stem(word) {
|
|
425
|
+
if (word.length < 3) return word;
|
|
426
|
+
if (word[0] === "y") {
|
|
427
|
+
word = `Y${word.slice(1)}`;
|
|
428
|
+
}
|
|
429
|
+
word = markVowelConsonantForms(word);
|
|
430
|
+
const { rv, r1, r2 } = findRegions(word);
|
|
431
|
+
const step1Result = step1StandardSuffix(word, rv, r1, r2);
|
|
432
|
+
let stemChanged = step1Result.changed;
|
|
433
|
+
word = step1Result.word;
|
|
434
|
+
if (!stemChanged) {
|
|
435
|
+
const step2aResult = step2aIVerbSuffix(word, rv);
|
|
436
|
+
if (step2aResult.changed) {
|
|
437
|
+
word = step2aResult.word;
|
|
438
|
+
stemChanged = true;
|
|
439
|
+
} else {
|
|
440
|
+
const step2bResult = step2bOtherVerbSuffix(word, rv, r2);
|
|
441
|
+
word = step2bResult.word;
|
|
442
|
+
stemChanged = step2bResult.changed;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (stemChanged) {
|
|
446
|
+
if (endsWith(word, "Y")) {
|
|
447
|
+
word = `${word.slice(0, -1)}i`;
|
|
448
|
+
}
|
|
449
|
+
if (endsWith(word, "\xE7")) {
|
|
450
|
+
word = `${word.slice(0, -1)}c`;
|
|
451
|
+
}
|
|
452
|
+
} else {
|
|
453
|
+
word = step3ResidualSuffix(word, rv, r2);
|
|
454
|
+
}
|
|
455
|
+
word = step4Undouble(word);
|
|
456
|
+
word = step5UnAccent(word);
|
|
457
|
+
word = restoreMarkedLetters(word);
|
|
458
|
+
return word.toLowerCase();
|
|
459
|
+
}
|
|
460
|
+
var stopWords = /* @__PURE__ */ new Set([
|
|
461
|
+
"au",
|
|
462
|
+
"aux",
|
|
463
|
+
"avec",
|
|
464
|
+
"ce",
|
|
465
|
+
"ces",
|
|
466
|
+
"dans",
|
|
467
|
+
"de",
|
|
468
|
+
"des",
|
|
469
|
+
"du",
|
|
470
|
+
"elle",
|
|
471
|
+
"en",
|
|
472
|
+
"et",
|
|
473
|
+
"eux",
|
|
474
|
+
"il",
|
|
475
|
+
"je",
|
|
476
|
+
"la",
|
|
477
|
+
"le",
|
|
478
|
+
"leur",
|
|
479
|
+
"lui",
|
|
480
|
+
"ma",
|
|
481
|
+
"mais",
|
|
482
|
+
"me",
|
|
483
|
+
"m\xEAme",
|
|
484
|
+
"mes",
|
|
485
|
+
"moi",
|
|
486
|
+
"mon",
|
|
487
|
+
"ne",
|
|
488
|
+
"nos",
|
|
489
|
+
"notre",
|
|
490
|
+
"nous",
|
|
491
|
+
"on",
|
|
492
|
+
"ou",
|
|
493
|
+
"par",
|
|
494
|
+
"pas",
|
|
495
|
+
"pour",
|
|
496
|
+
"qu",
|
|
497
|
+
"que",
|
|
498
|
+
"qui",
|
|
499
|
+
"sa",
|
|
500
|
+
"se",
|
|
501
|
+
"ses",
|
|
502
|
+
"son",
|
|
503
|
+
"sur",
|
|
504
|
+
"ta",
|
|
505
|
+
"te",
|
|
506
|
+
"tes",
|
|
507
|
+
"toi",
|
|
508
|
+
"ton",
|
|
509
|
+
"tu",
|
|
510
|
+
"un",
|
|
511
|
+
"une",
|
|
512
|
+
"vos",
|
|
513
|
+
"votre",
|
|
514
|
+
"vous",
|
|
515
|
+
"c",
|
|
516
|
+
"d",
|
|
517
|
+
"j",
|
|
518
|
+
"l",
|
|
519
|
+
"\xE0",
|
|
520
|
+
"m",
|
|
521
|
+
"n",
|
|
522
|
+
"s",
|
|
523
|
+
"t",
|
|
524
|
+
"y",
|
|
525
|
+
"\xE9t\xE9",
|
|
526
|
+
"\xE9t\xE9e",
|
|
527
|
+
"\xE9t\xE9es",
|
|
528
|
+
"\xE9t\xE9s",
|
|
529
|
+
"\xE9tant",
|
|
530
|
+
"suis",
|
|
531
|
+
"es",
|
|
532
|
+
"est",
|
|
533
|
+
"sommes",
|
|
534
|
+
"\xEAtes",
|
|
535
|
+
"sont",
|
|
536
|
+
"serai",
|
|
537
|
+
"seras",
|
|
538
|
+
"sera",
|
|
539
|
+
"serons",
|
|
540
|
+
"serez",
|
|
541
|
+
"seront",
|
|
542
|
+
"serais",
|
|
543
|
+
"serait",
|
|
544
|
+
"serions",
|
|
545
|
+
"seriez",
|
|
546
|
+
"seraient",
|
|
547
|
+
"\xE9tais",
|
|
548
|
+
"\xE9tait",
|
|
549
|
+
"\xE9tions",
|
|
550
|
+
"\xE9tiez",
|
|
551
|
+
"\xE9taient",
|
|
552
|
+
"fus",
|
|
553
|
+
"fut",
|
|
554
|
+
"f\xFBmes",
|
|
555
|
+
"f\xFBtes",
|
|
556
|
+
"furent",
|
|
557
|
+
"sois",
|
|
558
|
+
"soit",
|
|
559
|
+
"soyons",
|
|
560
|
+
"soyez",
|
|
561
|
+
"soient",
|
|
562
|
+
"fusse",
|
|
563
|
+
"fusses",
|
|
564
|
+
"f\xFBt",
|
|
565
|
+
"fussions",
|
|
566
|
+
"fussiez",
|
|
567
|
+
"fussent",
|
|
568
|
+
"ayant",
|
|
569
|
+
"eu",
|
|
570
|
+
"eue",
|
|
571
|
+
"eues",
|
|
572
|
+
"eus",
|
|
573
|
+
"ai",
|
|
574
|
+
"as",
|
|
575
|
+
"avons",
|
|
576
|
+
"avez",
|
|
577
|
+
"ont",
|
|
578
|
+
"aurai",
|
|
579
|
+
"auras",
|
|
580
|
+
"aura",
|
|
581
|
+
"aurons",
|
|
582
|
+
"aurez",
|
|
583
|
+
"auront",
|
|
584
|
+
"aurais",
|
|
585
|
+
"aurait",
|
|
586
|
+
"aurions",
|
|
587
|
+
"auriez",
|
|
588
|
+
"auraient",
|
|
589
|
+
"avais",
|
|
590
|
+
"avait",
|
|
591
|
+
"avions",
|
|
592
|
+
"aviez",
|
|
593
|
+
"avaient",
|
|
594
|
+
"eut",
|
|
595
|
+
"e\xFBmes",
|
|
596
|
+
"e\xFBtes",
|
|
597
|
+
"eurent",
|
|
598
|
+
"aie",
|
|
599
|
+
"aies",
|
|
600
|
+
"ait",
|
|
601
|
+
"ayons",
|
|
602
|
+
"ayez",
|
|
603
|
+
"aient",
|
|
604
|
+
"eusse",
|
|
605
|
+
"eusses",
|
|
606
|
+
"e\xFBt",
|
|
607
|
+
"eussions",
|
|
608
|
+
"eussiez",
|
|
609
|
+
"eussent",
|
|
610
|
+
"ceci",
|
|
611
|
+
"cela",
|
|
612
|
+
"cel\xE0",
|
|
613
|
+
"cet",
|
|
614
|
+
"cette",
|
|
615
|
+
"ici",
|
|
616
|
+
"ils",
|
|
617
|
+
"les",
|
|
618
|
+
"leurs",
|
|
619
|
+
"quel",
|
|
620
|
+
"quels",
|
|
621
|
+
"quelle",
|
|
622
|
+
"quelles",
|
|
623
|
+
"sans",
|
|
624
|
+
"soi"
|
|
625
|
+
]);
|
|
626
|
+
var french = {
|
|
627
|
+
name: "french",
|
|
628
|
+
stemmer: stem,
|
|
629
|
+
stopWords,
|
|
630
|
+
tokenizer: {
|
|
631
|
+
splitPattern: /[^a-z0-9äâàéèëêïîöôùüûœç-]+/gi
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
export { french };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/languages/ga.ts
|
|
2
|
+
var stopWords = /* @__PURE__ */ new Set([
|
|
3
|
+
"mi",
|
|
4
|
+
"bo",
|
|
5
|
+
"e",
|
|
6
|
+
"w\u0254",
|
|
7
|
+
"ni",
|
|
8
|
+
"am\u025B",
|
|
9
|
+
"l\u025B",
|
|
10
|
+
"m\u0254",
|
|
11
|
+
"n\u0254",
|
|
12
|
+
"he",
|
|
13
|
+
"le",
|
|
14
|
+
"k\u025B",
|
|
15
|
+
"shi",
|
|
16
|
+
"ba",
|
|
17
|
+
"y\u025B",
|
|
18
|
+
"ko",
|
|
19
|
+
"tso",
|
|
20
|
+
"ts\u0254",
|
|
21
|
+
"naa",
|
|
22
|
+
"n\u025B\u025B",
|
|
23
|
+
"fee",
|
|
24
|
+
"kane",
|
|
25
|
+
"shishi",
|
|
26
|
+
"moko",
|
|
27
|
+
"lo",
|
|
28
|
+
"la",
|
|
29
|
+
"mo",
|
|
30
|
+
"ji",
|
|
31
|
+
"ana",
|
|
32
|
+
"mli",
|
|
33
|
+
"nii",
|
|
34
|
+
"noko",
|
|
35
|
+
"ahi",
|
|
36
|
+
"kome",
|
|
37
|
+
"eno",
|
|
38
|
+
"eni",
|
|
39
|
+
"bee",
|
|
40
|
+
"tee",
|
|
41
|
+
"laa",
|
|
42
|
+
"nee",
|
|
43
|
+
"no",
|
|
44
|
+
"nu",
|
|
45
|
+
"ne",
|
|
46
|
+
"na",
|
|
47
|
+
"ta",
|
|
48
|
+
"fo",
|
|
49
|
+
"esa",
|
|
50
|
+
"bii",
|
|
51
|
+
"saa",
|
|
52
|
+
"f\u025B\u025B",
|
|
53
|
+
"ak\u025B",
|
|
54
|
+
"yaan\u0254",
|
|
55
|
+
"eee",
|
|
56
|
+
"ekome"
|
|
57
|
+
]);
|
|
58
|
+
var ga = {
|
|
59
|
+
name: "ga",
|
|
60
|
+
stemmer: null,
|
|
61
|
+
stopWords,
|
|
62
|
+
tokenizer: {
|
|
63
|
+
splitPattern: /[^a-zA-ZɛɔƐƆŋŊ0-9\p{M}]+/giu,
|
|
64
|
+
normalizeDiacritics: false,
|
|
65
|
+
minTokenLength: 1
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { ga };
|