Index: gc_core/js/char_player.js ================================================================== --- gc_core/js/char_player.js +++ gc_core/js/char_player.js @@ -21,11 +21,11 @@ sWord = sWord.toLowerCase(); let sRes = ""; for (let c of sWord) { sRes += this._dTransChars.gl_get(c, c); } - return sWord.replace("eau", "o").replace("au", "o"); + return sRes.replace("eau", "o").replace("au", "o"); }, distanceDamerauLevenshtein: function (s1, s2) { // distance of Damerau-Levenshtein between and // https://fr.wikipedia.org/wiki/Distance_de_Damerau-Levenshtein @@ -61,10 +61,16 @@ catch (e) { helpers.logerror(e); } }, + showDistance (s1, s2) { + let s1b = this.cleanWord(s1); + let s2b = this.cleanWord(s2); + console.log(`Distance: ${s1} / ${s2} = ${this.distanceDamerauLevenshtein(s1, s2)})`); + console.log(`Distance: ${s1b} / ${s2b} = ${this.distanceDamerauLevenshtein(s1b, s2b)})`); + }, // Method: Remove Useless Chars aVovels: new Set([ 'a', 'e', 'i', 'o', 'u', 'y', Index: gc_core/js/ibdawg.js ================================================================== --- gc_core/js/ibdawg.js +++ gc_core/js/ibdawg.js @@ -202,16 +202,16 @@ else if (sWord.gl_isLowerCase()) { aSugg.gl_update(this._suggest(sWord.gl_toCapitalize(), nMaxDel, nMaxHardRepl)); } // Set to Array aSugg = Array.from(aSugg); - aSugg = aSugg.filter((sSugg) => { return !sSugg.endsWith("è") && !sSugg.endsWith("È"); }); // fr language + aSugg = char_player.filterSugg(aSugg); if (sWord.gl_isTitle()) { aSugg = aSugg.map((sSugg) => { return sSugg.gl_toCapitalize(); }); } let dDistTemp = new Map(); - let sCleanWord = char_player.cleanWord(sWord) + let sCleanWord = char_player.cleanWord(sWord); aSugg.forEach((sSugg) => { dDistTemp.set(sSugg, char_player.distanceDamerauLevenshtein(sCleanWord, char_player.cleanWord(sSugg))); }); aSugg = aSugg.sort((sA, sB) => { return dDistTemp.get(sA) - dDistTemp.get(sB); }).slice(0, nMaxSugg); dDistTemp.clear(); if (sSfx || sPfx) { // we add what we removed Index: gc_core/py/char_player.py ================================================================== --- gc_core/py/char_player.py +++ gc_core/py/char_player.py @@ -39,10 +39,17 @@ ) if i and j and s1[i] == s2[j-1] and s1[i-1] == s2[j]: d[i, j] = min(d[i, j], d[i-2, j-2] + nCost) # Transposition return d[nLen1-1, nLen2-1] + +def showDistance (s1, s2): + s1b = cleanWord(s1); + s2b = cleanWord(s2); + print(f"Distance: {s1} / {s2} = {distanceDamerauLevenshtein(s1, s2)}") + print(f"Distance: {s1b} / {s2b} = {distanceDamerauLevenshtein(s1b, s2b)}") + # Method: Remove Useless Chars _dVovels = { 'a': '', 'e': '', 'i': '', 'o': '', 'u': '', 'y': '',