Grammalecte  Diff

Differences From Artifact [4d4d4ec095]:

To Artifact [ff4d262785]:


1
2


3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
10
11


+
+







// Grammar checker engine

//"use strict";

${string}
${regex}
${map}


if (typeof(require) !== 'undefined') {
    var helpers = require("resource://grammalecte/helpers.js");
82
83
84
85
86
87
88
89

90
91
92
93
94
95
96
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98







-
+








        // parse sentence
        for (let [iStart, iEnd] of this._getSentenceBoundaries(sText)) {
            if (4 < (iEnd - iStart) < 2000) {
                dDA.clear();
                //echo(sText.slice(iStart, iEnd));
                try {
                    [_, errs] = this._proofread(sText.slice(iStart, iEnd), sAlt.slice(iStart, iEnd), iStart, false, dDA, dPriority, sCountry, bDebug, bContext);
                    [sNew, errs] = this._proofread(sText.slice(iStart, iEnd), sAlt.slice(iStart, iEnd), iStart, false, dDA, dPriority, sCountry, bDebug, bContext);
                    dErrors.gl_update(errs);
                }
                catch (e) {
                    helpers.logerror(e);
                }
            }
        }
215
216
217
218
219
220
221

222
223
224
225
226
227
228
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231







+







            if (bUppercase && m[iGroup].slice(0,1).gl_isUpperCase()) {
                oErr["aSuggestions"] = capitalizeArray(sRepl.gl_expand(m).split("|"));
            } else {
                oErr["aSuggestions"] = sRepl.gl_expand(m).split("|");
            }
        }
        // Message
        let sMessage = "";
        if (sMsg[0] === "=") {
            sMessage = oEvalFunc[sMsg.slice(1)](s, m)
        } else {
            sMessage = sMsg.gl_expand(m);
        }
        if (bIdRule) {
            sMessage += " ##" + sLineId + " #" + sRuleId;
276
277
278
279
280
281
282
283
284


285
286
287
288
289
290
291


292
293
294
295
296
297
298
279
280
281
282
283
284
285


286
287
288
289
290
291
292


293
294
295
296
297
298
299
300
301







-
-
+
+





-
-
+
+







    reactivateRule: function (sRuleId) {
        _aIgnoredRules.delete(sRuleId);
    },

    listRules: function (sFilter=null) {
        // generator: returns tuple (sOption, sLineId, sRuleId)
        try {
            for ([sOption, lRuleGroup] of this._getRules(true)) {
                for ([_, _, sLineId, sRuleId, _, _] of lRuleGroup) {
            for (let [sOption, lRuleGroup] of this._getRules(true)) {
                for (let [x1, x2, sLineId, sRuleId, x3, x4] of lRuleGroup) {
                    if (!sFilter || sRuleId.test(sFilter)) {
                        yield [sOption, sLineId, sRuleId];
                    }
                }
            }
            for ([sOption, lRuleGroup] of this._getRules(false)) {
                for ([_, _, sLineId, sRuleId, _, _] of lRuleGroup) {
            for (let [sOption, lRuleGroup] of this._getRules(false)) {
                for (let [x1, x2, sLineId, sRuleId, x3, x4] of lRuleGroup) {
                    if (!sFilter || sRuleId.test(sFilter)) {
                        yield [sOption, sLineId, sRuleId];
                    }
                }
            }
        }
        catch (e) {