Index: graphspell-js/ibdawg.js ================================================================== --- graphspell-js/ibdawg.js +++ graphspell-js/ibdawg.js @@ -26,14 +26,19 @@ this.sSimplifiedWord = char_player.simplifyWord(sWord); this.nDistLimit = (nDistLimit >= 0) ? nDistLimit : Math.floor(sWord.length / 3) + 1; this.nMinDist = 1000; this.aSugg = new Set(); this.dSugg = new Map([ [0, []], [1, []], [2, []] ]); + this.aAllSugg = new Set(); // all found words even those refused } addSugg (sSugg, nDeep=0) { // add a suggestion + if (this.aAllSugg.has(sSugg)) { + return; + } + this.aAllSugg.add(sSugg); if (!this.aSugg.has(sSugg)) { let nDist = str_transform.distanceDamerauLevenshtein(this.sSimplifiedWord, char_player.simplifyWord(sSugg)); if (nDist <= this.nDistLimit) { if (!this.dSugg.has(nDist)) { this.dSugg.set(nDist, []); Index: graphspell/ibdawg.py ================================================================== --- graphspell/ibdawg.py +++ graphspell/ibdawg.py @@ -37,14 +37,18 @@ self.sSimplifiedWord = cp.simplifyWord(sWord) self.nDistLimit = nDistLimit if nDistLimit >= 0 else (len(sWord) // 3) + 1 self.nMinDist = 1000 self.aSugg = set() self.dSugg = { 0: [], 1: [], 2: [] } + self.aAllSugg = set() # all found words even those refused def addSugg (self, sSugg, nDeep=0): "add a suggestion" #logging.info((nDeep * " ") + "__" + sSugg + "__") + if sSugg in self.aAllSugg: + return + self.aAllSugg.add(sSugg) if sSugg not in self.aSugg: nDist = st.distanceDamerauLevenshtein(self.sSimplifiedWord, cp.simplifyWord(sSugg)) if nDist <= self.nDistLimit: if nDist not in self.dSugg: self.dSugg[nDist] = []