Index: graphspell-js/ibdawg.js ================================================================== --- graphspell-js/ibdawg.js +++ graphspell-js/ibdawg.js @@ -389,11 +389,10 @@ } } if (nDist > oSuggResult.nDistLimit) { return; } - let cCurrent = sRemain.slice(0, 1); for (let [cChar, jAddr] of this._getCharArcs(iAddr)) { if (char_player.d1to1.gl_get(cCurrent, cCurrent).indexOf(cChar) != -1) { this._suggest(oSuggResult, sRemain.slice(1), nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump, nDist, nDeep+1, jAddr, sNewWord+cChar); } @@ -400,11 +399,11 @@ else if (!bAvoidLoop) { if (nMaxHardRepl && this.isNgramsOK(cChar+sRemain.slice(1,2))) { this._suggest(oSuggResult, sRemain.slice(1), nMaxSwitch, nMaxDel, nMaxHardRepl-1, nMaxJump, nDist+1, nDeep+1, jAddr, sNewWord+cChar, true); } if (nMaxJump) { - this._suggest(oSuggResult, sRemain, nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump-1, nDist+1, nDeep+1, jAddr, sNewWord+cChar, true); + this._suggest(oSuggResult, sRemain, nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump-1, nDist+1, nDeep+1, jAddr, sNewWord+cChar); // True for avoiding loop? } } } if (!bAvoidLoop) { // avoid infinite loop if (sRemain.length > 1) { Index: graphspell/ibdawg.py ================================================================== --- graphspell/ibdawg.py +++ graphspell/ibdawg.py @@ -340,11 +340,11 @@ oSuggResult.addSugg(sNewWord+sTail, nDeep) return if (len(sNewWord) + len(sRemain) == len(oSuggResult.sWord)) and oSuggResult.sWord.lower().startswith(sNewWord.lower()) and self.isValid(sRemain): if self.sLangCode == "fr" and sNewWord.lower() in ("l", "d", "n", "m", "t", "s", "c", "j", "qu", "lorsqu", "puisqu", "quoiqu", "jusqu", "quelqu") and sRemain[0:1] in cp.aVowel: oSuggResult.addSugg(sNewWord+"’"+sRemain) - if (len(sNewWord) > 1 and len(sRemain) > 1) or sNewWord in ("a", "à", "y") or sRemain in ("a", "à", "y"): + if (len(sNewWord) > 1 and len(sRemain) > 1) or sNewWord in "aày" or sRemain in "aày": oSuggResult.addSugg(sNewWord+" "+sRemain) if nDist > oSuggResult.nDistLimit: return cCurrent = sRemain[0:1] for cChar, jAddr in self._getCharArcs(iAddr): @@ -352,11 +352,11 @@ self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump, nDist, nDeep+1, jAddr, sNewWord+cChar) elif not bAvoidLoop: if nMaxHardRepl and self.isNgramsOK(cChar+sRemain[1:2]): self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl-1, nMaxJump, nDist+1, nDeep+1, jAddr, sNewWord+cChar, True) if nMaxJump: - self._suggest(oSuggResult, sRemain, nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump-1, nDist+1, nDeep+1, jAddr, sNewWord+cChar, True) + self._suggest(oSuggResult, sRemain, nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump-1, nDist+1, nDeep+1, jAddr, sNewWord+cChar) if not bAvoidLoop: # avoid infinite loop if len(sRemain) > 1: if cCurrent == sRemain[1:2]: # same char, we remove 1 char without adding 1 to self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump, nDist, nDeep+1, iAddr, sNewWord) @@ -409,35 +409,20 @@ sCleanNewWord = cp.simplifyWord(sNewWord) if st.distanceSift4(oSuggResult.sCleanWord[:len(sCleanNewWord)], sCleanNewWord) > oSuggResult.nDistLimit: return if int.from_bytes(self.byDic[iAddr:iAddr+self.nBytesArc], byteorder='big') & self._finalNodeMask: oSuggResult.addSugg(sNewWord, nDeep) - for cChar, jAddr in self._getCharArcsWithPriority(iAddr, oSuggResult.sWord[nDeep:nDeep+1]): + for cChar, jAddr in self._getCharArcs(iAddr, oSuggResult.sWord[nDeep:nDeep+1]): self._suggest2(oSuggResult, nDeep+1, jAddr, sNewWord+cChar) return def _getCharArcs (self, iAddr): "generator: yield all chars and addresses from node at address " for nVal, jAddr in self._getArcs(iAddr): if nVal <= self.nChar: yield (self.dCharVal[nVal], jAddr) - def _getSimilarCharArcs (self, cChar, iAddr): - "generator: yield similar char of and address of the following node" - for c in cp.d1to1.get(cChar, [cChar]): - if c in self.dChar: - jAddr = self._lookupArcNode(self.dChar[c], iAddr) - if jAddr: - yield (c, jAddr) - - def _getCharArcsWithPriority (self, iAddr, cChar): - if not cChar: - yield from self._getCharArcs(iAddr) - lTuple = list(self._getCharArcs(iAddr)) - lTuple.sort(key=lambda t: 0 if t[0] in cp.d1to1.get(cChar, cChar) else 1) - yield from lTuple - def _getTails (self, iAddr, sTail="", n=2): "return a list of suffixes ending at a distance of from " aTails = set() for nVal, jAddr in self._getArcs(iAddr): if nVal <= self.nChar: