264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
aTails.update(self._getTails(jAddr, sTail+self.dCharVal[nVal], n-1))
return aTails
def _suggestWithCrushedUselessChars (self, sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=False):
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
cCurrent = sWord[0:1]
for cChar, jAddr in self._getSimilarArcsAndCrushedChars(cCurrent, iAddr):
show(nDeep, cChar)
aSugg.update(self._suggestWithCrushedUselessChars(sWord[1:], nDeep+1, jAddr, sNewWord+cChar))
return aSugg
def _getSimilarArcsAndCrushedChars (self, cChar, iAddr):
"generator: yield similar char of <cChar> and address of the following node"
for nVal, jAddr in self._getArcs(iAddr):
if self.dCharVal.get(nVal, None) in cp.aVovels:
|
|
|
|
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
aTails.update(self._getTails(jAddr, sTail+self.dCharVal[nVal], n-1))
return aTails
def _suggestWithCrushedUselessChars (self, sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=False):
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
cCurrent = sWord[0:1]
for cChar, jAddr in self._getSimilarArcsAndCrushedChars(cCurrent, iAddr):
#show(nDeep, cChar)
aSugg.update(self._suggestWithCrushedUselessChars(sWord[1:], nDeep+1, jAddr, sNewWord+cChar))
return aSugg
def _getSimilarArcsAndCrushedChars (self, cChar, iAddr):
"generator: yield similar char of <cChar> and address of the following node"
for nVal, jAddr in self._getArcs(iAddr):
if self.dCharVal.get(nVal, None) in cp.aVovels:
|