Grammalecte  Diff

Differences From Artifact [58e076d75b]:

To Artifact [979c697260]:


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
10
11
12
13
14
15
16

17
18
19
20
21
22
23







-







import pkgutil
import re
from functools import wraps
import time
import json
import binascii
import importlib
from collections import OrderedDict
from math import floor

#import logging
#logging.basicConfig(filename="suggestions.log", level=logging.DEBUG)

from . import str_transform as st
from . import char_player as cp
69
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84
85

86
87
88

89
90
91
92
93
94
95
68
69
70
71
72
73
74

75
76

77
78
79
80
81
82

83
84
85

86
87
88
89
90
91
92
93







-
+

-






-
+


-
+







            self.dAccSugg[sSugg] = min(nDist, nSimDist+1)
            if len(self.dAccSugg) > self.nTempSuggLimit:
                self.nDistLimit = -1  # suggest() ends searching when this variable = -1
        self.nDistLimit = min(self.nDistLimit, self.nMinDist+1)

    def getSuggestions (self):
        "return a list of suggestions"
        # we sort the better results with the original word
        # sort according to distance
        lRes = []
        # sort only with simplified words
        lResTmp = sorted(self.dAccSugg.items(), key=lambda x: (x[1], x[0]))
        for i in range(min(self.nSuggLimit, len(lResTmp))):
            lRes.append(lResTmp[i][0])
            #st.showDistance(self.sWord, lResTmp[i][0])
        # casing
        if self.sWord.isupper():
            lRes = list(OrderedDict.fromkeys(map(lambda sSugg: sSugg.upper(), lRes))) # use dict, when Python 3.6+
            lRes = list(dict.fromkeys(map(lambda sSugg: sSugg.upper(), lRes)))
        elif self.sWord[0:1].isupper():
            # don’t use <.istitle>
            lRes = list(OrderedDict.fromkeys(map(lambda sSugg: sSugg[0:1].upper()+sSugg[1:], lRes))) # use dict, when Python 3.6+
            lRes = list(dict.fromkeys(map(lambda sSugg: sSugg[0:1].upper()+sSugg[1:], lRes)))
        return lRes[:self.nSuggLimit]


class IBDAWG:
    """INDEXABLE BINARY DIRECT ACYCLIC WORD GRAPH"""

    def __init__ (self, source):