Grammalecte  Check-in [f4c85fbe0b]

Overview
Comment:[core] ibdawg: code cleaning
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | core
Files: files | file ages | folders
SHA3-256: f4c85fbe0b8986f412b9702c32ea6d2f8277ad4d1f2ed431559893e5cff1456d
User & Date: olr on 2017-07-03 02:35:21
Other Links: manifest | tags
Context
2017-07-03
09:30
[core] ibdawg: suggest() seeks for tails check-in: e07a5e6edb user: olr tags: core, trunk
02:35
[core] ibdawg: code cleaning check-in: f4c85fbe0b user: olr tags: core, trunk
2017-07-02
19:53
[core] ibdawg: suggest() use sets instead of lists check-in: f11e2ad39c user: olr tags: core, trunk
Changes

Modified gc_core/py/ibdawg.py from [48f4ad6627] to [e66ef9b298].

     1      1   #!python3
     2         -# -*- coding: UTF-8 -*-
     3      2   
     4      3   import os
     5      4   import traceback
     6      5   import pkgutil
     7      6   import re
     8      7   from itertools import chain
     9      8   
................................................................................
   184    183               if sWord.isupper() and len(sWord) > 1:
   185    184                   l.extend(self.morph(sWord.capitalize()))
   186    185           return l
   187    186   
   188    187       def suggest (self, sWord):
   189    188           "returns a set of similar words"
   190    189           # first, we check for similar words
   191         -        #return set(self._suggestWithCrushedUselessChars(cp.clearWord(sWord)))
          190  +        #return self._suggestWithCrushedUselessChars(cp.clearWord(sWord))
   192    191           aSugg = self._suggest(sWord)
   193    192           if not aSugg:
   194    193               aSugg.update(self._suggest(sWord[1:]))
   195    194               aSugg.update(self._suggest(sWord[:-1]))
   196    195               aSugg.update(self._suggest(sWord[1:-1]))
   197    196               if not aSugg:
   198    197                   aSugg.update(self._suggestWithCrushedUselessChars(cp.clearWord(sWord)))
   199    198           return aSugg
   200    199   
   201    200       def _suggest (self, sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=False):
   202         -        # RECURSIVE FUNCTION
          201  +        # recursive function
   203    202           aSugg = set()
   204    203           if not sWord:
   205    204               if int.from_bytes(self.byDic[iAddr:iAddr+self.nBytesArc], byteorder='big') & self._finalNodeMask:
   206    205                   #show(nDeep, "___" + sNewWord + "___")
   207    206                   aSugg.add(sNewWord)
   208    207               return aSugg
   209    208           #show(nDeep, "<" + sWord + ">  ===>  " + sNewWord)