Grammalecte  Check-in [e53fd4ae0e]

Overview
Comment:[graphspell][js] remove useless parameter and useless get/set
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | graphspell
Files: files | file ages | folders
SHA3-256: e53fd4ae0eb90f38ff235aa4438278250dbabc0b8cbec306240dbdf1211a0049
User & Date: olr on 2020-09-08 08:12:37
Other Links: manifest | tags
Context
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
2020-09-07
17:42
[graphsell][js] ibdawg: fix sort in getSuggestions check-in: 7d93db4a3b user: olr tags: trunk, graphspell
Changes

Modified graphspell-js/ibdawg.js from [027be60102] to [250621182e].

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
                    this.nMinDist = nDist;
                }
                this.nDistLimit = Math.min(this.nDistLimit, this.nMinDist+1);
            }
        }
    }

    getSuggestions (nSuggLimit=10, nDistLimit=-1) {
        // return a list of suggestions
        if (this.dSugg.get(0).length > 1) {
            // we sort the better results with the original word
            this.dSugg.set(0, [...this.dSugg.get(0)].sort((a, b) => { return str_transform.distanceDamerauLevenshtein(this.sWord, a) - str_transform.distanceDamerauLevenshtein(this.sWord, b); }));
        }
        else if (this.dSugg.get(1).length > 1) {
            this.dSugg.set(1, [...this.dSugg.get(1)].sort((a, b) => { return str_transform.distanceDamerauLevenshtein(this.sWord, a) - str_transform.distanceDamerauLevenshtein(this.sWord, b); }));
        }
        let lRes = [];
        for (let [nDist, lSugg] of this.dSugg.entries()) {
            if (nDist > this.nDistLimit) {
                break;
            }
            lRes.push(...lSugg);







|



|


|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
                    this.nMinDist = nDist;
                }
                this.nDistLimit = Math.min(this.nDistLimit, this.nMinDist+1);
            }
        }
    }

    getSuggestions (nSuggLimit=10) {
        // return a list of suggestions
        if (this.dSugg.get(0).length > 1) {
            // we sort the better results with the original word
            this.dSugg.get(0).sort((a, b) => { return str_transform.distanceDamerauLevenshtein(this.sWord, a) - str_transform.distanceDamerauLevenshtein(this.sWord, b); });
        }
        else if (this.dSugg.get(1).length > 1) {
            this.dSugg.get(1).sort((a, b) => { return str_transform.distanceDamerauLevenshtein(this.sWord, a) - str_transform.distanceDamerauLevenshtein(this.sWord, b); });
        }
        let lRes = [];
        for (let [nDist, lSugg] of this.dSugg.entries()) {
            if (nDist > this.nDistLimit) {
                break;
            }
            lRes.push(...lSugg);
499
500
501
502
503
504
505

506
507
508
509
510
511
512
        }
        return aTails;
    }

    // morph (sWord) {
    //     is defined in constructor
    // }

    getSimilarEntries (sWord, nSuggLimit=10) {
        // return a list of tuples (similar word, stem, morphology)
        if (sWord == "") {
            return [];
        }
        let lResult = [];
        for (let sSimilar of this.suggest(sWord, nSuggLimit)) {







>







499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
        }
        return aTails;
    }

    // morph (sWord) {
    //     is defined in constructor
    // }

    getSimilarEntries (sWord, nSuggLimit=10) {
        // return a list of tuples (similar word, stem, morphology)
        if (sWord == "") {
            return [];
        }
        let lResult = [];
        for (let sSimilar of this.suggest(sWord, nSuggLimit)) {