Grammalecte  Check-in [35d2a24375]

Overview
Comment:[tb] use Graphspell instead of Hunspell for spelling suggestions + [graphspell] str_transform: update exports bullshit again
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tb | graphspell | multid
Files: files | file ages | folders
SHA3-256: 35d2a24375174351ea33d23ccd5f8d74debef2b67e777fbe18f8ef804b040693
User & Date: olr on 2018-03-29 09:48:33
Original Comment: [graphspell] str_transform: update exports bullshit again
Other Links: branch diff | manifest | tags
Context
2018-03-29
09:52
[tb] remove console.log() check-in: 9510e5d68c user: olr tags: tb, multid
09:48
[tb] use Graphspell instead of Hunspell for spelling suggestions + [graphspell] str_transform: update exports bullshit again check-in: 35d2a24375 user: olr tags: tb, graphspell, multid
2018-03-28
18:35
[fx] lexicon editor: import dictionary check-in: b9f0eaf6cb user: olr tags: fx, multid
Changes

Modified gc_lang/fr/tb/content/overlay.js from [a85c2d244d] to [7168d199f9].

338
339
340
341
342
343
344
345
346

































347
348
349
350
351
352
353
338
339
340
341
342
343
344


345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384







-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







        xNodeDiv.appendChild(xNodeMessage);
        // suggestions
        let xNodeSuggLine = document.createElement("p");
        xNodeSuggLine.setAttribute("class", "suggestions");
        let xNodeSuggButton = document.createElement("span");
        xNodeSuggButton.setAttribute("class", "suggestions_button");
        xNodeSuggButton.textContent = "Suggestions : ";
        xNodeSuggButton.addEventListener("click", function (e) {
            if (this.bDictActive === null) {
        xNodeSuggButton.addEventListener("click", (e) => {
            let xPromise = this.xGCEWorker.post('suggest', [dErr['sValue'], 10]);
            xPromise.then(
                function (sVal) {
                    console.log(sVal);
                    if (sVal != "") {
                        let lSugg = sVal.split("|");
                        let n = 0;
                        for (let sSugg of lSugg) {
                            if (true || n > 0) {
                                xNodeSuggLine.appendChild(document.createTextNode(" "));
                            }
                            let xNodeSugg = document.createElement("span");
                            xNodeSugg.setAttribute("class", "sugg");
                            xNodeSugg.textContent = sSugg;
                            xNodeSugg.addEventListener("click", function (e) {
                                xEditor.changeParagraph(iParagraph, xNodeSugg.textContent, dErr["nStart"], dErr["nEnd"]);
                                xNodeDiv.textContent = "";
                                that.reparseParagraph(xEditor, iParagraph);
                            });
                            xNodeSuggLine.appendChild(xNodeSugg);
                            n += 1;
                        }
                    } else {
                        xNodeSuggLine.appendChild(document.createTextNode("Aucune suggestion."));
                    }
                    
                },
                function (aReason) { console.error('Promise rejected - ', aReason); }
            ).catch(
                function (aCaught) { console.error('Promise Error - ', aCaught); }
            );
            /*if (this.bDictActive === null) {
                this.bDictActive = oSpellControl.setDictionary("fr");
            }
            try {
                let aSugg = oSpellControl.suggest(dErr['sValue']);
                if (aSugg) {
                    let n = 0;
                    for (let sSugg of aSugg) {
368
369
370
371
372
373
374
375

376
377
378
379
380
381
382
399
400
401
402
403
404
405

406
407
408
409
410
411
412
413







-
+







                } else {
                    xNodeSuggLine.appendChild(document.createTextNode("Aucune suggestion."));
                }
            }
            catch (e) {
                xNodeSuggLine.appendChild(document.createTextNode("# Erreur : dictionnaire orthographique introuvable."));
                Cu.reportError(e);
            }
            }*/
        });
        xNodeSuggLine.appendChild(xNodeSuggButton);
        xNodeDiv.appendChild(xNodeSuggLine);
        return xNodeDiv;
    },
    loadUI: function() {
        echo("loadUI");

Modified gc_lang/fr/tb/worker/gce_worker.js from [d38c273279] to [d40c8ac28d].

105
106
107
108
109
110
111








112
113
114
115
116
117
118
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126







+
+
+
+
+
+
+
+







}

function parseAndSpellcheck (sText, sCountry, bDebug, bContext) {
    let aGrammErr = gce.parse(sText, sCountry, bDebug, bContext);
    let aSpellErr = oSpellChecker.parseParagraph(sText);
    return JSON.stringify({ aGrammErr: aGrammErr, aSpellErr: aSpellErr });
}

function suggest (sWord, nSuggLimit=10) {
    let lSugg = []
    for (let aSugg of oSpellChecker.suggest(sWord, nSuggLimit)) {
        lSugg.push(...aSugg);
    }
    return lSugg.join("|");
}

function getOptions () {
    return gce.getOptions().gl_toString();
}

function getDefaultOptions () {
    return gce.getDefaultOptions().gl_toString();

Modified graphspell-js/str_transform.js from [4a82fc9e42] to [1ed9d3e05c].

209
210
211
212
213
214
215




216
217


218
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224







+
+
+
+


+
+

        sWord = sPfxCode.slice(1) + sWord.slice(sPfxCode.charCodeAt(0)-48);
        return sSfxCode[0] == '0' ? sWord + sSfxCode.slice(1) : sWord.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1);
    }
};


if (typeof(exports) !== 'undefined') {
    exports.longestCommonSubstring = str_transform.longestCommonSubstring;
    exports.distanceDamerauLevenshtein = str_transform.distanceDamerauLevenshtein;
    exports.distanceDamerauLevenshtein2 = str_transform.distanceDamerauLevenshtein2;
    exports.showDistance = str_transform.showDistance;
    exports.changeWordWithSuffixCode = str_transform.changeWordWithSuffixCode;
    exports.changeWordWithAffixCode = str_transform.changeWordWithAffixCode;
    exports.defineAffixCode = str_transform.defineAffixCode;
    exports.defineSuffixCode = str_transform.defineSuffixCode;
}