Grammalecte  Check-in [01db34f050]

Overview
Comment:[graphspell] ibdawg: sort suggestions only if more than one suggestion
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | graphspell
Files: files | file ages | folders
SHA3-256: 01db34f0506c0b1045c69de72262ab4308ffe7527a93fe0d270f91e624571f3a
User & Date: olr on 2020-09-08 08:52:58
Other Links: manifest | tags
Context
2020-09-09
08:35
[fr] ajustements check-in: bffc11601b user: olr tags: fr, trunk
2020-09-08
08:52
[graphspell] ibdawg: sort suggestions only if more than one suggestion check-in: 01db34f050 user: olr tags: graphspell, trunk
08:12
[graphspell][js] remove useless parameter and useless get/set check-in: e53fd4ae0e user: olr tags: graphspell, trunk
Changes

Modified graphspell/ibdawg.py from [01e0cc9f3f] to [ca3736e14d].

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