198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
-
-
-
|
let aSugg = this._suggest(sWord, nMaxDel, nMaxHardRepl);
if (sWord.gl_isTitle()) {
aSugg.gl_update(this._suggest(sWord.toLowerCase(), nMaxDel, nMaxHardRepl));
}
else if (sWord.gl_isLowerCase()) {
aSugg.gl_update(this._suggest(sWord.gl_toCapitalize(), nMaxDel, nMaxHardRepl));
}
if (aSugg.size == 0) {
aSugg.gl_update(this._suggestWithCrushedUselessChars(char_player.shrinkWord(sWord)));
}
// Set to Array
aSugg = Array.from(aSugg);
aSugg = aSugg.filter((sSugg) => { return !sSugg.endsWith("è") && !sSugg.endsWith("È"); }); // fr language
if (sWord.gl_isTitle()) {
aSugg = aSugg.map((sSugg) => { return sSugg.gl_toCapitalize(); });
}
let dDistTemp = new Map();
|
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
aTails.gl_update(this._getTails(jAddr, sTail+this.dCharVal.get(nVal), n-1));
}
}
}
return aTails;
}
_suggestWithCrushedUselessChars (sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=false) {
let aSugg = new Set();
if (sWord.length == 0) {
if (this._convBytesToInteger(this.byDic.slice(iAddr, iAddr+this.nBytesArc)) & this._finalNodeMask) {
aSugg.add(sNewWord);
}
return aSugg;
}
let cCurrent = sWord.slice(0, 1);
for (let [cChar, jAddr] of this._getSimilarArcsAndCrushedChars(cCurrent, iAddr)) {
aSugg.gl_update(this._suggestWithCrushedUselessChars(sWord.slice(1), nDeep+1, jAddr, sNewWord+cChar));
}
return aSugg;
}
* _getSimilarArcsAndCrushedChars (cChar, iAddr) {
// generator: yield similar char of <cChar> and address of the following node
for (let [nVal, jAddr] of this._getArcs(iAddr)) {
if (this.dCharVal.get(nVal, null) in char_player.aVovels) {
yield [this.dCharVal[nVal], jAddr];
}
}
yield* this._getSimilarArcs(cChar, iAddr);
}
// morph (sWord) {
// is defined in constructor
// }
// VERSION 1
_morph1 (sWord) {
// returns morphologies of sWord
|