Grammalecte  Check-in [8b6694ecca]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[graphspell] JS sucks: for some strange reason, Thunderbird doesn’t like the using of hasOwnProperty with personal Object -> use Map
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | graphspell | v1.1
Files: files | file ages | folders
SHA3-256:8b6694ecca38fa9e726ae0e5c0911000df878b78a0e96abade450d8b3233e350
User & Date: olr 2019-05-15 07:55:07
Context
2019-05-15
09:15
pylint: exclusion list check-in: a31e62962a user: olr tags: trunk
07:55
[graphspell] JS sucks: for some strange reason, Thunderbird doesn’t like the using of hasOwnProperty with personal Object -> use Map check-in: 8b6694ecca user: olr tags: graphspell, trunk, v1.1
06:30
[fr] mise à jour du dictionnaire check-in: 07779d8b19 user: olr tags: fr, trunk
Changes

Changes to graphspell-js/spellchecker.js.

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
...
131
132
133
134
135
136
137
138

139




140
141
142
143
144
145
146
...
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
        this.oMainDic = this._loadDictionary(mainDic, sPath, true);
        this.oCommunityDic = this._loadDictionary(communityDic, sPath);
        this.oPersonalDic = this._loadDictionary(personalDic, sPath);
        this.bCommunityDic = Boolean(this.oCommunityDic);
        this.bPersonalDic = Boolean(this.oPersonalDic);
        this.oTokenizer = null;
        // Default suggestions
        this.oDefaultSugg = null;
        this.loadSuggestions(sLangCode)
        // storage
        this.bStorage = false;
        this._dMorphologies = new Map();            // key: flexion, value: list of morphologies
        this._dLemmas = new Map();                  // key: flexion, value: list of lemmas
    }

................................................................................


    // Default suggestions

    loadSuggestions (sLangCode) {
        // load default suggestion module for <sLangCode>
        // When “import” works everywhere, do like with Python
        if (suggest && suggest.hasOwnProperty(sLangCode)) {

            this.oDefaultSugg = suggest[sLangCode];




        }
    }


    // Storage

    activateStorage () {
................................................................................
            return this._dLemmas.get(sWord);
        }
        return Array.from(new Set(this.getMorph(sWord).map((sMorph) => { return sMorph.slice(1, sMorph.indexOf("/")); })));
    }

    * suggest (sWord, nSuggLimit=10) {
        // generator: returns 1, 2 or 3 lists of suggestions
        if (this.oDefaultSugg) {
            if (this.oDefaultSugg.hasOwnProperty(sWord)) {
                yield this.oDefaultSugg[sWord].split("|");
            } else if (sWord.gl_isTitle() && this.oDefaultSugg.hasOwnProperty(sWord.toLowerCase())) {
                let lRes = this.oDefaultSugg[sWord.toLowerCase()].split("|");
                yield lRes.map((sSugg) => { return sSugg.slice(0,1).toUpperCase() + sSugg.slice(1); });
            } else {
                yield this.oMainDic.suggest(sWord, nSuggLimit, true);
            }
        } else {
            yield this.oMainDic.suggest(sWord, nSuggLimit, true);
        }







|







 







|
>
|
>
>
>
>







 







|
|
|
|
|







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
        this.oMainDic = this._loadDictionary(mainDic, sPath, true);
        this.oCommunityDic = this._loadDictionary(communityDic, sPath);
        this.oPersonalDic = this._loadDictionary(personalDic, sPath);
        this.bCommunityDic = Boolean(this.oCommunityDic);
        this.bPersonalDic = Boolean(this.oPersonalDic);
        this.oTokenizer = null;
        // Default suggestions
        this.dDefaultSugg = null;
        this.loadSuggestions(sLangCode)
        // storage
        this.bStorage = false;
        this._dMorphologies = new Map();            // key: flexion, value: list of morphologies
        this._dLemmas = new Map();                  // key: flexion, value: list of lemmas
    }

................................................................................


    // Default suggestions

    loadSuggestions (sLangCode) {
        // load default suggestion module for <sLangCode>
        // When “import” works everywhere, do like with Python
        try {
            if (typeof(suggest) !== 'undefined') {
                this.dDefaultSugg = suggest[sLangCode];
            }
        }
        catch (e) {
            console.error(e);
        }
    }


    // Storage

    activateStorage () {
................................................................................
            return this._dLemmas.get(sWord);
        }
        return Array.from(new Set(this.getMorph(sWord).map((sMorph) => { return sMorph.slice(1, sMorph.indexOf("/")); })));
    }

    * suggest (sWord, nSuggLimit=10) {
        // generator: returns 1, 2 or 3 lists of suggestions
        if (this.dDefaultSugg) {
            if (this.dDefaultSugg.has(sWord)) {
                yield this.dDefaultSugg.get(sWord).split("|");
            } else if (sWord.gl_isTitle() && this.dDefaultSugg.has(sWord.toLowerCase())) {
                let lRes = this.dDefaultSugg.get(sWord.toLowerCase()).split("|");
                yield lRes.map((sSugg) => { return sSugg.slice(0,1).toUpperCase() + sSugg.slice(1); });
            } else {
                yield this.oMainDic.suggest(sWord, nSuggLimit, true);
            }
        } else {
            yield this.oMainDic.suggest(sWord, nSuggLimit, true);
        }

Changes to graphspell-js/suggest.js.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48




// JavaScript

"use strict";

var suggest = {
    "fr": {
        "bcp": "beaucoup",
        "ca": "ça",
        "cad": "c’est-à-dire",
        "cb": "combien|CB",
        "cdlt": "cordialement",
        "construirent": "construire|construisirent|construisent|construiront",
        "càd": "c’est-à-dire",
        "dc": "de|donc",
        "done": "donc|donne",
        "email": "courriel|e-mail|émail",
        "emails": "courriels|e-mails",
        "Etes-vous": "Êtes-vous",
        "Etiez-vous": "Étiez-vous",
        "Etions-nous": "Étions-nous",
        "parce-que": "parce que",
        "pcq": "parce que",
        "pd": "pendant|pédé",
        "pdq": "pendant que",
        "pdt": "pendant",
        "pdtq": "pendant que",
        "pk": "pourquoi",
        "pq": "pourquoi|PQ",
        "prq": "presque",
        "prsq": "presque",
        "qcq": "quiconque",
        "qq": "quelque",
        "qqch": "quelque chose",
        "qqn": "quelqu’un",
        "qqne": "quelqu’une",
        "qqs": "quelques",
        "qqunes": "quelques-unes",
        "qquns": "quelques-uns",
        "tdq": "tandis que",
        "tj": "toujours",
        "tjs": "toujours",
        "tq": "tant que|tandis que",
        "ts": "tous",
        "tt": "tant|tout",
        "tte": "toute",
        "ttes": "toutes"

    }
}









|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// JavaScript

"use strict";

var suggest = {
    fr: new Map ([
        ["bcp", "beaucoup"],
        ["ca", "ça"],
        ["cad", "c’est-à-dire"],
        ["cb", "combien|CB"],
        ["cdlt", "cordialement"],
        ["construirent", "construire|construisirent|construisent|construiront"],
        ["càd", "c’est-à-dire"],
        ["dc", "de|donc"],
        ["done", "donc|donne"],
        ["email", "courriel|e-mail|émail"],
        ["emails", "courriels|e-mails"],
        ["Etes-vous", "Êtes-vous"],
        ["Etiez-vous", "Étiez-vous"],
        ["Etions-vous", "Étions-nous"],
        ["parce-que", "parce que"],
        ["pcq", "parce que"],
        ["pd", "pendant|pédé"],
        ["pdq", "pendant que"],
        ["pdt", "pendant"],
        ["pdtq", "pendant que"],
        ["pk", "pourquoi"],
        ["pq", "pourquoi|PQ"],
        ["prq", "presque"],
        ["prsq", "presque"],
        ["qcq", "quiconque"],
        ["qq", "quelque"],
        ["qqch", "quelque chose"],
        ["qqn", "quelqu’un"],
        ["qqne", "quelqu’une"],
        ["qqs", "quelques"],
        ["qqunes", "quelques-unes"],
        ["qquns", "quelques-uns"],
        ["tdq", "tandis que"],
        ["tj", "toujours"],
        ["tjs", "toujours"],
        ["tq", "tant que|tandis que"],
        ["ts", "tous"],
        ["tt", "tant|tout"],
        ["tte", "toute"],
        ["ttes", "toutes"]
    ])
};


if (typeof(exports) !== 'undefined') {
    exports.fr = suggest.fr;
}