Grammalecte  Check-in [2d5c0dce59]

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

Overview
Comment:[js] All Grammalecte work in node
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | njs | nodejs
Files: files | file ages | folders
SHA3-256:2d5c0dce59b2e3ebe062719a553a0652e0c6cf57a02b1c1939ddb60ba8c81419
User & Date: IllusionPerdu 2018-10-10 12:08:41
Context
2018-10-10
12:23
[js] Minimal file to use in node check-in: a43e8d10eb user: IllusionPerdu tags: njs, nodejs
12:08
[js] All Grammalecte work in node check-in: 2d5c0dce59 user: IllusionPerdu tags: njs, nodejs
09:36
Minimal file to use in node check-in: b79bb889b9 user: IllusionPerdu tags: graphspell, njs, nodejs
Changes

Changes to gc_core/js/lang_core/gc_engine.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
..
49
50
51
52
53
54
55
56



57
58
59
60
61
62
63
64
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
....
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
// Grammar checker engine


/*jslint esversion: 6*/
/*global console,require,exports*/


"use strict";

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








if (typeof(require) !== 'undefined') {
    var gc_options = require("resource://grammalecte/${lang}/gc_options.js");
    var gc_rules = require("resource://grammalecte/${lang}/gc_rules.js");
    var gc_rules_graph = require("resource://grammalecte/${lang}/gc_rules_graph.js");
    var cregex = require("resource://grammalecte/${lang}/cregex.js");
    var text = require("resource://grammalecte/text.js");
}


function capitalizeArray (aArray) {
    // can’t map on user defined function??
    let aNew = [];
    for (let i = 0; i < aArray.length; i = i + 1) {
................................................................................
    version: "${version}",
    author: "${author}",

    //// Initialization

    load: function (sContext="JavaScript", sColorType="aRGB", sPath="") {
        try {
            if (typeof(require) !== 'undefined') {



                var spellchecker = require("resource://grammalecte/graphspell/spellchecker.js");
                _oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}");
            } else {
                _oSpellChecker = new SpellChecker("${lang}", sPath, "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}");
            }
            _sAppContext = sContext;
            _dOptions = gc_options.getOptions(sContext).gl_shallowCopy();     // duplication necessary, to be able to reset to default
            _dOptionsColors = gc_options.getOptionsColors(sContext, sColorType);
................................................................................
        this.dTokenPos = new Map();
        this.dTags = new Map();
        this.dError = new Map();
        this.dErrorPriority = new Map();  // Key = position; value = priority
    }

    asString () {
        let s = "===== TEXT =====\n"
        s += "sentence: " + this.sSentence0 + "\n";
        s += "now:      " + this.sSentence  + "\n";
        for (let dToken of this.lToken) {
            s += `#${dToken["i"]}\t${dToken["nStart"]}:${dToken["nEnd"]}\t${dToken["sValue"]}\t${dToken["sType"]}`;
            if (dToken.hasOwnProperty("lMorph")) {
                s += "\t" + dToken["lMorph"].toString();
            }
................................................................................
${callablesJS}

    // callables for graph rules
${graph_callablesJS}
}


if (typeof(exports) !== 'undefined') {
    exports.lang = gc_engine.lang;
    exports.locales = gc_engine.locales;
    exports.pkg = gc_engine.pkg;
    exports.name = gc_engine.name;
    exports.version = gc_engine.version;
    exports.author = gc_engine.author;
    // init

>
>
|
<
>



|
|
|


>
>
>
>
>
>
|
|
|
|
|
|







 







|
>
>
>
|







 







|







 







|







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
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
....
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
// Grammar checker engine

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */

/* global require, exports, console */

"use strict";

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


if(typeof process !== 'undefined') {
    var gc_options = require('./gc_options.js');
    var gc_rules = require('./gc_rules.js');
    var gc_rules_graph = require('./gc_rules_graph.js');
    var cregex = require('./cregex.js');
    var text = require('../text.js');
} else if (typeof(require) !== 'undefined') {
    var gc_options = require('resource://grammalecte/${lang}/gc_options.js');
    var gc_rules = require('resource://grammalecte/${lang}/gc_rules.js');
    var gc_rules_graph = require('resource://grammalecte/${lang}/gc_rules_graph.js');
    var cregex = require('resource://grammalecte/${lang}/cregex.js');
    var text = require('resource://grammalecte/text.js');
}


function capitalizeArray (aArray) {
    // can’t map on user defined function??
    let aNew = [];
    for (let i = 0; i < aArray.length; i = i + 1) {
................................................................................
    version: "${version}",
    author: "${author}",

    //// Initialization

    load: function (sContext="JavaScript", sColorType="aRGB", sPath="") {
        try {
            if(typeof process !== 'undefined') {
                var spellchecker = require('../graphspell/spellchecker.js');
                _oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}");
            } else if (typeof require !== 'undefined') {
                var spellchecker = require('resource://grammalecte/graphspell/spellchecker.js');
                _oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}");
            } else {
                _oSpellChecker = new SpellChecker("${lang}", sPath, "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}");
            }
            _sAppContext = sContext;
            _dOptions = gc_options.getOptions(sContext).gl_shallowCopy();     // duplication necessary, to be able to reset to default
            _dOptionsColors = gc_options.getOptionsColors(sContext, sColorType);
................................................................................
        this.dTokenPos = new Map();
        this.dTags = new Map();
        this.dError = new Map();
        this.dErrorPriority = new Map();  // Key = position; value = priority
    }

    asString () {
        let s = "===== TEXT =====\n";
        s += "sentence: " + this.sSentence0 + "\n";
        s += "now:      " + this.sSentence  + "\n";
        for (let dToken of this.lToken) {
            s += `#${dToken["i"]}\t${dToken["nStart"]}:${dToken["nEnd"]}\t${dToken["sValue"]}\t${dToken["sType"]}`;
            if (dToken.hasOwnProperty("lMorph")) {
                s += "\t" + dToken["lMorph"].toString();
            }
................................................................................
${callablesJS}

    // callables for graph rules
${graph_callablesJS}
}


if (typeof exports !== 'undefined') {
    exports.lang = gc_engine.lang;
    exports.locales = gc_engine.locales;
    exports.pkg = gc_engine.pkg;
    exports.name = gc_engine.name;
    exports.version = gc_engine.version;
    exports.author = gc_engine.author;
    // init

Changes to gc_core/js/lang_core/gc_options.js.

1


2
3
4
5
6
7
8
9
10
..
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Options for Grammalecte


/*jslint esversion: 6*/
/*global exports*/

${map}


var gc_options = {
    getOptions: function (sContext="JavaScript") {
        if (this.dOpt.hasOwnProperty(sContext)) {
................................................................................
            for (let [sOpt, sColor] of Object.entries(dOptColor)) {
                dColor[sOpt] = dColorType[sColor];
            }
            return dColor;
        }
        catch (e) {
            console.error(e);
            return {}
        }
    },

    lStructOpt: ${lStructOpt},

    dOpt: {
        "JavaScript": new Map (${dOptJavaScript}),
................................................................................
    },

    dColorType: ${dColorType},

    dOptColor: ${dOptColor},

    dOptLabel: ${dOptLabel}
}


if (typeof(exports) !== 'undefined') {
	exports.getOptions = gc_options.getOptions;
    exports.getOptionsColors = gc_options.getOptionsColors;
	exports.lStructOpt = gc_options.lStructOpt;
    exports.dOpt = gc_options.dOpt;
    exports.dColorType = gc_options.dColorType;
    exports.dOptColor = gc_options.dOptColor;
	exports.dOptLabel = gc_options.dOptLabel;
}

>
>
|
|







 







|







 







|


|

|

|
|
|


1
2
3
4
5
6
7
8
9
10
11
12
..
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Options for Grammalecte

/* jshint esversion:6 */
/* jslint esversion:6 */
/* global exports */

${map}


var gc_options = {
    getOptions: function (sContext="JavaScript") {
        if (this.dOpt.hasOwnProperty(sContext)) {
................................................................................
            for (let [sOpt, sColor] of Object.entries(dOptColor)) {
                dColor[sOpt] = dColorType[sColor];
            }
            return dColor;
        }
        catch (e) {
            console.error(e);
            return {};
        }
    },

    lStructOpt: ${lStructOpt},

    dOpt: {
        "JavaScript": new Map (${dOptJavaScript}),
................................................................................
    },

    dColorType: ${dColorType},

    dOptColor: ${dOptColor},

    dOptLabel: ${dOptLabel}
};


if (typeof exports !== 'undefined') {
	exports.getOptions = gc_options.getOptions;
	exports.getOptionsColors = gc_options.getOptionsColors;
	exports.lStructOpt = gc_options.lStructOpt;
	exports.dOpt = gc_options.dOpt;
	exports.dColorType = gc_options.dColorType;
	exports.dOptColor = gc_options.dOptColor;
	exports.dOptLabel = gc_options.dOptLabel;
}

Changes to gc_core/js/lang_core/gc_rules.js.

1


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Grammar checker rules


/*jslint esversion: 6*/
/*global exports*/

"use strict";

${string}
${regex}

var gc_rules = {
    lParagraphRules: ${paragraph_rules_JS},

    lSentenceRules: ${sentence_rules_JS}
}


if (typeof(exports) !== 'undefined') {
    exports.lParagraphRules = gc_rules.lParagraphRules;
    exports.lSentenceRules = gc_rules.lSentenceRules;
}

>
>
|











|


|



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Grammar checker rules

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/*global exports*/

"use strict";

${string}
${regex}

var gc_rules = {
    lParagraphRules: ${paragraph_rules_JS},

    lSentenceRules: ${sentence_rules_JS}
};


if (typeof exports !== 'undefined') {
    exports.lParagraphRules = gc_rules.lParagraphRules;
    exports.lSentenceRules = gc_rules.lSentenceRules;
}

Changes to gc_core/js/lang_core/gc_rules_graph.js.

1


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Grammar checker graph rules


/*jslint esversion: 6*/
/*global exports*/

"use strict";

${string}


var gc_rules_graph = {
    dAllGraph: ${rules_graphsJS},

    dRule: ${rules_actionsJS}
}


if (typeof(exports) !== 'undefined') {
    exports.dAllGraph = gc_rules_graph.dAllGraph;
    exports.dRule = gc_rules_graph.dRule;
}

>
>
|




|






|


|



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Grammar checker graph rules

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/*global exports*/

"use strict";

//${string}


var gc_rules_graph = {
    dAllGraph: ${rules_graphsJS},

    dRule: ${rules_actionsJS}
};


if (typeof exports !== 'undefined') {
    exports.dAllGraph = gc_rules_graph.dAllGraph;
    exports.dRule = gc_rules_graph.dRule;
}

Changes to gc_core/js/tests.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
...
149
150
151
152
153
154
155
156
157
158
// JavaScript


/*jslint esversion: 6*/
/*global console,require,exports*/


"use strict";


if (typeof(require) !== 'undefined') {


    var helpers = require("resource://grammalecte/graphspell/helpers.js");
}


class TestGrammarChecking {

    constructor (gce, spfTests="") {
        this.gce = gce;
        this.spfTests = spfTests;
        this._aRuleTested = new Set();
    }

    * testParse (bDebug=false) {
        const t0 = Date.now();




        let sURL = (this.spfTests !== "") ? this.spfTests : "resource://grammalecte/"+this.gce.lang+"/tests_data.json";

        const aData = JSON.parse(helpers.loadFile(sURL)).aData;
        let nInvalid = 0;
        let nTotal = 0;
        let sErrorText;
        let sSugg;
        let sExpectedErrors;
        let sTextToCheck;
................................................................................
        }
        return [" ".repeat(sLine.length), ""];
    }

}


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

>
>
|
<
>




|
>
>
|













>
>
>
>
|
>







 







|


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
...
158
159
160
161
162
163
164
165
166
167
// JavaScript

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */

/* global require, exports, console */

"use strict";


if(typeof process !== 'undefined') {
    var helpers = require('./graphspell/helpers.js');
} else if (typeof require !== 'undefined') {
    var helpers = require('resource://grammalecte/graphspell/helpers.js');
}


class TestGrammarChecking {

    constructor (gce, spfTests="") {
        this.gce = gce;
        this.spfTests = spfTests;
        this._aRuleTested = new Set();
    }

    * testParse (bDebug=false) {
        const t0 = Date.now();
        let sURL;
        if(typeof process !== 'undefined') {
            sURL = (this.spfTests !== "") ? this.spfTests : "./"+this.gce.lang+"/tests_data.json";
        } else {
            sURL = (this.spfTests !== "") ? this.spfTests : "resource://grammalecte/"+this.gce.lang+"/tests_data.json";
        }
        const aData = JSON.parse(helpers.loadFile(sURL)).aData;
        let nInvalid = 0;
        let nTotal = 0;
        let sErrorText;
        let sSugg;
        let sExpectedErrors;
        let sTextToCheck;
................................................................................
        }
        return [" ".repeat(sLine.length), ""];
    }

}


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

Changes to gc_core/js/text.js.

1


2
3
4
5
6
7
8
9
10
..
55
56
57
58
59
60
61
62
63
64
65
66
// JavaScript


/*jslint esversion: 6*/
/*global require,exports*/

"use strict";


var text = {
    getParagraph: function* (sText, sSepParagraph = "\n") {
        // generator: returns paragraphs of text
................................................................................
            console.error(e);
            return "\n# Error. Data: " + oErr.toString();
        }
    }
};


if (typeof(exports) !== 'undefined') {
    exports.getParagraph = text.getParagraph;
    exports.wrap = text.wrap;
    exports.getReadableError = text.getReadableError;
}

>
>
|
|







 







|




1
2
3
4
5
6
7
8
9
10
11
12
..
57
58
59
60
61
62
63
64
65
66
67
68
// JavaScript

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global require, exports, console */

"use strict";


var text = {
    getParagraph: function* (sText, sSepParagraph = "\n") {
        // generator: returns paragraphs of text
................................................................................
            console.error(e);
            return "\n# Error. Data: " + oErr.toString();
        }
    }
};


if (typeof exports !== 'undefined') {
    exports.getParagraph = text.getParagraph;
    exports.wrap = text.wrap;
    exports.getReadableError = text.getReadableError;
}

Changes to gc_lang/fr/modules-js/conj.js.

1
2


3
4

5
6
7
8
9
10
11


12
13
14
15
16
17
18
19
...
492
493
494
495
496
497
498



499
500
501
502
503
504
505
506
507
508

509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
// Grammalecte - Conjugueur
// License: GPL 3


/*jslint esversion: 6*/
/*global console,require,exports,self,browser*/


"use strict";

${map}


if (typeof(require) !== 'undefined') {


    var helpers = require("resource://grammalecte/graphspell/helpers.js");
}

var conj = {
    _lVtyp: [],
    _lTags: [],
    _dPatternConj: {},
    _dVerb: {},
................................................................................
        }
        return (this.dConj.get(":Q").get(":Q4")) ? this.dConj.get(":Q").get(":Q4") : this.dConj.get(":Q").get(":Q1");
    }
}


// Initialization



if (!conj.bInit && typeof(browser) !== 'undefined') {
    // WebExtension Standard (but not in Worker)
    conj.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/conj_data.json")));
} else if (!conj.bInit && typeof(chrome) !== 'undefined') {
    // WebExtension Chrome (but not in Worker)
    conj.init(helpers.loadFile(chrome.extension.getURL("grammalecte/fr/conj_data.json")));
} else if (!conj.bInit && typeof(require) !== 'undefined') {
    // Add-on SDK and Thunderbird
    conj.init(helpers.loadFile("resource://grammalecte/fr/conj_data.json"));
} else if (!conj.bInit && typeof(self) !== 'undefined' && typeof(self.port) !== 'undefined' && typeof(self.port.on) !== "undefined") {

    // used within Firefox content script (conjugation panel).
    // can’t load JSON from here, so we do it in ui.js and send it here.
    self.port.on("provideConjData", function (sJSONData) {
        conj.init(sJSONData);
    });    
} else if (conj.bInit){
    console.log("Module conj déjà initialisé");
} else {
    //console.log("Module conj non initialisé");
}


if (typeof(exports) !== 'undefined') {
    exports._lVtyp = conj._lVtyp;
    exports._lTags = conj._lTags;
    exports._dPatternConj = conj._dPatternConj;
    exports._dVerb = conj._dVerb;
    exports.init = conj.init;
    exports._zStartVoy = conj._zStartVoy;
    exports._zNeedTeuph = conj._zNeedTeuph;


>
>
|
<
>



|


|
>
>
|







 







>
>
>
|

|
|

|
|

|
<
>


|

|

|





|







1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514

515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
// Grammalecte - Conjugueur
// License: GPL 3

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */

/*global require, exports, console, self, browser, chrome, __dirname */

"use strict";

//${map}


if(typeof process !== 'undefined') {
    var helpers = require('../graphspell/helpers.js');
} else if (typeof require !== 'undefined') {
    var helpers = require('resource://grammalecte/graphspell/helpers.js');
}

var conj = {
    _lVtyp: [],
    _lTags: [],
    _dPatternConj: {},
    _dVerb: {},
................................................................................
        }
        return (this.dConj.get(":Q").get(":Q4")) ? this.dConj.get(":Q").get(":Q4") : this.dConj.get(":Q").get(":Q1");
    }
}


// Initialization
if(!conj.bInit && typeof process !== 'undefined') {
    // Work with nodejs
    conj.init(helpers.loadFile(__dirname+'/conj_data.json'));
} else if (!conj.bInit && typeof(browser) !== 'undefined') {
    // WebExtension Standard (but not in Worker)
    conj.init(helpers.loadFile(browser.extension.getURL('grammalecte/fr/conj_data.json')));
} else if (!conj.bInit && typeof chrome !== 'undefined') {
    // WebExtension Chrome (but not in Worker)
    conj.init(helpers.loadFile(chrome.extension.getURL('grammalecte/fr/conj_data.json')));
} else if (!conj.bInit && typeof require !== 'undefined') {
    // Add-on SDK and Thunderbird
    conj.init(helpers.loadFile('resource://grammalecte/fr/conj_data.json'));

} else if (!conj.bInit && typeof self !== 'undefined' && typeof self.port !== 'undefined' && typeof self.port.on !== 'undefined') {
    // used within Firefox content script (conjugation panel).
    // can’t load JSON from here, so we do it in ui.js and send it here.
    self.port.on('provideConjData', function (sJSONData) {
        conj.init(sJSONData);
    });
} else if (conj.bInit){
    console.log('Module conj déjà initialisé');
} else {
    //console.log("Module conj non initialisé");
}


if (typeof exports !== 'undefined') {
    exports._lVtyp = conj._lVtyp;
    exports._lTags = conj._lTags;
    exports._dPatternConj = conj._dPatternConj;
    exports._dVerb = conj._dVerb;
    exports.init = conj.init;
    exports._zStartVoy = conj._zStartVoy;
    exports._zNeedTeuph = conj._zNeedTeuph;

Changes to gc_lang/fr/modules-js/conj_generator.js.

1
2
3
4
5
6




7
8
9
10
11
12
13
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//  JavaScript

/*
    Conjugation generator
    beta stage, unfinished, the root for a new way to generate flexions…
*/





"use strict";


var conj_generator = {

    conjugate: function (sVerb, sVerbTag="i_____a", bVarPpas=true) {
................................................................................
            [2,     "isses",        ":Sp:Sq:2s/*",      false],
            [2,     "isse",         ":Sp:3s/*",         false],
            [2,     "ît",           ":Sq:3s/*",         false],
            [2,     "is",           ":E:2s/*",          false],
            [2,     "issons",       ":E:1p/*",          false],
            [2,     "issez",        ":E:2p/*",          false]
        ],
        
        // premier groupe (bien plus irrégulier que prétendu)
        "V1": {
            // a
            // verbes en -er, -ger, -yer, -cer
            "er": [
                [2,      "er",        ":Y/*",               false],
                [2,      "ant",       ":P/*",               false],


<
|
|
<
>
>
>
>







 







|







1
2

3
4

5
6
7
8
9
10
11
12
13
14
15
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//  JavaScript


//    Conjugation generator
//    beta stage, unfinished, the root for a new way to generate flexions…



/* jshint esversion:6, -W097 */
/* jslint esversion:6 */

"use strict";


var conj_generator = {

    conjugate: function (sVerb, sVerbTag="i_____a", bVarPpas=true) {
................................................................................
            [2,     "isses",        ":Sp:Sq:2s/*",      false],
            [2,     "isse",         ":Sp:3s/*",         false],
            [2,     "ît",           ":Sq:3s/*",         false],
            [2,     "is",           ":E:2s/*",          false],
            [2,     "issons",       ":E:1p/*",          false],
            [2,     "issez",        ":E:2p/*",          false]
        ],

        // premier groupe (bien plus irrégulier que prétendu)
        "V1": {
            // a
            // verbes en -er, -ger, -yer, -cer
            "er": [
                [2,      "er",        ":Y/*",               false],
                [2,      "ant",       ":P/*",               false],

Changes to gc_lang/fr/modules-js/cregex.js.

1


2
3
4
5
6
7
8
9
...
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
//// Grammalecte - Compiled regular expressions


/*jslint esversion: 6*/


var cregex = {
    ///// Lemme
    _zLemma: new RegExp(">([a-zà-öø-ÿ0-9Ā-ʯ][a-zà-öø-ÿ0-9Ā-ʯ-]+)"),

    ///// Masculin / féminin / singulier / pluriel
................................................................................
            return false;
        }
        return lMorph.some(s  =>  this._zNPm.test(s));
    }
};


if (typeof(exports) !== 'undefined') {
    exports._zLemma = cregex._zLemma;
    exports._zGender = cregex._zGender;
    exports._zNumber = cregex._zNumber;
    exports._zNA = cregex._zNA;
    exports._zNAs = cregex._zNAs;
    exports._zNAp = cregex._zNAp;
    exports._zNAi = cregex._zNAi;
|
>
>
|







 







|







1
2
3
4
5
6
7
8
9
10
11
...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
// Grammalecte - Compiled regular expressions

/* jshint esversion:6 */
/* jslint esversion:6 */


var cregex = {
    ///// Lemme
    _zLemma: new RegExp(">([a-zà-öø-ÿ0-9Ā-ʯ][a-zà-öø-ÿ0-9Ā-ʯ-]+)"),

    ///// Masculin / féminin / singulier / pluriel
................................................................................
            return false;
        }
        return lMorph.some(s  =>  this._zNPm.test(s));
    }
};


if (typeof exports !== 'undefined') {
    exports._zLemma = cregex._zLemma;
    exports._zGender = cregex._zGender;
    exports._zNumber = cregex._zNumber;
    exports._zNA = cregex._zNA;
    exports._zNAs = cregex._zNAs;
    exports._zNAp = cregex._zNAp;
    exports._zNAi = cregex._zNAi;

Changes to gc_lang/fr/modules-js/gce_analyseur.js.

1


2
3
4
5
6
7
8
9
...
126
127
128
129
130
131
132
133
134
135
136
137
138
//// GRAMMAR CHECKING ENGINE PLUGIN: Parsing functions for French language


/*jslint esversion: 6*/

function g_morphVC (dToken, sPattern, sNegPattern="") {
    let nEnd = dToken["sValue"].lastIndexOf("-");
    if (dToken["sValue"].includes("-t-")) {
        nEnd = nEnd - 2;
    }
    return g_morph(dToken, sPattern, sNegPattern, 0, nEnd, false);
................................................................................
    if (s.length > 1 && s.length < 16 && s.slice(0, 1).gl_isLowerCase() && (!s.slice(1).gl_isLowerCase() || /[0-9]/.test(s))) {
        return true;
    }
    return false;
}


//// Exceptions

const aREGULARPLURAL = new Set(["abricot", "amarante", "aubergine", "acajou", "anthracite", "brique", "caca", "café",
                                "carotte", "cerise", "chataigne", "corail", "citron", "crème", "grave", "groseille",
                                "jonquille", "marron", "olive", "pervenche", "prune", "sable"]);
const aSHOULDBEVERB = new Set(["aller", "manger"]);
|
>
>
|







 







|





1
2
3
4
5
6
7
8
9
10
11
...
128
129
130
131
132
133
134
135
136
137
138
139
140
// GRAMMAR CHECKING ENGINE PLUGIN: Parsing functions for French language

/* jshint esversion:6 */
/* jslint esversion:6 */

function g_morphVC (dToken, sPattern, sNegPattern="") {
    let nEnd = dToken["sValue"].lastIndexOf("-");
    if (dToken["sValue"].includes("-t-")) {
        nEnd = nEnd - 2;
    }
    return g_morph(dToken, sPattern, sNegPattern, 0, nEnd, false);
................................................................................
    if (s.length > 1 && s.length < 16 && s.slice(0, 1).gl_isLowerCase() && (!s.slice(1).gl_isLowerCase() || /[0-9]/.test(s))) {
        return true;
    }
    return false;
}


// Exceptions

const aREGULARPLURAL = new Set(["abricot", "amarante", "aubergine", "acajou", "anthracite", "brique", "caca", "café",
                                "carotte", "cerise", "chataigne", "corail", "citron", "crème", "grave", "groseille",
                                "jonquille", "marron", "olive", "pervenche", "prune", "sable"]);
const aSHOULDBEVERB = new Set(["aller", "manger"]);

Changes to gc_lang/fr/modules-js/gce_date_verif.js.

1
2
3
4

5
6

7
8
9
10
11
12
13
//// GRAMMAR CHECKING ENGINE PLUGIN
/*jslint esversion: 6*/

// Check date validity


// WARNING: when creating a Date, month must be between 0 and 11



const _lDay = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"];
const _dMonth = new Map ([
    ["janvier", 1], ["février", 2], ["mars", 3], ["avril", 4], ["mai", 5], ["juin", 6], ["juillet", 7],
    ["août", 8], ["aout", 8], ["septembre", 9], ["octobre", 10], ["novembre", 11], ["décembre", 12]
]);
|
<


>

|
>







1

2
3
4
5
6
7
8
9
10
11
12
13
14
// GRAMMAR CHECKING ENGINE PLUGIN


// Check date validity
// WARNING: when creating a Date, month must be between 0 and 11

/* jshint esversion:6 */
/* jslint esversion:6 */


const _lDay = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"];
const _dMonth = new Map ([
    ["janvier", 1], ["février", 2], ["mars", 3], ["avril", 4], ["mai", 5], ["juin", 6], ["juillet", 7],
    ["août", 8], ["aout", 8], ["septembre", 9], ["octobre", 10], ["novembre", 11], ["décembre", 12]
]);

Changes to gc_lang/fr/modules-js/gce_suggestions.js.

1


2
3
4
5




6
7
8
9
10
11
12
13
14
15
//// GRAMMAR CHECKING ENGINE PLUGIN: Suggestion mechanisms


/*jslint esversion: 6*/
/*global require*/

if (typeof(require) !== 'undefined') {




    var conj = require("resource://grammalecte/fr/conj.js");
    var mfsp = require("resource://grammalecte/fr/mfsp.js");
    var phonet = require("resource://grammalecte/fr/phonet.js");
}


//// verbs

function splitVerb (sVerb) {
    // renvoie le verbe et les pronoms séparément
|
>
>
|
|

|
>
>
>
>
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// GRAMMAR CHECKING ENGINE PLUGIN: Suggestion mechanisms

/* jshint esversion:6 */
/* jslint esversion:6 */
/* global require */

if(typeof process !== 'undefined') {
    var conj = require('./conj.js');
    var mfsp = require('./mfsp.js');
    var phonet = require('./phonet.js');
} else if (typeof require !== 'undefined') {
    var conj = require('resource://grammalecte/fr/conj.js');
    var mfsp = require('resource://grammalecte/fr/mfsp.js');
    var phonet = require('resource://grammalecte/fr/phonet.js');
}


//// verbs

function splitVerb (sVerb) {
    // renvoie le verbe et les pronoms séparément

Changes to gc_lang/fr/modules-js/lexicographe.js.

1
2


3
4
5
6
7
8
9
10
11
// Grammalecte - Lexicographe
// License: MPL 2


/*jslint esversion: 6*/
/*global require,exports*/

"use strict";

${string}
${map}




>
>
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
// Grammalecte - Lexicographe
// License: MPL 2

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global require, exports, console */

"use strict";

${string}
${map}


Changes to gc_lang/fr/modules-js/mfsp.js.

1


2
3

4
5
6
7
8


9
10
11
12
13
14
15
16
...
100
101
102
103
104
105
106



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Grammalecte


/*jslint esversion: 6*/
/*global console,require,exports,browser*/


"use strict";


if (typeof(require) !== 'undefined') {


    var helpers = require("resource://grammalecte/graphspell/helpers.js");
}


var mfsp = {
    // list of affix codes
    _lTagMiscPlur: [],
    _lTagMasForm: [],
................................................................................
            return "## erreur, code : " + sSfx + " ##";
        }
    }
};


// Initialization



if (!mfsp.bInit && typeof(browser) !== 'undefined') {
    // WebExtension
    mfsp.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/mfsp_data.json")));
} else if (!mfsp.bInit && typeof(require) !== 'undefined') {
    // Add-on SDK and Thunderbird
    mfsp.init(helpers.loadFile("resource://grammalecte/fr/mfsp_data.json"));
} else if (mfsp.bInit){
    console.log("Module mfsp déjà initialisé");
} else {
    //console.log("Module mfsp non initialisé");
}


if (typeof(exports) !== 'undefined') {
    exports._lTagMiscPlur = mfsp._lTagMiscPlur;
    exports._lTagMasForm = mfsp._lTagMasForm;
    exports._dMiscPlur = mfsp._dMiscPlur;
    exports._dMasForm = mfsp._dMasForm;
    exports.init = mfsp.init;
    exports.isFemForm = mfsp.isFemForm;
    exports.getMasForm = mfsp.getMasForm;
    exports.hasMiscPlural = mfsp.hasMiscPlural;
    exports.getMiscPlural = mfsp.getMiscPlural;
    exports._whatSuffixCode = mfsp._whatSuffixCode;
    exports._modifyStringWithSuffixCode = mfsp._modifyStringWithSuffixCode;
}

>
>
|
<
>




|
>
>
|







 







>
>
>
|

|


|

|

|



|












1
2
3
4

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Grammalecte

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */

/* global require, exports, console, browser,__dirname */

"use strict";


if(typeof process !== 'undefined') {
    var helpers = require('../graphspell/helpers.js');
} else if (typeof require !== 'undefined') {
    var helpers = require('resource://grammalecte/graphspell/helpers.js');
}


var mfsp = {
    // list of affix codes
    _lTagMiscPlur: [],
    _lTagMasForm: [],
................................................................................
            return "## erreur, code : " + sSfx + " ##";
        }
    }
};


// Initialization
if(!mfsp.bInit && typeof process !== 'undefined') {
    //Nodejs
    mfsp.init(helpers.loadFile(__dirname+'/mfsp_data.json'));
} else if (!mfsp.bInit && typeof(browser) !== 'undefined') {
    // WebExtension
    mfsp.init(helpers.loadFile(browser.extension.getURL('grammalecte/fr/mfsp_data.json')));
} else if (!mfsp.bInit && typeof(require) !== 'undefined') {
    // Add-on SDK and Thunderbird
    mfsp.init(helpers.loadFile('resource://grammalecte/fr/mfsp_data.json'));
} else if (mfsp.bInit){
    console.log('Module mfsp déjà initialisé');
} else {
    //console.log('Module mfsp non initialisé');
}


if (typeof exports !== 'undefined') {
    exports._lTagMiscPlur = mfsp._lTagMiscPlur;
    exports._lTagMasForm = mfsp._lTagMasForm;
    exports._dMiscPlur = mfsp._dMiscPlur;
    exports._dMasForm = mfsp._dMasForm;
    exports.init = mfsp.init;
    exports.isFemForm = mfsp.isFemForm;
    exports.getMasForm = mfsp.getMasForm;
    exports.hasMiscPlural = mfsp.hasMiscPlural;
    exports.getMiscPlural = mfsp.getMiscPlural;
    exports._whatSuffixCode = mfsp._whatSuffixCode;
    exports._modifyStringWithSuffixCode = mfsp._modifyStringWithSuffixCode;
}

Changes to gc_lang/fr/modules-js/phonet.js.

1


2

3
4


5
6
7
8
9
10
11
..
80
81
82
83
84
85
86
87



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Grammalecte - Suggestion phonétique


/*jslint esversion: 6*/


if (typeof(require) !== 'undefined') {


    var helpers = require("resource://grammalecte/graphspell/helpers.js");
}


var phonet = {
    _dWord: new Map(),
    _lSet: [],
................................................................................
        }
        return aSelect;
    }
};


// Initialization
if (!phonet.bInit && typeof(browser) !== 'undefined') {



    // WebExtension
    phonet.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/phonet_data.json")));
} else if (!phonet.bInit && typeof(require) !== 'undefined') {
    // Add-on SDK and Thunderbird
    phonet.init(helpers.loadFile("resource://grammalecte/fr/phonet_data.json"));
} else if (phonet.bInit){
    console.log("Module phonet déjà initialisé");
} else {
    //console.log("Module phonet non initialisé");
}


if (typeof(exports) !== 'undefined') {
    exports._dWord = phonet._dWord;
    exports._lSet = phonet._lSet;
    exports._dMorph = phonet._dMorph;
    exports.init = phonet.init;
    exports.hasSimil = phonet.hasSimil;
    exports.getSimil = phonet.getSimil;
    exports.selectSimil = phonet.selectSimil;
}

>
>
|
>

|
>
>







 







|
>
>
>

|
|

|

|

|



|








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Grammalecte - Suggestion phonétique

/* jshint esversion:6 */
/* jslint esversion:6 */
/* global __dirname */

if(typeof process !== 'undefined') {
    var helpers = require("../graphspell/helpers.js");
} else if (typeof require  !== 'undefined') {
    var helpers = require("resource://grammalecte/graphspell/helpers.js");
}


var phonet = {
    _dWord: new Map(),
    _lSet: [],
................................................................................
        }
        return aSelect;
    }
};


// Initialization
if (!phonet.bInit && typeof process !== 'undefined') {
    //Nodejs
    phonet.init(helpers.loadFile(__dirname+'/phonet_data.json'));
} else if (!phonet.bInit && typeof browser !== 'undefined') {
    // WebExtension
    phonet.init(helpers.loadFile(browser.extension.getURL('grammalecte/fr/phonet_data.json')));
} else if (!phonet.bInit && typeof require !== 'undefined') {
    // Add-on SDK and Thunderbird
    phonet.init(helpers.loadFile('resource://grammalecte/fr/phonet_data.json'));
} else if (phonet.bInit){
    console.log('Module phonet déjà initialisé');
} else {
    //console.log('Module phonet non initialisé');
}


if (typeof exports !== 'undefined') {
    exports._dWord = phonet._dWord;
    exports._lSet = phonet._lSet;
    exports._dMorph = phonet._dMorph;
    exports.init = phonet.init;
    exports.hasSimil = phonet.hasSimil;
    exports.getSimil = phonet.getSimil;
    exports.selectSimil = phonet.selectSimil;
}

Changes to gc_lang/fr/modules-js/textformatter.js.

1


2
3
4
5
6
7
8
9
10
..
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
283
284
285
286
287
288
289
290
291
292
293
// Grammalecte - text formatter


/*jslint esversion: 6*/
/*global exports*/

"use strict";

${map}


// Latin letters: http://unicode-table.com/fr/
................................................................................
    "erase_non_breaking_hyphens": [ [/­/g, ""] ],
    //// typographic signs
    "ts_apostrophe":              [ [/\b([ldnjmtscç])['´‘′`](?=[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ])/ig, "$1’"],
                                    [/\b(qu|jusqu|lorsqu|puisqu|quoiqu|quelqu|presqu|entr|aujourd|prud)['´‘′`]/ig, "$1’"] ],
    "ts_ellipsis":                [ [/\.\.\./g, "…"],
                                    [/…\.\./g, "……"],
                                    [/…\.(?!\.)/g, "…"] ],
    "ts_n_dash_middle":           [ [/ [-—] /g, " – "], 
                                    [/ [-—],/g, " –,"] ],
    "ts_m_dash_middle":           [ [/ [-–] /g, " — "],
                                    [/ [-–],/g, " —,"] ],
    "ts_n_dash_start":            [ [/^[-—][  ]/gm, "– "],
                                    [/^– /gm, "– "],
                                    [/^[-–—](?=[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ.…])/gm, "– "] ],
    "ts_m_dash_start":            [ [/^[-–][  ]/gm, "— "],
................................................................................

    getDefaultOptions () {
        return dTFDefaultOptions;
    }
}


if (typeof(exports) !== 'undefined') {
    exports.TextFormatter = TextFormatter;
    exports.oReplTable = oReplTable;
}

>
>
|
|







 







|







 







|



1
2
3
4
5
6
7
8
9
10
11
12
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
285
286
287
288
289
290
291
292
293
294
295
// Grammalecte - text formatter

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global exports */

"use strict";

${map}


// Latin letters: http://unicode-table.com/fr/
................................................................................
    "erase_non_breaking_hyphens": [ [/­/g, ""] ],
    //// typographic signs
    "ts_apostrophe":              [ [/\b([ldnjmtscç])['´‘′`](?=[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ])/ig, "$1’"],
                                    [/\b(qu|jusqu|lorsqu|puisqu|quoiqu|quelqu|presqu|entr|aujourd|prud)['´‘′`]/ig, "$1’"] ],
    "ts_ellipsis":                [ [/\.\.\./g, "…"],
                                    [/…\.\./g, "……"],
                                    [/…\.(?!\.)/g, "…"] ],
    "ts_n_dash_middle":           [ [/ [-—] /g, " – "],
                                    [/ [-—],/g, " –,"] ],
    "ts_m_dash_middle":           [ [/ [-–] /g, " — "],
                                    [/ [-–],/g, " —,"] ],
    "ts_n_dash_start":            [ [/^[-—][  ]/gm, "– "],
                                    [/^– /gm, "– "],
                                    [/^[-–—](?=[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ.…])/gm, "– "] ],
    "ts_m_dash_start":            [ [/^[-–][  ]/gm, "— "],
................................................................................

    getDefaultOptions () {
        return dTFDefaultOptions;
    }
}


if (typeof exports !== 'undefined') {
    exports.TextFormatter = TextFormatter;
    exports.oReplTable = oReplTable;
}

Changes to graphspell-js/ibdawg.js.

1
2
3
4
5
6
7
8
9
10
11
12
..
97
98
99
100
101
102
103




104

105
106
107
108
109
110
111
// IBDAWG

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global require, exports, console*/

"use strict";

if(typeof process !== 'undefined') {
    var str_transform = require('./str_transform.js');
    var helpers = require('./helpers.js');
    var char_player = require('./char_player.js');
................................................................................
    // INDEXABLE BINARY DIRECT ACYCLIC WORD GRAPH

    constructor (param1, sPath="") {
        // param1 can be a filename or a object with all the necessary data.
        try {
            let oData = null;
            if (typeof(param1) == "string") {




                let sURL = (sPath !== "") ? sPath + "/" + param1 : "resource://grammalecte/graphspell/_dictionaries/"+param1;

                oData = JSON.parse(helpers.loadFile(sURL));
            } else {
                oData = param1;
            }
            Object.assign(this, oData);
        }
        catch (e) {




|







 







>
>
>
>
|
>







1
2
3
4
5
6
7
8
9
10
11
12
..
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// IBDAWG

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global require, exports, console, __dirname */

"use strict";

if(typeof process !== 'undefined') {
    var str_transform = require('./str_transform.js');
    var helpers = require('./helpers.js');
    var char_player = require('./char_player.js');
................................................................................
    // INDEXABLE BINARY DIRECT ACYCLIC WORD GRAPH

    constructor (param1, sPath="") {
        // param1 can be a filename or a object with all the necessary data.
        try {
            let oData = null;
            if (typeof(param1) == "string") {
                let sURL;
                if(typeof process !== 'undefined') {
                    sURL = (sPath !== "") ? sPath + "/" + param1 : __dirname + "/_dictionaries/"+param1;
                } else {
                    sURL = (sPath !== "") ? sPath + "/" + param1 : "resource://grammalecte/graphspell/_dictionaries/"+param1;
                }
                oData = JSON.parse(helpers.loadFile(sURL));
            } else {
                oData = param1;
            }
            Object.assign(this, oData);
        }
        catch (e) {