212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
#show(nDeep, cChar)
aSugg.update(self._suggest(sRemain[1:], nDeep+1, jAddr, sNewWord+cChar))
if not bAvoidLoop: # avoid infinite loop
#show(nDeep, ":no loop:")
if cCurrent == sRemain[1:2]:
# same char, we remove 1 char without adding 1 to <sNewWord>
aSugg.update(self._suggest(sRemain[1:], nDeep+1, iAddr, sNewWord))
for sRepl in cp.d1toX.get(cCurrent, ()):
#show(nDeep, sRepl)
aSugg.update(self._suggest(sRepl + sRemain[1:], nDeep+1, iAddr, sNewWord, True))
for sRepl in cp.d2toX.get(sRemain[0:2], ()):
#show(nDeep, sRepl)
aSugg.update(self._suggest(sRepl + sRemain[2:], nDeep+1, iAddr, sNewWord, True))
if len(sRemain) == 2:
|
>
>
>
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
#show(nDeep, cChar)
aSugg.update(self._suggest(sRemain[1:], nDeep+1, jAddr, sNewWord+cChar))
if not bAvoidLoop: # avoid infinite loop
#show(nDeep, ":no loop:")
if cCurrent == sRemain[1:2]:
# same char, we remove 1 char without adding 1 to <sNewWord>
aSugg.update(self._suggest(sRemain[1:], nDeep+1, iAddr, sNewWord))
else:
# switching chars
aSugg.update(self._suggest(sRemain[1:2]+sRemain[0:1]+sRemain[2:], nDeep+1, iAddr, sNewWord, True))
for sRepl in cp.d1toX.get(cCurrent, ()):
#show(nDeep, sRepl)
aSugg.update(self._suggest(sRepl + sRemain[1:], nDeep+1, iAddr, sNewWord, True))
for sRepl in cp.d2toX.get(sRemain[0:2], ()):
#show(nDeep, sRepl)
aSugg.update(self._suggest(sRepl + sRemain[2:], nDeep+1, iAddr, sNewWord, True))
if len(sRemain) == 2:
|