Index: graphspell-js/ibdawg.js ================================================================== --- graphspell-js/ibdawg.js +++ graphspell-js/ibdawg.js @@ -77,13 +77,15 @@ } } lRes = char_player.filterSugg(lRes); if (this.sWord.gl_isUpperCase()) { lRes = lRes.map((sSugg) => { return sSugg.toUpperCase(); }); + lRes = [...new Set(lRes)]; } else if (this.sWord.slice(0,1).gl_isUpperCase()) { lRes = lRes.map((sSugg) => { return sSugg.slice(0,1).toUpperCase() + sSugg.slice(1); }); + lRes = [...new Set(lRes)]; } return lRes.slice(0, nSuggLimit); } reset () { @@ -270,13 +272,12 @@ return true; } return !!(this.lookup(sWord.toLowerCase()) || this.lookup(sWord.gl_toCapitalize())); } return !!this.lookup(sWord.slice(0, 1).toLowerCase() + sWord.slice(1)); - } else { - return !!this.lookup(sWord.toLowerCase()); } + return !!this.lookup(sWord.toLowerCase()); } if (sWord.slice(0,1).gl_isDigit()) { return true; } return false; @@ -376,10 +377,14 @@ oSuggResult.addSugg(sNewWord+sTail); } return; } else if ( (sNewWord.length + sRemain.length == oSuggResult.sWord.length) && oSuggResult.sWord.toLowerCase().startsWith(sNewWord.toLowerCase()) && this.isValid(sRemain) ) { + if (this.sLangCode == "fr" + && ["l", "d", "n", "m", "t", "s", "c", "j", "qu", "lorsqu", "puisqu", "quoiqu", "jusqu", "quelqu"].includes(sNewWord.toLowerCase()) && char_player.aVowel.has(sRemain.slice(0,1))) { + oSuggResult.addSugg(sNewWord+"’"+sRemain); + } oSuggResult.addSugg(sNewWord+" "+sRemain); } } if (nDist > oSuggResult.nDistLimit) { return; Index: graphspell/ibdawg.py ================================================================== --- graphspell/ibdawg.py +++ graphspell/ibdawg.py @@ -11,10 +11,11 @@ import re from functools import wraps import time import json import binascii +from collections import OrderedDict #import logging #logging.basicConfig(filename="suggestions.log", level=logging.DEBUG) from . import str_transform as st @@ -75,13 +76,14 @@ lRes.extend(lSugg) if len(lRes) > nSuggLimit: break lRes = list(cp.filterSugg(lRes)) if self.sWord.isupper(): - lRes = list(map(lambda sSugg: sSugg.upper(), lRes)) + lRes = list(OrderedDict.fromkeys(map(lambda sSugg: sSugg.upper(), lRes))) # use dict, when Python 3.6+ elif self.sWord[0:1].isupper(): - lRes = list(map(lambda sSugg: sSugg[0:1].upper()+sSugg[1:], lRes)) # dont’ use <.istitle> + # dont’ use <.istitle> + lRes = list(OrderedDict.fromkeys(map(lambda sSugg: sSugg[0:1].upper()+sSugg[1:], lRes))) # use dict, when Python 3.6+ return lRes[:nSuggLimit] def reset (self): "clear data" self.aSugg.clear() @@ -335,10 +337,12 @@ oSuggResult.addSugg(sNewWord, nDeep) for sTail in self._getTails(iAddr): 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) oSuggResult.addSugg(sNewWord+" "+sRemain) if nDist > oSuggResult.nDistLimit: return cCurrent = sRemain[0:1] for cChar, jAddr in self._getCharArcs(iAddr):