Overview
Comment: | [core] ibdawg: suggest > avoid useless recursivity |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core | spellsugg |
Files: | files | file ages | folders |
SHA3-256: |
7d3b4993eed4faeade8e31b872c6ceac |
User & Date: | olr on 2017-11-08 08:26:36 |
Original Comment: | [core] ibdawg: suggest > avoid useless recursion |
Other Links: | branch diff | manifest | tags |
Context
2017-11-08
| ||
08:52 | [core] ibdawg: code clarification check-in: f7c9ad046c user: olr tags: core, spellsugg | |
08:26 | [core] ibdawg: suggest > avoid useless recursivity check-in: 7d3b4993ee user: olr tags: core, spellsugg | |
08:16 | [core] ibdawg: suggest > maximum number of switches > faster search check-in: a85c70d24d user: olr tags: core, spellsugg | |
Changes
Modified gc_core/py/ibdawg.py from [33982d882f] to [0a0b7a93a2].
︙ | ︙ | |||
275 276 277 278 279 280 281 | for sTail in self._getTails(iAddr): oSuggResult.addSugg(sNewWord+sTail, nDeep) return cCurrent = sRemain[0:1] for cChar, jAddr in self._getSimilarCharArcs(cCurrent, iAddr): self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl, nDeep+1, jAddr, sNewWord+cChar, "*") if not bAvoidLoop: # avoid infinite loop | > | | | | | | | | | | | | | | | | | | | | | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | for sTail in self._getTails(iAddr): oSuggResult.addSugg(sNewWord+sTail, nDeep) return cCurrent = sRemain[0:1] for cChar, jAddr in self._getSimilarCharArcs(cCurrent, iAddr): self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl, nDeep+1, jAddr, sNewWord+cChar, "*") if not bAvoidLoop: # avoid infinite loop if len(sRemain) > 1: if cCurrent == sRemain[1:2]: # same char, we remove 1 char without adding 1 to <sNewWord> self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl, nDeep+1, iAddr, sNewWord, cCurrent+"/2") else: # switching chars if nMaxSwitch: self._suggest(oSuggResult, sRemain[1:2]+sRemain[0:1]+sRemain[2:], nMaxSwitch-1, nMaxDel, nMaxHardRepl, nDeep+1, iAddr, sNewWord, "><",True) # delete char if nMaxDel: self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel-1, nMaxHardRepl, nDeep+1, iAddr, sNewWord, "-"+cCurrent, True) # 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): 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) # 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, ()): |
︙ | ︙ |