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: trunk, fr
2020-09-08
08:52
[graphspell] ibdawg: sort suggestions only if more than one suggestion check-in: 01db34f050 user: olr tags: trunk, graphspell
08:12
[graphspell][js] remove useless parameter and useless get/set check-in: e53fd4ae0e user: olr tags: trunk, graphspell
Changes

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

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]:
            self.dSugg[0].sort(key=lambda sSugg: st.distanceDamerauLevenshtein(self.sWord, sSugg))
        elif self.dSugg[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







|

|







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 len(self.dSugg[0]) > 1:
            self.dSugg[0].sort(key=lambda sSugg: st.distanceDamerauLevenshtein(self.sWord, sSugg))
        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