293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
-
+
-
-
-
-
+
+
|
# Phonetic replacements
for sRepl in cp.d1toX.get(cCurrent, ()):
self._suggest(oSuggResult, sRepl + sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl, nDeep+1, iAddr, sNewWord, cCurrent+">"+sRepl, True)
for sRepl in cp.d2toX.get(sRemain[0:2], ()):
self._suggest(oSuggResult, sRepl + sRemain[2:], nMaxSwitch, nMaxDel, nMaxHardRepl, nDeep+1, iAddr, sNewWord, sRemain[0:2]+">"+sRepl, True)
# Hard replacements
if nDeep > 3 and nMaxHardRepl:
for nVal, kAddr in self._getArcs1(iAddr):
for cChar, kAddr in self._getCharArcs(iAddr):
if nVal in self.dCharVal:
cChar = self.dCharVal[nVal]
if cChar not in cp.d1to1.get(cCurrent, ""):
self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl-1, nDeep+1, kAddr, sNewWord+cChar, "[["+cChar+"]]", True)
if cChar not in cp.d1to1.get(cCurrent, ""):
self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl-1, nDeep+1, kAddr, sNewWord+cChar, "[["+cChar+"]]", True)
# end of word
if len(sRemain) == 2:
for sRepl in cp.dFinal2.get(sRemain, ()):
self._suggest(oSuggResult, sRepl, nMaxSwitch, nMaxDel, nMaxHardRepl, nDeep+1, iAddr, sNewWord, sRemain + " >> " + sRepl, True)
elif len(sRemain) == 1:
self._suggest(oSuggResult, "", nMaxSwitch, nMaxDel, nMaxHardRepl, nDeep+1, iAddr, sNewWord, sRemain + " [last char removed] ", True) # remove last char and go o
for sRepl in cp.dFinal1.get(sRemain, ()):
|