69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
-
+
-
+
|
if nDist < self.nMinDist:
self.nMinDist = nDist
self.nDistLimit = min(self.nDistLimit, self.nMinDist+1)
def getSuggestions (self, nSuggLimit=10):
"return a list of suggestions"
# we sort the better results with the original word
if self.dSugg[0]:
if len(self.dSugg[0]) > 1:
self.dSugg[0].sort(key=lambda sSugg: st.distanceDamerauLevenshtein(self.sWord, sSugg))
elif self.dSugg[1]:
elif len(self.dSugg[1]) > 1:
self.dSugg[1].sort(key=lambda sSugg: st.distanceDamerauLevenshtein(self.sWord, sSugg))
lRes = self.dSugg.pop(0)
for nDist, lSugg in self.dSugg.items():
if nDist <= self.nDistLimit:
lRes.extend(lSugg)
if len(lRes) > nSuggLimit:
break
|