188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
-
-
-
+
+
+
+
+
|
}
// 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(); });
}
return aSugg.sort((sA, sB) => {
return char_player.distanceDamerauLevenshtein(sWord, sA) - char_player.distanceDamerauLevenshtein(sWord, sB);
}).slice(0, nMaxSugg);
let dDistTemp = new Map();
aSugg.forEach((sSugg) => { dDistTemp.set(sSugg, char_player.distanceDamerauLevenshtein(sWord, sSugg)); });
aSugg = aSugg.sort((sA, sB) => { return dDistTemp.get(sA) - dDistTemp.get(sB); }).slice(0, nMaxSugg);
dDistTemp.clear();
return aSugg;
}
_suggest (sRemain, nMaxDel=0, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=false) {
// returns a set of suggestions
// recursive function
//show(nDeep, sNewWord + ":" + sRemain)
let aSugg = new Set();
|