Index: gc_core/js/ibdawg.js ================================================================== --- gc_core/js/ibdawg.js +++ gc_core/js/ibdawg.js @@ -200,13 +200,10 @@ 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(); }); @@ -313,35 +310,10 @@ } } 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 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 Index: gc_core/py/ibdawg.py ================================================================== --- gc_core/py/ibdawg.py +++ gc_core/py/ibdawg.py @@ -196,13 +196,10 @@ if sWord.istitle(): aSugg.update(self._suggest(sWord.lower(), nMaxDel=nMaxDel, nMaxHardRepl=nMaxHardRepl)) aSugg = set(map(lambda sSugg: sSugg.title(), aSugg)) elif sWord.islower(): aSugg.update(self._suggest(sWord.title(), nMaxDel=nMaxDel, nMaxHardRepl=nMaxHardRepl)) - if not aSugg: - #print("crush useless chars") - aSugg.update(self._suggestWithCrushedUselessChars(cp.shrinkWord(sWord))) aSugg = cp.filterSugg(aSugg) sCleanWord = cp.cleanWord(sWord) aSugg = sorted(aSugg, key=lambda sSugg: cp.distanceDamerauLevenshtein(sCleanWord, cp.cleanWord(sSugg)))[:nMaxSugg] if sSfx or sPfx: # we add what we removed @@ -273,30 +270,10 @@ aTails.add(sTail + self.dCharVal[nVal]) if n and not aTails: aTails.update(self._getTails(jAddr, sTail+self.dCharVal[nVal], n-1)) return aTails - def _suggestWithCrushedUselessChars (self, sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=False): - aSugg = set() - if not sWord: - if int.from_bytes(self.byDic[iAddr:iAddr+self.nBytesArc], byteorder='big') & self._finalNodeMask: - #show(nDeep, "!!! " + sNewWord + " !!!") - aSugg.add(sNewWord) - return aSugg - cCurrent = sWord[0:1] - for cChar, jAddr in self._getSimilarArcsAndCrushedChars(cCurrent, iAddr): - #show(nDeep, cChar) - aSugg.update(self._suggestWithCrushedUselessChars(sWord[1:], nDeep+1, jAddr, sNewWord+cChar)) - return aSugg - - def _getSimilarArcsAndCrushedChars (self, cChar, iAddr): - "generator: yield similar char of and address of the following node" - for nVal, jAddr in self._getArcs(iAddr): - if self.dCharVal.get(nVal, None) in cp.aVovels: - yield (self.dCharVal[nVal], jAddr) - yield from self._getSimilarArcs(cChar, iAddr) - def drawPath (self, sWord, iAddr=0): "show the path taken by in the graph" cChar = sWord[0:1] if sWord else " " iPos = -1 n = 0