Grammalecte  Diff

Differences From Artifact [48f4ad6627]:

To Artifact [e66ef9b298]:


1
2
3
4
5
6
7
8
9
#!python3
# -*- coding: UTF-8 -*-

import os
import traceback
import pkgutil
import re
from itertools import chain


<







1

2
3
4
5
6
7
8
#!python3


import os
import traceback
import pkgutil
import re
from itertools import chain

184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
            if sWord.isupper() and len(sWord) > 1:
                l.extend(self.morph(sWord.capitalize()))
        return l

    def suggest (self, sWord):
        "returns a set of similar words"
        # first, we check for similar words
        #return set(self._suggestWithCrushedUselessChars(cp.clearWord(sWord)))
        aSugg = self._suggest(sWord)
        if not aSugg:
            aSugg.update(self._suggest(sWord[1:]))
            aSugg.update(self._suggest(sWord[:-1]))
            aSugg.update(self._suggest(sWord[1:-1]))
            if not aSugg:
                aSugg.update(self._suggestWithCrushedUselessChars(cp.clearWord(sWord)))
        return aSugg

    def _suggest (self, sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=False):
        # RECURSIVE FUNCTION
        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
        #show(nDeep, "<" + sWord + ">  ===>  " + sNewWord)







|










|







183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
            if sWord.isupper() and len(sWord) > 1:
                l.extend(self.morph(sWord.capitalize()))
        return l

    def suggest (self, sWord):
        "returns a set of similar words"
        # first, we check for similar words
        #return self._suggestWithCrushedUselessChars(cp.clearWord(sWord))
        aSugg = self._suggest(sWord)
        if not aSugg:
            aSugg.update(self._suggest(sWord[1:]))
            aSugg.update(self._suggest(sWord[:-1]))
            aSugg.update(self._suggest(sWord[1:-1]))
            if not aSugg:
                aSugg.update(self._suggestWithCrushedUselessChars(cp.clearWord(sWord)))
        return aSugg

    def _suggest (self, sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=False):
        # recursive function
        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
        #show(nDeep, "<" + sWord + ">  ===>  " + sNewWord)