Changes In Branch nodejs
Through [401f29a39d]
Excluding Merge-Ins
This is equivalent to a diff from
4d2953e2f6
to 401f29a39d
2018-10-17
| | |
16:07 |
|
check-in: 23d95509f4 user: olr tags: njs, nodejs
|
14:21 |
|
check-in: 401f29a39d user: olr tags: fr, build, nodejs
|
14:04 |
|
check-in: 6963981657 user: olr tags: core, njs, nodejs
|
2018-10-10
| | |
09:19 |
|
check-in: a3687f4fd3 user: IllusionPerdu tags: graphspell, njs, nodejs
|
09:03 |
|
check-in: bdcc97b45b user: olr tags: trunk, fr
|
2018-10-09
| | |
11:07 |
|
check-in: 4d2953e2f6 user: olr tags: trunk, graphspell
|
08:54 |
|
check-in: 14ed269c7c user: olr tags: trunk, graphspell
|
| | |
Modified compile_rules.py
from [6c0309c95b]
to [3c1cc360a0].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
+
+
|
"""
Grammalecte: compile rules
"""
import re
import os
import traceback
import json
import colorsys
import time
import compile_rules_js_convert as jsconv
import compile_rules_graph as crg
dDEF = {}
lFUNCTIONS = []
|
︙ | | |
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
-
+
|
dColor = {}
dOptLabel = {}
dOptPriority = {}
for sLine in lOptionLines:
sLine = sLine.strip()
if sLine.startswith("OPTGROUP/"):
m = re.match("OPTGROUP/([a-z0-9]+):(.+)$", sLine)
lStructOpt.append( (m.group(1), list(map(str.split, m.group(2).split(",")))) )
lStructOpt.append( [m.group(1), list(map(str.split, m.group(2).split(",")))] )
elif sLine.startswith("OPTSOFTWARE:"):
lOpt = [ [s, {}] for s in sLine[12:].strip().split() ] # don’t use tuples (s, {}), because unknown to JS
elif sLine.startswith("OPT/"):
m = re.match("OPT/([a-z0-9]+):(.+)$", sLine)
for i, sOpt in enumerate(m.group(2).split()):
lOpt[i][1][m.group(1)] = eval(sOpt)
elif sLine.startswith("OPTCOLORTHEME:"):
|
︙ | | |
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
|
-
+
+
+
+
+
+
+
+
+
+
|
def printBookmark (nLevel, sComment, nLine):
"print bookmark within the rules file"
print(" {:>6}: {}".format(nLine, " " * nLevel + sComment))
def make (spLang, sLang, bJavaScript):
def make (spLang, sLang, bUseCache=False):
"compile rules, returns a dictionary of values"
# for clarity purpose, don’t create any file here
if bUseCache and os.path.isfile("_build/data_cache.json"):
print("> don’t rebuild rules, use cache...")
sJSON = open("_build/data_cache.json", "r", encoding="utf-8").read()
dCacheVars = json.loads(sJSON)
print(" build made at: " + time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(dCacheVars.get("fBuildTime", 0))))
return dCacheVars
fBuildTime = time.time()
print("> read rules file...")
try:
lRules = open(spLang + "/rules.grx", 'r', encoding="utf-8").readlines()
except:
print("Error. Rules file in project [" + sLang + "] not found.")
exit()
|
︙ | | |
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
|
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
+
+
|
sJSCallables += " return " + jsconv.py2js(sReturn) + ";\n"
sJSCallables += " },\n"
displayStats(lParagraphRules, lSentenceRules)
print("Unnamed rules: " + str(nRULEWITHOUTNAME))
dVars = {
"fBuildTime": fBuildTime,
dVars = { "callables": sPyCallables,
"callablesJS": sJSCallables,
"gctests": sGCTests,
"gctestsJS": sGCTestsJS,
"paragraph_rules": mergeRulesByOption(lParagraphRules),
"sentence_rules": mergeRulesByOption(lSentenceRules),
"paragraph_rules_JS": jsconv.writeRulesToJSArray(mergeRulesByOption(lParagraphRulesJS)),
"sentence_rules_JS": jsconv.writeRulesToJSArray(mergeRulesByOption(lSentenceRulesJS)) }
"callables": sPyCallables,
"callablesJS": sJSCallables,
"gctests": sGCTests,
"gctestsJS": sGCTestsJS,
"paragraph_rules": mergeRulesByOption(lParagraphRules),
"sentence_rules": mergeRulesByOption(lSentenceRules),
"paragraph_rules_JS": jsconv.writeRulesToJSArray(mergeRulesByOption(lParagraphRulesJS)),
"sentence_rules_JS": jsconv.writeRulesToJSArray(mergeRulesByOption(lSentenceRulesJS))
}
dVars.update(dOptions)
# compile graph rules
dVars2 = crg.make(lGraphRule, dDEF, sLang, dOptPriority, bJavaScript)
dVars2 = crg.make(lGraphRule, dDEF, sLang, dOptPriority)
dVars.update(dVars2)
with open("_build/data_cache.json", "w", encoding="utf-8") as hDst:
hDst.write(json.dumps(dVars, ensure_ascii=False))
return dVars
|
Modified compile_rules_graph.py
from [f9b11563d7]
to [f9c246b8ef].
︙ | | |
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
-
+
|
sAction = createFunction("da", sActionId, sAction)
return [sOption, sCondition, cAction, sAction]
else:
print(" # Unknown action.", sActionId)
return None
def make (lRule, dDef, sLang, dOptPriority, bJavaScript):
def make (lRule, dDef, sLang, dOptPriority):
"compile rules, returns a dictionary of values"
# for clarity purpose, don’t create any file here
# removing comments, zeroing empty lines, creating definitions, storing tests, merging rule lines
print(" parsing rules...")
lTokenLine = []
sActions = ""
|
︙ | | |
450
451
452
453
454
455
456
457
458
459
460
461
|
450
451
452
453
454
455
456
457
458
459
460
461
|
-
+
-
+
|
print("\nFunctions:")
print(sPyCallables)
# Result
return {
"graph_callables": sPyCallables,
"graph_callablesJS": sJSCallables,
"rules_graphs": dAllGraph,
"rules_graphs": str(dAllGraph),
"rules_graphsJS": str(dAllGraph).replace("True", "true").replace("False", "false"),
"rules_actions": dACTIONS,
"rules_actions": str(dACTIONS),
"rules_actionsJS": str(dACTIONS).replace("True", "true").replace("False", "false")
}
|
Modified gc_core/js/lang_core/gc_engine.js
from [e6dde271f2]
to [5c503d2a3c].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
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
|
+
+
-
-
+
+
+
+
+
+
+
+
-
+
|
// Grammar checker engine
/* jshint esversion:6, -W097 */
/*jslint esversion: 6*/
/*global console,require,exports*/
/* 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");
if (typeof(require) !== 'undefined') {
} 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");
}
|
︙ | | |
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
+
+
+
-
+
|
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}");
if (typeof(require) !== 'undefined') {
} 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
|
︙ | | |
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
-
+
|
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"
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();
}
|
︙ | | |
Modified gc_core/js/lang_core/gc_options.js
from [aa3f5d62cd]
to [ece26d7264].
1
2
3
4
5
6
7
8
9
10
|
1
2
3
4
5
6
7
8
9
10
11
12
|
+
+
-
-
+
+
|
// Options for Grammalecte
/* jshint esversion:6 */
/*jslint esversion: 6*/
/*global exports*/
/* jslint esversion:6 */
/* global exports */
${map}
var gc_options = {
getOptions: function (sContext="JavaScript") {
if (this.dOpt.hasOwnProperty(sContext)) {
|
︙ | | |
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
54
55
56
|
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
54
55
56
57
58
|
-
+
-
+
-
+
-
+
-
+
|
for (let [sOpt, sColor] of Object.entries(dOptColor)) {
dColor[sOpt] = dColorType[sColor];
}
return dColor;
}
catch (e) {
console.error(e);
return {}
return {};
}
},
lStructOpt: ${lStructOpt},
dOpt: {
"JavaScript": new Map (${dOptJavaScript}),
"Firefox": new Map (${dOptFirefox}),
"Thunderbird": new Map (${dOptThunderbird}),
},
dColorType: ${dColorType},
dOptColor: ${dOptColor},
dOptLabel: ${dOptLabel}
}
};
if (typeof(exports) !== 'undefined') {
exports.getOptions = gc_options.getOptions;
exports.getOptions = gc_options.getOptions;
exports.getOptionsColors = gc_options.getOptionsColors;
exports.lStructOpt = gc_options.lStructOpt;
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;
exports.dOptLabel = gc_options.dOptLabel;
}
|
Modified gc_core/js/lang_core/gc_rules.js
from [cdb121423e]
to [4a0b977685].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
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*/
/* 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;
}
|
Modified gc_core/js/lang_core/gc_rules_graph.js
from [7405261f29]
to [3efb8afd5c].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
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*/
/* 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;
}
|
Modified gc_core/js/tests.js
from [1eda44faf6]
to [147f1c4e7b].
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
|
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
|
+
+
-
-
+
+
+
+
-
+
+
+
+
+
-
+
+
|
// JavaScript
/* jshint esversion:6, -W097 */
/*jslint esversion: 6*/
/*global console,require,exports*/
/* jslint esversion:6 */
/* global require, exports, console */
"use strict";
if(typeof(process) !== 'undefined') {
var helpers = require("./graphspell/helpers.js");
if (typeof(require) !== 'undefined') {
} 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 {
let sURL = (this.spfTests !== "") ? this.spfTests : "resource://grammalecte/"+this.gce.lang+"/tests_data.json";
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;
|
︙ | | |
Modified gc_core/js/text.js
from [c9e7670db8]
to [1251d5448b].
1
2
3
4
5
6
7
8
9
10
|
1
2
3
4
5
6
7
8
9
10
11
12
|
+
+
-
-
+
+
|
// JavaScript
/* jshint esversion:6, -W097 */
/*jslint esversion: 6*/
/*global require,exports*/
/* jslint esversion:6 */
/* global require, exports, console */
"use strict";
var text = {
getParagraph: function* (sText, sSepParagraph = "\n") {
// generator: returns paragraphs of text
|
︙ | | |
Modified gc_lang/fr/build.py
from [c2d27a1c07]
to [d49776adfe].
︙ | | |
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
+
|
import helpers
def build (sLang, dVars, spLangPack):
"complementary build launched from make.py"
createWebExtension(sLang, dVars)
createThunderbirdExtension(sLang, dVars, spLangPack)
createNodeJSPackage(sLang)
def createWebExtension (sLang, dVars):
"create Web-extension"
print("Building WebExtension")
helpers.createCleanFolder("_build/webext/"+sLang)
dir_util.copy_tree("gc_lang/"+sLang+"/webext/", "_build/webext/"+sLang)
|
︙ | | |
83
84
85
86
87
88
89
|
84
85
86
87
88
89
90
91
92
93
94
95
96
|
+
+
+
+
+
+
|
hZip.write("grammalecte-js/graphspell/"+sf, sAddPath+"grammalecte-js/graphspell/"+sf)
for sf in os.listdir("grammalecte-js/graphspell/_dictionaries"):
if not os.path.isdir("grammalecte-js/graphspell/_dictionaries/"+sf):
hZip.write("grammalecte-js/graphspell/_dictionaries/"+sf, sAddPath+"grammalecte-js/graphspell/_dictionaries/"+sf)
for sf in os.listdir(spLangPack):
if not os.path.isdir(spLangPack+"/"+sf):
hZip.write(spLangPack+"/"+sf, sAddPath+spLangPack+"/"+sf)
def createNodeJSPackage (sLang):
helpers.createCleanFolder("_build/nodejs/"+sLang)
dir_util.copy_tree("gc_lang/"+sLang+"/nodejs/", "_build/nodejs/"+sLang)
dir_util.copy_tree("grammalecte-js", "_build/nodejs/"+sLang+"/core/grammalecte")
|
Modified gc_lang/fr/modules-js/conj.js
from [8124143953]
to [98b99c75fa].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
+
+
-
-
+
+
+
+
-
+
|
// Grammalecte - Conjugueur
// License: GPL 3
/* jshint esversion:6, -W097 */
/*jslint esversion: 6*/
/*global console,require,exports,self,browser*/
/* jslint esversion:6 */
/* global require, exports, console, self, browser, chrome, __dirname */
"use strict";
${map}
if(typeof(process) !== 'undefined') {
var helpers = require("../graphspell/helpers.js");
if (typeof(require) !== 'undefined') {
} else if (typeof(require) !== 'undefined') {
var helpers = require("resource://grammalecte/graphspell/helpers.js");
}
var conj = {
_lVtyp: [],
_lTags: [],
_dPatternConj: {},
|
︙ | | |
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
|
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
|
+
+
+
-
+
-
+
-
+
|
}
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"));
if (!conj.bInit && typeof(browser) !== 'undefined') {
} 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") {
} 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é");
}
|
︙ | | |
Modified gc_lang/fr/modules-js/conj_generator.js
from [058e3de2f7]
to [5e8295b732].
1
2
3
4
5
6
7
8
9
10
11
12
13
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
-
-
-
-
+
+
+
+
+
+
|
// JavaScript
/*
Conjugation generator
beta stage, unfinished, the root for a new way to generate flexions…
*/
// 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) {
|
︙ | | |
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
-
+
|
[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],
|
︙ | | |
Modified gc_lang/fr/modules-js/cregex.js
from [97d67d03aa]
to [53af2cbc4f].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
10
11
|
-
-
+
+
+
+
|
//// Grammalecte - Compiled regular expressions
/*jslint esversion: 6*/
// 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
|
︙ | | |
Modified gc_lang/fr/modules-js/gce_analyseur.js
from [427ee71140]
to [09241345b5].
1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
10
11
|
-
-
+
+
+
+
|
//// GRAMMAR CHECKING ENGINE PLUGIN: Parsing functions for French language
/*jslint esversion: 6*/
// 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);
|
︙ | | |
126
127
128
129
130
131
132
133
134
135
136
137
138
|
128
129
130
131
132
133
134
135
136
137
138
139
140
|
-
+
|
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
// 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"]);
|
Modified gc_lang/fr/modules-js/gce_date_verif.js
from [f30dbe242e]
to [8555f52be9].
1
2
3
4
5
6
7
8
9
10
11
12
13
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
-
+
-
+
-
+
+
|
//// GRAMMAR CHECKING ENGINE PLUGIN
// GRAMMAR CHECKING ENGINE PLUGIN
/*jslint esversion: 6*/
// Check date validity
// WARNING: when creating a Date, month must be between 0 and 11
// 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]
]);
|
︙ | | |
Modified gc_lang/fr/modules-js/gce_suggestions.js
from [ae7eaca80b]
to [6c462561b6].
1
2
3
4
5
6
7
8
9
10
11
12
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
-
-
-
+
+
+
+
+
+
+
+
+
-
+
|
//// GRAMMAR CHECKING ENGINE PLUGIN: Suggestion mechanisms
/*jslint esversion: 6*/
/*global require*/
// 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");
if (typeof(require) !== 'undefined') {
} 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
|
︙ | | |
Modified gc_lang/fr/modules-js/lexicographe.js
from [3f0da2f1ff]
to [50f4dc02f6].
1
2
3
4
5
6
7
8
9
10
11
|
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*/
/* jslint esversion:6 */
/* global require, exports, console */
"use strict";
${string}
${map}
|
︙ | | |
Modified gc_lang/fr/modules-js/mfsp.js
from [9d6124ec70]
to [7cfc8c21b3].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
+
+
-
-
+
+
+
+
-
+
|
// Grammalecte
/* jshint esversion:6, -W097 */
/*jslint esversion: 6*/
/*global console,require,exports,browser*/
/* jslint esversion:6 */
/* global require, exports, console, browser,__dirname */
"use strict";
if(typeof(process) !== 'undefined') {
var helpers = require("../graphspell/helpers.js");
if (typeof(require) !== 'undefined') {
} else if (typeof(require) !== 'undefined') {
var helpers = require("resource://grammalecte/graphspell/helpers.js");
}
var mfsp = {
// list of affix codes
_lTagMiscPlur: [],
|
︙ | | |
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
+
+
+
-
+
|
return "## erreur, code : " + sSfx + " ##";
}
}
};
// Initialization
if(!mfsp.bInit && typeof(process) !== 'undefined') {
//Nodejs
mfsp.init(helpers.loadFile(__dirname+"/mfsp_data.json"));
if (!mfsp.bInit && typeof(browser) !== 'undefined') {
} 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é");
|
︙ | | |
Modified gc_lang/fr/modules-js/phonet.js
from [07bba03053]
to [71750ecf21].
1
2
3
4
5
6
7
8
9
10
11
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
+
+
-
+
+
-
+
+
+
|
// Grammalecte - Suggestion phonétique
/* jshint esversion:6 */
/*jslint esversion: 6*/
/* jslint esversion:6 */
/* global __dirname */
if (typeof(require) !== 'undefined') {
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: [],
|
︙ | | |
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
+
+
+
-
+
|
}
return aSelect;
}
};
// Initialization
if (!phonet.bInit && typeof(process) !== 'undefined') {
//Nodejs
phonet.init(helpers.loadFile(__dirname+"/phonet_data.json"));
if (!phonet.bInit && typeof(browser) !== 'undefined') {
} 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é");
|
︙ | | |
Modified gc_lang/fr/modules-js/textformatter.js
from [a9dd9e148e]
to [920d8b7cad].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
+
+
-
-
+
+
-
+
|
// Grammalecte - text formatter
/* jshint esversion:6, -W097 */
/*jslint esversion: 6*/
/*global exports*/
/* jslint esversion:6 */
/* global exports, console */
"use strict";
${map}
//!${map}
// Latin letters: http://unicode-table.com/fr/
// 0-9
// A-Z
// a-z
// À-Ö 00C0-00D6 (upper case)
|
︙ | | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
-
+
|
"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, " – "],
"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, "— "],
|
︙ | | |
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
-
-
-
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
|
["etc", true],
["missing_hyphens", true],
["ma_word", true],
["ma_1letter_lowercase", false],
["ma_1letter_uppercase", false]
]);
const dTFOptions = dTFDefaultOptions.gl_shallowCopy();
class TextFormatter {
constructor () {
constructor (bDebug=false) {
this.sLang = "fr";
this.bDebug = bDebug;
//don't change this in external ;)
this.dOptions = dTFDefaultOptions.gl_shallowCopy();
}
formatText (sText, dOpt=null) {
if (dOpt !== null) {
dTFOptions.gl_updateOnlyExistingKeys(dOpt);
this.dOptions.gl_updateOnlyExistingKeys(dOpt);
}
for (let [sOptName, bVal] of dTFOptions) {
if (bVal && oReplTable.has(sOptName)) {
for (let [sOptName, bVal] of this.dOptions) {
//console.log(oReplTable);
if (bVal && oReplTable[sOptName]) {
for (let [zRgx, sRep] of oReplTable[sOptName]) {
sText = sText.replace(zRgx, sRep);
}
}
}
return sText;
}
formatTextCount (sText, dOpt=null) {
let nCount = 0;
if (dOpt !== null) {
this.dOptions.gl_updateOnlyExistingKeys(dOpt);
}
for (let [sOptName, bVal] of this.dOptions) {
if (bVal && oReplTable[sOptName]) {
for (let [zRgx, sRep] of oReplTable[sOptName]) {
nCount += (sText.match(zRgx) || []).length;
sText = sText.replace(zRgx, sRep);
}
}
}
return [sText, nCount];
}
formatTextRule (sText, sRuleName) {
if (oReplTable[sRuleName]) {
for (let [zRgx, sRep] of oReplTable[sRuleName]) {
sText = sText.replace(zRgx, sRep);
}
} else if (this.bDebug){
console.log("# Error. TF: there is no option “" + sRuleName+ "”.");
}
return sText;
}
formatTextRuleCount (sText, sRuleName) {
let nCount = 0;
if (oReplTable[sRuleName]) {
for (let [zRgx, sRep] of oReplTable[sRuleName]) {
nCount += (sText.match(zRgx) || []).length;
sText = sText.replace(zRgx, sRep);
}
} else if (this.bDebug){
console.log("# Error. TF: there is no option “" + sRuleName+ "”.");
}
return [sText, nCount];
}
removeHyphenAtEndOfParagraphs (sText) {
sText = sText.replace(/-[ ]*\n/gm, "");
return sText;
}
removeHyphenAtEndOfParagraphsCount (sText) {
let nCount = (sText.match(/-[ ]*\n/gm) || []).length;
sText = sText.replace(/-[ ]*\n/gm, "");
return [sText, nCount];
}
mergeContiguousParagraphs (sText) {
sText = sText.replace(/^[ ]+$/gm, ""); // clear empty paragraphs
let s = "";
for (let sParagraph of this.getParagraph(sText)) {
if (sParagraph === "") {
s += "\n";
} else {
s += sParagraph + " ";
}
}
s = s.replace(/ +/gm, " ").replace(/ $/gm, "");
return s;
}
mergeContiguousParagraphsCount (sText) {
let nCount = 0;
sText = sText.replace(/^[ ]+$/gm, ""); // clear empty paragraphs
let s = "";
for (let sParagraph of this.getParagraph(sText)) {
if (sParagraph === "") {
s += "\n";
} else {
s += sParagraph + " ";
nCount += 1;
}
}
s = s.replace(/ +/gm, " ").replace(/ $/gm, "");
return [s, nCount];
}
* getParagraph (sText, sSep="\n") {
// generator: returns paragraphs of text
let iStart = 0;
let iEnd = 0;
while ((iEnd = sText.indexOf(sSep, iStart)) !== -1) {
yield sText.slice(iStart, iEnd);
iStart = iEnd + 1;
}
yield sText.slice(iStart);
}
getDefaultOptions () {
//we return a copy to make sure they are no modification in external
return dTFDefaultOptions;
return dTFDefaultOptions.gl_shallowCopy();
}
getOptions () {
//we return a copy to make sure they are no modification in external
return this.dOptions.gl_shallowCopy();
}
setOptions (dOpt=null) {
if (dOpt !== null) {
this.dOptions.gl_updateOnlyExistingKeys(dOpt);
} else if (this.bDebug){
console.log("# Error. TF: no option to change.");
}
}
}
if (typeof(exports) !== 'undefined') {
exports.TextFormatter = TextFormatter;
exports.oReplTable = oReplTable;
}
|
Added gc_lang/fr/nodejs/cli/bin/gramma-cli.bat version [ab9b945c3f].
|
1
|
+
|
@node gramma-cli.js %*
|
Added gc_lang/fr/nodejs/cli/bin/gramma-cli.js version [cbc4196f53].