184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
if sWord.isupper() and len(sWord) > 1:
l.extend(self.morph(sWord.capitalize()))
return l
def suggest (self, sWord):
"returns a set of similar words"
# first, we check for similar words
#return set(self._suggestWithCrushedUselessChars(cp.clearWord(sWord)))
aSugg = self._suggest(sWord)
if not aSugg:
aSugg.update(self._suggest(sWord[1:]))
aSugg.update(self._suggest(sWord[:-1]))
aSugg.update(self._suggest(sWord[1:-1]))
if not aSugg:
aSugg.update(self._suggestWithCrushedUselessChars(cp.clearWord(sWord)))
return aSugg
def _suggest (self, sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=False):
# RECURSIVE FUNCTION
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
#show(nDeep, "<" + sWord + "> ===> " + sNewWord)
|
|
|
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
if sWord.isupper() and len(sWord) > 1:
l.extend(self.morph(sWord.capitalize()))
return l
def suggest (self, sWord):
"returns a set of similar words"
# first, we check for similar words
#return self._suggestWithCrushedUselessChars(cp.clearWord(sWord))
aSugg = self._suggest(sWord)
if not aSugg:
aSugg.update(self._suggest(sWord[1:]))
aSugg.update(self._suggest(sWord[:-1]))
aSugg.update(self._suggest(sWord[1:-1]))
if not aSugg:
aSugg.update(self._suggestWithCrushedUselessChars(cp.clearWord(sWord)))
return aSugg
def _suggest (self, sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=False):
# recursive function
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
#show(nDeep, "<" + sWord + "> ===> " + sNewWord)
|