@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,606 @@
|
|
|
1
|
+
// src/languages/spanish.ts
|
|
2
|
+
var VOWELS = "aeiou\xE1\xE9\xED\xF3\xFA\xFC";
|
|
3
|
+
var ACCENT_A = /á/g;
|
|
4
|
+
var ACCENT_E = /é/g;
|
|
5
|
+
var ACCENT_I = /í/g;
|
|
6
|
+
var ACCENT_O = /ó/g;
|
|
7
|
+
var ACCENT_U = /ú/g;
|
|
8
|
+
var STEP1_GROUP1_SUFFIXES = [
|
|
9
|
+
"amientos",
|
|
10
|
+
"imientos",
|
|
11
|
+
"amiento",
|
|
12
|
+
"imiento",
|
|
13
|
+
"aciones",
|
|
14
|
+
"uciones",
|
|
15
|
+
"adoras",
|
|
16
|
+
"adores",
|
|
17
|
+
"ancias",
|
|
18
|
+
"encias",
|
|
19
|
+
"adora",
|
|
20
|
+
"antes",
|
|
21
|
+
"anzas",
|
|
22
|
+
"ismos",
|
|
23
|
+
"istas",
|
|
24
|
+
"ables",
|
|
25
|
+
"ibles",
|
|
26
|
+
"aci\xF3n",
|
|
27
|
+
"uci\xF3n",
|
|
28
|
+
"icas",
|
|
29
|
+
"ador",
|
|
30
|
+
"ante",
|
|
31
|
+
"anza",
|
|
32
|
+
"icos",
|
|
33
|
+
"ismo",
|
|
34
|
+
"ista",
|
|
35
|
+
"osas",
|
|
36
|
+
"osos",
|
|
37
|
+
"iva",
|
|
38
|
+
"ivo",
|
|
39
|
+
"ivas",
|
|
40
|
+
"ivos",
|
|
41
|
+
"ica",
|
|
42
|
+
"ico",
|
|
43
|
+
"osa",
|
|
44
|
+
"oso",
|
|
45
|
+
"able",
|
|
46
|
+
"ible"
|
|
47
|
+
];
|
|
48
|
+
var STEP1_GROUP2_SUFFIXES = ["log\xEDas", "log\xEDa"];
|
|
49
|
+
var STEP1_GROUP3_SUFFIXES = ["uci\xF3n", "uciones"];
|
|
50
|
+
var STEP1_GROUP4_SUFFIXES = ["encia", "encias"];
|
|
51
|
+
var STEP1_GROUP5_SUFFIXES = ["amente"];
|
|
52
|
+
var STEP1_GROUP6_SUFFIXES = ["mente"];
|
|
53
|
+
var STEP1_GROUP7_SUFFIXES = ["idades", "idad"];
|
|
54
|
+
var STEP1_ALL_SUFFIXES = [
|
|
55
|
+
...STEP1_GROUP1_SUFFIXES,
|
|
56
|
+
...STEP1_GROUP2_SUFFIXES,
|
|
57
|
+
...STEP1_GROUP3_SUFFIXES,
|
|
58
|
+
...STEP1_GROUP4_SUFFIXES,
|
|
59
|
+
...STEP1_GROUP5_SUFFIXES,
|
|
60
|
+
...STEP1_GROUP6_SUFFIXES,
|
|
61
|
+
...STEP1_GROUP7_SUFFIXES
|
|
62
|
+
];
|
|
63
|
+
var Y_VERB_SUFFIXES = ["yeron", "yendo", "yamos", "yais", "yan", "yen", "yas", "yes", "ya", "ye", "yo", "y\xF3"];
|
|
64
|
+
var STEP2B_VERB_SUFFIXES = [
|
|
65
|
+
"i\xE9ramos",
|
|
66
|
+
"i\xE9semos",
|
|
67
|
+
"er\xEDamos",
|
|
68
|
+
"ar\xEDamos",
|
|
69
|
+
"ir\xEDamos",
|
|
70
|
+
"\xE1ramos",
|
|
71
|
+
"\xE1bamos",
|
|
72
|
+
"\xE1semos",
|
|
73
|
+
"\xEDamos",
|
|
74
|
+
"ar\xEDais",
|
|
75
|
+
"er\xEDais",
|
|
76
|
+
"ir\xEDais",
|
|
77
|
+
"ieran",
|
|
78
|
+
"iesen",
|
|
79
|
+
"ieron",
|
|
80
|
+
"ir\xEDan",
|
|
81
|
+
"er\xEDan",
|
|
82
|
+
"ar\xEDan",
|
|
83
|
+
"arais",
|
|
84
|
+
"aseis",
|
|
85
|
+
"er\xE9is",
|
|
86
|
+
"ar\xE9is",
|
|
87
|
+
"ir\xE9is",
|
|
88
|
+
"ir\xEDas",
|
|
89
|
+
"er\xEDas",
|
|
90
|
+
"ar\xEDas",
|
|
91
|
+
"ieras",
|
|
92
|
+
"ieses",
|
|
93
|
+
"abais",
|
|
94
|
+
"aremos",
|
|
95
|
+
"eremos",
|
|
96
|
+
"iremos",
|
|
97
|
+
"isteis",
|
|
98
|
+
"asteis",
|
|
99
|
+
"ierais",
|
|
100
|
+
"ieseis",
|
|
101
|
+
"iendo",
|
|
102
|
+
"ando",
|
|
103
|
+
"ar\xE1n",
|
|
104
|
+
"er\xE1n",
|
|
105
|
+
"ir\xE1n",
|
|
106
|
+
"aron",
|
|
107
|
+
"aban",
|
|
108
|
+
"aran",
|
|
109
|
+
"adas",
|
|
110
|
+
"idas",
|
|
111
|
+
"abas",
|
|
112
|
+
"aras",
|
|
113
|
+
"ases",
|
|
114
|
+
"ir\xEDa",
|
|
115
|
+
"er\xEDa",
|
|
116
|
+
"ar\xEDa",
|
|
117
|
+
"iera",
|
|
118
|
+
"iese",
|
|
119
|
+
"aste",
|
|
120
|
+
"iste",
|
|
121
|
+
"ados",
|
|
122
|
+
"idos",
|
|
123
|
+
"amos",
|
|
124
|
+
"imos",
|
|
125
|
+
"\xEDan",
|
|
126
|
+
"\xE1is",
|
|
127
|
+
"aba",
|
|
128
|
+
"ada",
|
|
129
|
+
"ida",
|
|
130
|
+
"ara",
|
|
131
|
+
"ase",
|
|
132
|
+
"ado",
|
|
133
|
+
"ido",
|
|
134
|
+
"\xEDas",
|
|
135
|
+
"\xE9is",
|
|
136
|
+
"\xEDa",
|
|
137
|
+
"ad",
|
|
138
|
+
"ed",
|
|
139
|
+
"id",
|
|
140
|
+
"an",
|
|
141
|
+
"i\xF3",
|
|
142
|
+
"ar",
|
|
143
|
+
"er",
|
|
144
|
+
"ir",
|
|
145
|
+
"as",
|
|
146
|
+
"es",
|
|
147
|
+
"\xEDs",
|
|
148
|
+
"en",
|
|
149
|
+
"ar\xE1",
|
|
150
|
+
"er\xE1",
|
|
151
|
+
"ir\xE1",
|
|
152
|
+
"ar\xE9",
|
|
153
|
+
"er\xE9",
|
|
154
|
+
"ir\xE9",
|
|
155
|
+
"\xE1t"
|
|
156
|
+
];
|
|
157
|
+
var RESIDUAL_SUFFIXES = ["os", "a", "o", "\xE1", "\xED", "\xF3"];
|
|
158
|
+
function isVowel(ch) {
|
|
159
|
+
return VOWELS.includes(ch);
|
|
160
|
+
}
|
|
161
|
+
function findRegions(word) {
|
|
162
|
+
let rv = word.length;
|
|
163
|
+
let r1 = word.length;
|
|
164
|
+
let r2 = word.length;
|
|
165
|
+
if (word.length >= 2) {
|
|
166
|
+
if (!isVowel(word[1])) {
|
|
167
|
+
for (let i = 2; i < word.length; i++) {
|
|
168
|
+
if (isVowel(word[i])) {
|
|
169
|
+
rv = i + 1;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
} else if (isVowel(word[0])) {
|
|
174
|
+
for (let i = 2; i < word.length; i++) {
|
|
175
|
+
if (!isVowel(word[i])) {
|
|
176
|
+
rv = i + 1;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
rv = 3;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
for (let i = 0; i < word.length - 1; i++) {
|
|
185
|
+
if (isVowel(word[i]) && !isVowel(word[i + 1])) {
|
|
186
|
+
r1 = i + 2;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
for (let i = r1; i < word.length - 1; i++) {
|
|
191
|
+
if (isVowel(word[i]) && !isVowel(word[i + 1])) {
|
|
192
|
+
r2 = i + 2;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return { rv, r1, r2 };
|
|
197
|
+
}
|
|
198
|
+
function endsWith(word, suffix) {
|
|
199
|
+
return word.endsWith(suffix);
|
|
200
|
+
}
|
|
201
|
+
function removeSuffix(word, suffix) {
|
|
202
|
+
return word.slice(0, word.length - suffix.length);
|
|
203
|
+
}
|
|
204
|
+
function suffixInRegion(word, suffix, regionStart) {
|
|
205
|
+
return word.length - suffix.length >= regionStart;
|
|
206
|
+
}
|
|
207
|
+
function findLongestAmong(word, suffixes, regionStart) {
|
|
208
|
+
let longestMatch = null;
|
|
209
|
+
for (const suffix of suffixes) {
|
|
210
|
+
if (endsWith(word, suffix) && suffixInRegion(word, suffix, regionStart)) {
|
|
211
|
+
if (longestMatch === null || suffix.length > longestMatch.length) {
|
|
212
|
+
longestMatch = suffix;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return longestMatch;
|
|
217
|
+
}
|
|
218
|
+
function removeAccents(word) {
|
|
219
|
+
return word.replace(ACCENT_A, "a").replace(ACCENT_E, "e").replace(ACCENT_I, "i").replace(ACCENT_O, "o").replace(ACCENT_U, "u");
|
|
220
|
+
}
|
|
221
|
+
var ATTACHED_PRONOUNS = ["selas", "selos", "sela", "selo", "las", "les", "los", "nos", "la", "le", "lo", "me", "se"];
|
|
222
|
+
var PRONOUN_VERB_SUFFIXES = ["i\xE9ndo", "\xE1ndo", "\xE1r", "\xE9r", "\xEDr", "iendo", "ando", "yendo", "ar", "er", "ir"];
|
|
223
|
+
function step0AttachedPronoun(word, rv) {
|
|
224
|
+
for (const pronoun of ATTACHED_PRONOUNS) {
|
|
225
|
+
if (!endsWith(word, pronoun)) continue;
|
|
226
|
+
if (!suffixInRegion(word, pronoun, rv)) continue;
|
|
227
|
+
const beforePronoun = removeSuffix(word, pronoun);
|
|
228
|
+
for (const verbSuffix of PRONOUN_VERB_SUFFIXES) {
|
|
229
|
+
if (!endsWith(beforePronoun, verbSuffix)) continue;
|
|
230
|
+
if (verbSuffix === "yendo" && endsWith(removeSuffix(beforePronoun, "yendo"), "u")) {
|
|
231
|
+
return removeSuffix(word, pronoun);
|
|
232
|
+
}
|
|
233
|
+
if (verbSuffix === "i\xE9ndo") {
|
|
234
|
+
return `${removeSuffix(word, pronoun).slice(0, -5)}iendo`;
|
|
235
|
+
}
|
|
236
|
+
if (verbSuffix === "\xE1ndo") {
|
|
237
|
+
return `${removeSuffix(word, pronoun).slice(0, -4)}ando`;
|
|
238
|
+
}
|
|
239
|
+
if (verbSuffix === "\xE1r") {
|
|
240
|
+
return `${removeSuffix(word, pronoun).slice(0, -2)}ar`;
|
|
241
|
+
}
|
|
242
|
+
if (verbSuffix === "\xE9r") {
|
|
243
|
+
return `${removeSuffix(word, pronoun).slice(0, -2)}er`;
|
|
244
|
+
}
|
|
245
|
+
if (verbSuffix === "\xEDr") {
|
|
246
|
+
return `${removeSuffix(word, pronoun).slice(0, -2)}ir`;
|
|
247
|
+
}
|
|
248
|
+
return removeSuffix(word, pronoun);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return word;
|
|
252
|
+
}
|
|
253
|
+
function step1StandardSuffix(word, r1, r2) {
|
|
254
|
+
let longestSuffix = null;
|
|
255
|
+
for (const s of STEP1_ALL_SUFFIXES) {
|
|
256
|
+
if (endsWith(word, s)) {
|
|
257
|
+
if (longestSuffix === null || s.length > longestSuffix.length) {
|
|
258
|
+
longestSuffix = s;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (!longestSuffix) return { word, changed: false };
|
|
263
|
+
if (STEP1_GROUP1_SUFFIXES.includes(longestSuffix)) {
|
|
264
|
+
if (longestSuffix === "iva" || longestSuffix === "ivo" || longestSuffix === "ivas" || longestSuffix === "ivos") {
|
|
265
|
+
if (!suffixInRegion(word, longestSuffix, r2)) return { word, changed: false };
|
|
266
|
+
word = removeSuffix(word, longestSuffix);
|
|
267
|
+
if (endsWith(word, "at") && suffixInRegion(word, "at", r2)) {
|
|
268
|
+
word = removeSuffix(word, "at");
|
|
269
|
+
}
|
|
270
|
+
return { word, changed: true };
|
|
271
|
+
}
|
|
272
|
+
if (!suffixInRegion(word, longestSuffix, r2)) return { word, changed: false };
|
|
273
|
+
return { word: removeSuffix(word, longestSuffix), changed: true };
|
|
274
|
+
}
|
|
275
|
+
if (STEP1_GROUP2_SUFFIXES.includes(longestSuffix)) {
|
|
276
|
+
if (!suffixInRegion(word, longestSuffix, r2)) return { word, changed: false };
|
|
277
|
+
return { word: `${removeSuffix(word, longestSuffix)}log`, changed: true };
|
|
278
|
+
}
|
|
279
|
+
if (STEP1_GROUP3_SUFFIXES.includes(longestSuffix)) {
|
|
280
|
+
if (!suffixInRegion(word, longestSuffix, r2)) return { word, changed: false };
|
|
281
|
+
return { word: `${removeSuffix(word, longestSuffix)}u`, changed: true };
|
|
282
|
+
}
|
|
283
|
+
if (STEP1_GROUP4_SUFFIXES.includes(longestSuffix)) {
|
|
284
|
+
if (!suffixInRegion(word, longestSuffix, r2)) return { word, changed: false };
|
|
285
|
+
return { word: `${removeSuffix(word, longestSuffix)}ente`, changed: true };
|
|
286
|
+
}
|
|
287
|
+
if (STEP1_GROUP5_SUFFIXES.includes(longestSuffix)) {
|
|
288
|
+
if (!suffixInRegion(word, longestSuffix, r1)) return { word, changed: false };
|
|
289
|
+
word = removeSuffix(word, longestSuffix);
|
|
290
|
+
if (endsWith(word, "iv") && suffixInRegion(word, "iv", r2)) {
|
|
291
|
+
word = removeSuffix(word, "iv");
|
|
292
|
+
if (endsWith(word, "at") && suffixInRegion(word, "at", r2)) {
|
|
293
|
+
word = removeSuffix(word, "at");
|
|
294
|
+
}
|
|
295
|
+
} else if (endsWith(word, "os") && suffixInRegion(word, "os", r2)) {
|
|
296
|
+
word = removeSuffix(word, "os");
|
|
297
|
+
} else if (endsWith(word, "ic") && suffixInRegion(word, "ic", r2)) {
|
|
298
|
+
word = removeSuffix(word, "ic");
|
|
299
|
+
} else if (endsWith(word, "ad") && suffixInRegion(word, "ad", r2)) {
|
|
300
|
+
word = removeSuffix(word, "ad");
|
|
301
|
+
}
|
|
302
|
+
return { word, changed: true };
|
|
303
|
+
}
|
|
304
|
+
if (STEP1_GROUP6_SUFFIXES.includes(longestSuffix)) {
|
|
305
|
+
if (!suffixInRegion(word, longestSuffix, r2)) return { word, changed: false };
|
|
306
|
+
word = removeSuffix(word, longestSuffix);
|
|
307
|
+
if (endsWith(word, "ante") && suffixInRegion(word, "ante", r2)) {
|
|
308
|
+
word = removeSuffix(word, "ante");
|
|
309
|
+
} else if (endsWith(word, "able") && suffixInRegion(word, "able", r2)) {
|
|
310
|
+
word = removeSuffix(word, "able");
|
|
311
|
+
} else if (endsWith(word, "ible") && suffixInRegion(word, "ible", r2)) {
|
|
312
|
+
word = removeSuffix(word, "ible");
|
|
313
|
+
}
|
|
314
|
+
return { word, changed: true };
|
|
315
|
+
}
|
|
316
|
+
if (STEP1_GROUP7_SUFFIXES.includes(longestSuffix)) {
|
|
317
|
+
if (!suffixInRegion(word, longestSuffix, r2)) return { word, changed: false };
|
|
318
|
+
word = removeSuffix(word, longestSuffix);
|
|
319
|
+
if (endsWith(word, "abil") && suffixInRegion(word, "abil", r2)) {
|
|
320
|
+
word = removeSuffix(word, "abil");
|
|
321
|
+
} else if (endsWith(word, "ic") && suffixInRegion(word, "ic", r2)) {
|
|
322
|
+
word = removeSuffix(word, "ic");
|
|
323
|
+
} else if (endsWith(word, "iv") && suffixInRegion(word, "iv", r2)) {
|
|
324
|
+
word = removeSuffix(word, "iv");
|
|
325
|
+
}
|
|
326
|
+
return { word, changed: true };
|
|
327
|
+
}
|
|
328
|
+
return { word, changed: false };
|
|
329
|
+
}
|
|
330
|
+
function step2aYVerbSuffix(word, rv) {
|
|
331
|
+
const suffix = findLongestAmong(word, Y_VERB_SUFFIXES, rv);
|
|
332
|
+
if (suffix) {
|
|
333
|
+
const stemmed = removeSuffix(word, suffix);
|
|
334
|
+
if (stemmed.length > 0 && stemmed[stemmed.length - 1] === "u") {
|
|
335
|
+
return { word: stemmed, changed: true };
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return { word, changed: false };
|
|
339
|
+
}
|
|
340
|
+
function step2bVerbSuffix(word, rv) {
|
|
341
|
+
const suffix = findLongestAmong(word, STEP2B_VERB_SUFFIXES, rv);
|
|
342
|
+
if (!suffix) return { word, changed: false };
|
|
343
|
+
if (suffix === "en" || suffix === "es" || suffix === "\xE9is" || suffix === "emos") {
|
|
344
|
+
word = removeSuffix(word, suffix);
|
|
345
|
+
if (endsWith(word, "gu")) {
|
|
346
|
+
if (suffixInRegion(word, "u", rv)) {
|
|
347
|
+
word = removeSuffix(word, "u");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return { word, changed: true };
|
|
351
|
+
}
|
|
352
|
+
return { word: removeSuffix(word, suffix), changed: true };
|
|
353
|
+
}
|
|
354
|
+
function step3ResidualSuffix(word, rv) {
|
|
355
|
+
const suffix = findLongestAmong(word, RESIDUAL_SUFFIXES, rv);
|
|
356
|
+
if (suffix) {
|
|
357
|
+
return removeSuffix(word, suffix);
|
|
358
|
+
}
|
|
359
|
+
if (endsWith(word, "e") || endsWith(word, "\xE9")) {
|
|
360
|
+
const eSuffix = endsWith(word, "\xE9") ? "\xE9" : "e";
|
|
361
|
+
if (suffixInRegion(word, eSuffix, rv)) {
|
|
362
|
+
word = removeSuffix(word, eSuffix);
|
|
363
|
+
if (endsWith(word, "gu") && suffixInRegion(word, "u", rv)) {
|
|
364
|
+
word = removeSuffix(word, "u");
|
|
365
|
+
}
|
|
366
|
+
return word;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return word;
|
|
370
|
+
}
|
|
371
|
+
function stem(word) {
|
|
372
|
+
if (word.length < 3) return word;
|
|
373
|
+
const { rv, r1, r2 } = findRegions(word);
|
|
374
|
+
word = step0AttachedPronoun(word, rv);
|
|
375
|
+
const step1Result = step1StandardSuffix(word, r1, r2);
|
|
376
|
+
let stemChanged = step1Result.changed;
|
|
377
|
+
word = step1Result.word;
|
|
378
|
+
if (!stemChanged) {
|
|
379
|
+
const step2aResult = step2aYVerbSuffix(word, rv);
|
|
380
|
+
if (step2aResult.changed) {
|
|
381
|
+
word = step2aResult.word;
|
|
382
|
+
stemChanged = true;
|
|
383
|
+
} else {
|
|
384
|
+
const step2bResult = step2bVerbSuffix(word, rv);
|
|
385
|
+
word = step2bResult.word;
|
|
386
|
+
stemChanged = step2bResult.changed;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
word = step3ResidualSuffix(word, rv);
|
|
390
|
+
word = removeAccents(word);
|
|
391
|
+
return word;
|
|
392
|
+
}
|
|
393
|
+
var stopWords = /* @__PURE__ */ new Set([
|
|
394
|
+
"a",
|
|
395
|
+
"al",
|
|
396
|
+
"algo",
|
|
397
|
+
"alguna",
|
|
398
|
+
"algunas",
|
|
399
|
+
"alguno",
|
|
400
|
+
"algunos",
|
|
401
|
+
"alg\xFAn",
|
|
402
|
+
"ambos",
|
|
403
|
+
"ante",
|
|
404
|
+
"antes",
|
|
405
|
+
"aquel",
|
|
406
|
+
"aquella",
|
|
407
|
+
"aquellas",
|
|
408
|
+
"aquello",
|
|
409
|
+
"aquellos",
|
|
410
|
+
"aqu\xED",
|
|
411
|
+
"arriba",
|
|
412
|
+
"as\xED",
|
|
413
|
+
"aunque",
|
|
414
|
+
"a\xFAn",
|
|
415
|
+
"bajo",
|
|
416
|
+
"bastante",
|
|
417
|
+
"bien",
|
|
418
|
+
"cada",
|
|
419
|
+
"casi",
|
|
420
|
+
"como",
|
|
421
|
+
"con",
|
|
422
|
+
"contra",
|
|
423
|
+
"cual",
|
|
424
|
+
"cuales",
|
|
425
|
+
"cuando",
|
|
426
|
+
"cu\xE1ndo",
|
|
427
|
+
"cu\xE1nto",
|
|
428
|
+
"cu\xE1ntos",
|
|
429
|
+
"de",
|
|
430
|
+
"del",
|
|
431
|
+
"dem\xE1s",
|
|
432
|
+
"dentro",
|
|
433
|
+
"desde",
|
|
434
|
+
"donde",
|
|
435
|
+
"d\xF3nde",
|
|
436
|
+
"dos",
|
|
437
|
+
"durante",
|
|
438
|
+
"el",
|
|
439
|
+
"ella",
|
|
440
|
+
"ellas",
|
|
441
|
+
"ello",
|
|
442
|
+
"ellos",
|
|
443
|
+
"en",
|
|
444
|
+
"encima",
|
|
445
|
+
"entonces",
|
|
446
|
+
"entre",
|
|
447
|
+
"era",
|
|
448
|
+
"esa",
|
|
449
|
+
"esas",
|
|
450
|
+
"ese",
|
|
451
|
+
"eso",
|
|
452
|
+
"esos",
|
|
453
|
+
"esta",
|
|
454
|
+
"estaba",
|
|
455
|
+
"estado",
|
|
456
|
+
"estas",
|
|
457
|
+
"este",
|
|
458
|
+
"esto",
|
|
459
|
+
"estos",
|
|
460
|
+
"est\xE1",
|
|
461
|
+
"est\xE1n",
|
|
462
|
+
"fue",
|
|
463
|
+
"fuera",
|
|
464
|
+
"fueron",
|
|
465
|
+
"ha",
|
|
466
|
+
"hace",
|
|
467
|
+
"hacen",
|
|
468
|
+
"hacer",
|
|
469
|
+
"hacia",
|
|
470
|
+
"han",
|
|
471
|
+
"hasta",
|
|
472
|
+
"hay",
|
|
473
|
+
"la",
|
|
474
|
+
"las",
|
|
475
|
+
"le",
|
|
476
|
+
"les",
|
|
477
|
+
"lo",
|
|
478
|
+
"los",
|
|
479
|
+
"luego",
|
|
480
|
+
"mas",
|
|
481
|
+
"m\xE1s",
|
|
482
|
+
"me",
|
|
483
|
+
"mejor",
|
|
484
|
+
"menos",
|
|
485
|
+
"mi",
|
|
486
|
+
"mientras",
|
|
487
|
+
"mis",
|
|
488
|
+
"misma",
|
|
489
|
+
"mismo",
|
|
490
|
+
"mucha",
|
|
491
|
+
"muchas",
|
|
492
|
+
"mucho",
|
|
493
|
+
"muchos",
|
|
494
|
+
"muy",
|
|
495
|
+
"m\xED",
|
|
496
|
+
"m\xEDa",
|
|
497
|
+
"m\xEDo",
|
|
498
|
+
"nada",
|
|
499
|
+
"ni",
|
|
500
|
+
"ninguna",
|
|
501
|
+
"ninguno",
|
|
502
|
+
"ning\xFAn",
|
|
503
|
+
"no",
|
|
504
|
+
"nos",
|
|
505
|
+
"nosotras",
|
|
506
|
+
"nosotros",
|
|
507
|
+
"nuestra",
|
|
508
|
+
"nuestras",
|
|
509
|
+
"nuestro",
|
|
510
|
+
"nuestros",
|
|
511
|
+
"nunca",
|
|
512
|
+
"o",
|
|
513
|
+
"os",
|
|
514
|
+
"otra",
|
|
515
|
+
"otras",
|
|
516
|
+
"otro",
|
|
517
|
+
"otros",
|
|
518
|
+
"para",
|
|
519
|
+
"pero",
|
|
520
|
+
"poca",
|
|
521
|
+
"pocas",
|
|
522
|
+
"poco",
|
|
523
|
+
"pocos",
|
|
524
|
+
"por",
|
|
525
|
+
"porque",
|
|
526
|
+
"que",
|
|
527
|
+
"qu\xE9",
|
|
528
|
+
"quien",
|
|
529
|
+
"qui\xE9n",
|
|
530
|
+
"se",
|
|
531
|
+
"sea",
|
|
532
|
+
"seg\xFAn",
|
|
533
|
+
"ser",
|
|
534
|
+
"ser\xE1",
|
|
535
|
+
"si",
|
|
536
|
+
"sido",
|
|
537
|
+
"sin",
|
|
538
|
+
"sino",
|
|
539
|
+
"sobre",
|
|
540
|
+
"somos",
|
|
541
|
+
"son",
|
|
542
|
+
"soy",
|
|
543
|
+
"su",
|
|
544
|
+
"sus",
|
|
545
|
+
"suya",
|
|
546
|
+
"suyas",
|
|
547
|
+
"suyo",
|
|
548
|
+
"s\xED",
|
|
549
|
+
"tambi\xE9n",
|
|
550
|
+
"tan",
|
|
551
|
+
"tanto",
|
|
552
|
+
"te",
|
|
553
|
+
"tengo",
|
|
554
|
+
"ti",
|
|
555
|
+
"tiene",
|
|
556
|
+
"tienen",
|
|
557
|
+
"toda",
|
|
558
|
+
"todas",
|
|
559
|
+
"todav\xEDa",
|
|
560
|
+
"todo",
|
|
561
|
+
"todos",
|
|
562
|
+
"tu",
|
|
563
|
+
"tus",
|
|
564
|
+
"tuya",
|
|
565
|
+
"tuyo",
|
|
566
|
+
"t\xFA",
|
|
567
|
+
"un",
|
|
568
|
+
"una",
|
|
569
|
+
"unas",
|
|
570
|
+
"uno",
|
|
571
|
+
"unos",
|
|
572
|
+
"usted",
|
|
573
|
+
"ustedes",
|
|
574
|
+
"va",
|
|
575
|
+
"vamos",
|
|
576
|
+
"ver",
|
|
577
|
+
"vez",
|
|
578
|
+
"vosotras",
|
|
579
|
+
"vosotros",
|
|
580
|
+
"vuestra",
|
|
581
|
+
"vuestras",
|
|
582
|
+
"vuestro",
|
|
583
|
+
"vuestros",
|
|
584
|
+
"y",
|
|
585
|
+
"ya",
|
|
586
|
+
"yo",
|
|
587
|
+
"\xE9l",
|
|
588
|
+
"\xE9sta",
|
|
589
|
+
"\xE9stas",
|
|
590
|
+
"\xE9ste",
|
|
591
|
+
"\xE9stos",
|
|
592
|
+
"\xFAltima",
|
|
593
|
+
"\xFAltimas",
|
|
594
|
+
"\xFAltimo",
|
|
595
|
+
"\xFAltimos"
|
|
596
|
+
]);
|
|
597
|
+
var spanish = {
|
|
598
|
+
name: "spanish",
|
|
599
|
+
stemmer: stem,
|
|
600
|
+
stopWords,
|
|
601
|
+
tokenizer: {
|
|
602
|
+
splitPattern: /[^a-z0-9á-úñü]+/gi
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
export { spanish };
|