Overview
| Comment: | [graphspell] use nDistLimit to truncate number of suggestions | 
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive | 
| Timelines: | family | ancestors | descendants | both | trunk | graphspell | 
| Files: | files | file ages | folders | 
| SHA3-256: | 
f3a3ed9041d66e75a8c73a5a66daa068 | 
| User & Date: | olr on 2018-05-02 11:22:50 | 
| Original Comment: | [graphspell] use nDistLimit to trancate number of suggestions | 
| Other Links: | manifest | tags | 
Context
| 
   2018-05-02 
 | ||
| 12:33 | [graphspell] spelling suggestion speed up: calculate approximate distance while exploring the word graph check-in: 2be7acdcad user: olr tags: trunk, graphspell | |
| 11:22 | [graphspell] use nDistLimit to truncate number of suggestions check-in: f3a3ed9041 user: olr tags: trunk, graphspell | |
| 10:29 | [graphspell] char_player: cut also prefixes for better suggestions check-in: 3955fe8676 user: olr tags: trunk, graphspell | |
Changes
Modified graphspell-js/ibdawg.js from [f093112b5c] to [83b959776d].
| ︙ | ︙ | |||
59 60 61 62 63 64 65  | 
        if (this.dSugg.get(0).length) {
            // we sort the better results with the original word
            let dDistTemp = new Map();
            lRes.forEach((sSugg) => { dDistTemp.set(sSugg, str_transform.distanceDamerauLevenshtein(this.sWord, sSugg)); });
            lRes = lRes.sort((sA, sB) => { return dDistTemp.get(sA) - dDistTemp.get(sB); });
            dDistTemp.clear();
        }
 | | > > > |  | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77  | 
        if (this.dSugg.get(0).length) {
            // we sort the better results with the original word
            let dDistTemp = new Map();
            lRes.forEach((sSugg) => { dDistTemp.set(sSugg, str_transform.distanceDamerauLevenshtein(this.sWord, sSugg)); });
            lRes = lRes.sort((sA, sB) => { return dDistTemp.get(sA) - dDistTemp.get(sB); });
            dDistTemp.clear();
        }
        for (let [nDist, lSugg] of this.dSugg.entries()) {
            if (nDist > this.nDistLimit) {
                break;
            }
            lRes.push(...lSugg);
            if (lRes.length > nSuggLimit) {
                break;
            }
        }
        lRes = char_player.filterSugg(lRes);
        if (this.sWord.gl_isUpperCase()) {
            lRes = lRes.map((sSugg) => { return sSugg.toUpperCase(); });
 | 
| ︙ | ︙ | 
Modified graphspell/ibdawg.py from [d9511f25e6] to [9c9c4c03aa].
| ︙ | ︙ | |||
56 57 58 59 60 61 62  | 
                self.aSugg.add(sSugg)
                if nDist < self.nMinDist:
                    self.nMinDist = nDist
                self.nDistLimit = min(self.nDistLimit, self.nMinDist+2)
    def getSuggestions (self, nSuggLimit=10, nDistLimit=-1):
        "return a list of suggestions"
 | < > | > | | |  | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78  | 
                self.aSugg.add(sSugg)
                if nDist < self.nMinDist:
                    self.nMinDist = nDist
                self.nDistLimit = min(self.nDistLimit, self.nMinDist+2)
    def getSuggestions (self, nSuggLimit=10, nDistLimit=-1):
        "return a list of suggestions"
        if self.dSugg[0]:
            # we sort the better results with the original word
            self.dSugg[0].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
        lRes = list(cp.filterSugg(lRes))
        if self.sWord.isupper():
            lRes = list(map(lambda sSugg: sSugg.upper(), lRes))
        elif self.sWord[0:1].isupper():
            lRes = list(map(lambda sSugg: sSugg[0:1].upper()+sSugg[1:], lRes))  # dont’ use <.istitle>
        return lRes[:nSuggLimit]
 | 
| ︙ | ︙ |