Overview
Context
Changes
Modified gc_core/js/lang_core/gc_engine.js
from [c712d65b9e]
to [e250bfaf63].
︙ | | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
+
-
+
-
+
|
// commons regexes
const _zEndOfSentence = new RegExp ('([.?!:;…][ .?!… »”")]*|.$)', "g");
const _zBeginOfParagraph = new RegExp ("^[- –—.,;?!…]*", "ig");
const _zEndOfParagraph = new RegExp ("[- .,;?!…–—]*$", "ig");
// grammar rules and dictionary
//const _rules = require("./gc_rules.js");
let _sContext = ""; // what software is running
const _rules = require("resource://grammalecte/${lang}/gc_rules.js");
let _dOptions = gc_options.dOpt._shallowCopy(); // duplication necessary, to be able to reset to default
let _dOptions = null;
let _aIgnoredRules = new Set();
let _oDict = null;
let _dAnalyses = new Map(); // cache for data from dictionary
let _dAnalyses = new Map(); // cache for data from dictionary
///// Parsing
function parse (sText, sCountry="${country_default}", bDebug=false, bContext=false) {
// analyses the paragraph sText and returns list of errors
let dErrors;
|
︙ | | |
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
-
+
+
+
|
helpers.logerror(e);
}
}
//////// init
function load () {
function load (sContext="JavaScript") {
try {
_oDict = new ibdawg.IBDAWG("${dic_name}.json");
_sContext = sContext;
_dOptions = gc_options.getOptions(sContext)._shallowCopy(); // duplication necessary, to be able to reset to default
}
catch (e) {
helpers.logerror(e);
}
}
function setOption (sOpt, bVal) {
|
︙ | | |
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
-
+
-
+
|
}
function getOptions () {
return _dOptions;
}
function getDefaultOptions () {
return gc_options.dOpt._shallowCopy();
return gc_options.getOptions(_sContext)._shallowCopy();
}
function resetOptions () {
_dOptions = gc_options.dOpt._shallowCopy();
_dOptions = gc_options.getOptions(_sContext)._shallowCopy();
}
function getDictionary () {
return _oDict;
}
function _getRules (bParagraph) {
|
︙ | | |
Modified gc_core/js/lang_core/gc_options.js
from [3105c2862f]
to [a6bfab9180].
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
16
17
18
19
20
21
22
23
24
|
+
+
+
+
+
+
+
-
+
+
+
+
+
+
-
|
// Options for Grammalecte
${map}
function getOptions (sContext="JavaScript") {
if (dOpt.hasOwnProperty(sContext)) {
return dOpt[sContext];
}
return dOpt["JavaScript"];
}
const lStructOpt = ${lStructOpt};
const dOpt = new Map (${dOptJavaScript});
const dOpt = {
"JavaScript": new Map (${dOptJavaScript}),
"Firefox": new Map (${dOptFirefox}),
"Thunderbird": new Map (${dOptThunderbird}),
}
const dOptLabel = ${dOptLabel};
exports.getOptions = getOptions;
exports.lStructOpt = lStructOpt;
exports.dOpt = dOpt;
exports.dOptLabel = dOptLabel;
|
Modified gc_core/py/lang_core/gc_engine.py
from [25f4682d72]
to [4742310603].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
+
-
-
+
+
|
locales = ${loc}
pkg = "${implname}"
name = "${name}"
version = "${version}"
author = "${author}"
# grammar rules and dictionary
_sContext = "" # what software is running
_rules = None
_dOptions = dict(gc_options.dOpt) # duplication necessary, to be able to reset to default
_rules = None # module gc_rules
_dOptions = None
_aIgnoredRules = set()
_oDict = None
_dAnalyses = {} # cache for data from dictionary
#### Parsing
|
︙ | | |
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
|
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
|
-
+
+
+
+
+
-
+
-
+
|
from com.sun.star.beans import PropertyValue
#import lightproof_handler_${implname} as opt
_createError = _createWriterError
except ImportError:
_createError = _createDictError
def load ():
def load (sContext="Python"):
global _oDict
global _sContext
global _dOptions
try:
_oDict = IBDAWG("${dic_name}.bdic")
_sContext = sContext
_dOptions = dict(gc_options.getOptions(sContext)) # duplication necessary, to be able to reset to default
except:
traceback.print_exc()
def setOption (sOpt, bVal):
if sOpt in _dOptions:
_dOptions[sOpt] = bVal
def setOptions (dOpt):
for sKey, bVal in dOpt.items():
if sKey in _dOptions:
_dOptions[sKey] = bVal
def getOptions ():
return _dOptions
def getDefaultOptions ():
return dict(gc_options.dOpt)
return dict(gc_options.getOptions(_sContext))
def getOptionsLabels (sLang):
return gc_options.getUI(sLang)
def displayOptions (sLang):
echo("List of options")
echo("\n".join( [ k+":\t"+str(v)+"\t"+gc_options.getUI(sLang).get(k, ("?", ""))[0] for k, v in sorted(_dOptions.items()) ] ))
echo("")
def resetOptions ():
global _dOptions
_dOptions = dict(gc_options.dOpt)
_dOptions = dict(gc_options.getOptions(_sContext))
def getDictionary ():
return _oDict
def _getRules (bParagraph):
|
︙ | | |
Modified gc_core/py/lang_core/gc_options.py
from [383a99acb3]
to [871c8d4b8f].
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
19
20
21
22
23
24
25
|
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
|
# generated code, do not edit
def getUI (sLang):
if sLang in _dOptLabel:
return _dOptLabel[sLang]
return _dOptLabel["fr"]
def getOptions (sContext="Python"):
if sContext in dOpt:
return dOpt[sContext]
return dOpt["Python"]
lStructOpt = ${lStructOpt}
dOpt = ${dOptPython}
dOpt = {
"Python": ${dOptPython},
"Server": ${dOptServer},
"Writer": ${dOptWriter}
}
_dOptLabel = ${dOptLabel}
|
Modified gc_core/py/oxt/Grammalecte.py
from [f962117745]
to [0f730fb3f5].
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
|
self.locales = []
for i in gce.locales:
l = gce.locales[i]
self.locales.append(Locale(l[0], l[1], l[2]))
self.locales = tuple(self.locales)
xCurCtx = uno.getComponentContext()
# init
gce.load()
gce.load("Writer")
# GC options
# opt_handler.load(xCurCtx)
dOpt = Options.load(xCurCtx)
gce.setOptions(dOpt)
# store for results of big paragraphs
self.dResult = {}
self.nMaxRes = 1500
|
︙ | | |
Modified gc_core/py/oxt/Options.py
from [f3a8765730]
to [e0f5ecd431].
︙ | | |
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
+
-
+
+
-
+
-
+
|
self.xContainer.endExecute()
else:
print("Wrong command: " + xActionEvent.ActionCommand)
except:
traceback.print_exc()
def _setDefault (self):
dOpt = gce.gc_options.getOptions("Writer")
for w in self.lxOptions:
w.State = gce.gc_options.dOpt.get(w.Name, False)
w.State = dOpt.get(w.Name, False)
def load (self, sLang):
try:
xChild = self.xNode.getByName(sLang)
dOpt = gce.gc_options.getOptions("Writer")
for sKey in gce.gc_options.dOpt:
for sKey in dOpt:
sValue = xChild.getPropertyValue(sKey)
if sValue == '':
if gce.gc_options.dOpt[sKey]:
if dOpt[sKey]:
sValue = 1
else:
sValue = 0
options[sKey] = bool(int(sValue))
except:
traceback.print_exc()
|
︙ | | |
Modified gc_lang/fr/rules.grx
from [1834cd53b7]
to [233237795c].
︙ | | |
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
OPTGROUP/verbs: infi conj ppas, imp inte vmode
OPTGROUP/style: bs pleo, redon1 redon2, neg
OPTGROUP/misc: date mc
OPTGROUP/debug: idrule
# pour l’instant, seuls les colonnes Python et JavaScript sont utiles
OPTSOFTWARE: Python JavaScript Writer Firefox Thunderbird
OPT/typo: True True True True True
OPT/apos: True True True True True
OPT/esp: True False True False False
OPT/tab: False False True False False
OPT/nbsp: True False True False False
OPT/tu: True True True True True
OPT/maj: True True True True True
OPT/num: True True True True True
OPT/virg: True True True True True
OPT/unit: True False True False False
OPT/nf: True True True True True
OPT/liga: False False False False False
OPT/mapos: False False False False False
OPT/chim: False False False False False
OPT/ocr: False False False False False
OPT/conf: True True True True True
OPT/sgpl: True True True True True
OPT/gn: True True True True True
OPT/infi: True True True True True
OPT/conj: True True True True True
OPT/ppas: True True True True True
OPT/imp: True True True True True
OPT/inte: True True True True True
OPT/vmode: True True True True True
OPT/bs: True True True True True
OPT/pleo: True True True True True
OPT/redon1: False False False False False
OPT/redon2: False False False False False
OPT/neg: False False False False False
OPT/date: True True True True True
OPT/mc: False False False False False
OPT/idrule: False False False False False
OPT/html: False True False True True
OPT/latex: False False False False False
OPTSOFTWARE: Python Server Writer JavaScript Firefox Thunderbird
OPT/typo: True True True True True True
OPT/apos: True True True True True True
OPT/esp: True True True False False False
OPT/tab: False True False False False False
OPT/nbsp: True True True False False False
OPT/tu: True True True True True True
OPT/maj: True True True True True True
OPT/num: True True True True True True
OPT/virg: True True True True True True
OPT/unit: True True True False False False
OPT/nf: True True True True True True
OPT/liga: False False False False False False
OPT/mapos: False False False False False False
OPT/chim: False False False False False False
OPT/ocr: False False False False False False
OPT/conf: True True True True True True
OPT/sgpl: True True True True True True
OPT/gn: True True True True True True
OPT/infi: True True True True True True
OPT/conj: True True False True True True
OPT/ppas: True True True True True True
OPT/imp: True True True True True True
OPT/inte: True True True True True True
OPT/vmode: True True True True True True
OPT/bs: True True True True True True
OPT/pleo: True True True True True True
OPT/redon1: False False False False False False
OPT/redon2: False False False False False False
OPT/neg: False False False False False False
OPT/date: True True True True True True
OPT/mc: False False False False False False
OPT/idrule: False False False False False False
OPT/html: False False False True True True
OPT/latex: False False False False False False
# Priority: from 0 to 9. Default priority is 4.
OPTPRIORITY/tu: 6
OPTPRIORITY/conf: 5
OPTPRIORITY/ocr: 3
|
︙ | | |
Modified gc_lang/fr/tb/content/overlay.js
from [3429b110d8]
to [31d038a91d].
︙ | | |
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
-
+
|
xGCEWorker: null,
bDictActive: null,
loadGC: function () {
if (this.xGCEWorker === null) {
// Grammar checker
echo('Loading Grammalecte');
this.xGCEWorker = new BasePromiseWorker('chrome://promiseworker/content/gce_worker.js');
let xPromise = this.xGCEWorker.post('loadGrammarChecker', [prefs.getCharPref("sGCOptions")]);
let xPromise = this.xGCEWorker.post('loadGrammarChecker', [prefs.getCharPref("sGCOptions"), "Thunderbird"]);
xPromise.then(
function (aVal) {
echo(aVal);
prefs.setCharPref("sGCOptions", aVal);
},
function (aReason) { echo('Promise rejected - ', aReason); }
).catch(
|
︙ | | |
Modified gc_lang/fr/xpi/gce_worker.js
from [779e66492e]
to [378b08526d].
︙ | | |
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
let lxg = null; // module: lexicographer
let helpers = null;
let oTokenizer = null;
let oDict = null;
let oLxg = null;
function loadGrammarChecker (sGCOptions="") {
function loadGrammarChecker (sGCOptions="", sContext="JavaScript") {
if (gce === null) {
try {
gce = require("resource://grammalecte/fr/gc_engine.js");
helpers = require("resource://grammalecte/helpers.js");
text = require("resource://grammalecte/text.js");
tkz = require("resource://grammalecte/tokenizer.js");
lxg = require("resource://grammalecte/fr/lexicographe.js");
oTokenizer = new tkz.Tokenizer("fr");
helpers.setLogOutput(worker.log);
gce.load();
oDict = gce.getDictionary();
oLxg = new lxg.Lexicographe(oDict);
if (sGCOptions !== "") {
gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
}
// we always retrieve options from the gce, for setOptions filters obsolete options
return gce.getOptions()._toString();
gce = require("resource://grammalecte/fr/gc_engine.js");
helpers = require("resource://grammalecte/helpers.js");
text = require("resource://grammalecte/text.js");
tkz = require("resource://grammalecte/tokenizer.js");
lxg = require("resource://grammalecte/fr/lexicographe.js");
oTokenizer = new tkz.Tokenizer("fr");
helpers.setLogOutput(worker.log);
gce.load(sContext);
oDict = gce.getDictionary();
oLxg = new lxg.Lexicographe(oDict);
if (sGCOptions !== "") {
gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
}
// we always retrieve options from the gce, for setOptions filters obsolete options
return gce.getOptions()._toString();
}
catch (e) {
worker.log("# Error: " + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}
}
}
function parse (sText, sLang, bDebug, bContext) {
let aGrammErr = gce.parse(sText, sLang, bDebug, bContext);
return JSON.stringify(aGrammErr);
}
|
︙ | | |
Modified gc_lang/fr/xpi/ui.js
from [e0ebb525c4]
to [d81c939773].
︙ | | |
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
-
+
|
let oTF = null;
function loadGrammarChecker (bSetPanelOptions=false) {
if (xGCEWorker === null) {
// Grammar checker
xGCEWorker = new BasePromiseWorker('chrome://promiseworker/content/gce_worker.js');
let xPromise = xGCEWorker.post('loadGrammarChecker', [sp.prefs["sGCOptions"]]);
let xPromise = xGCEWorker.post('loadGrammarChecker', [sp.prefs["sGCOptions"], "Firefox"]);
xPromise.then(
function (aVal) {
sp.prefs["sGCOptions"] = aVal;
if (bSetPanelOptions) {
xAboutPanel.port.emit("sendGrammarOptionsToPanel", aVal);
}
},
|
︙ | | |
Modified make.py
from [73e3038349]
to [78de6b4826].
︙ | | |
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
-
+
|
with open("server_options."+sLang+".ini", "w", encoding="utf-8", newline="\n") as hDst:
hDst.write("# Server options. Lang: " + sLang + "\n\n[gc_options]\n")
for sSection, lOpt in dOptData["lStructOpt"]:
hDst.write("\n########## " + dOptData["dOptLabel"][sLang].get(sSection, sSection + "[no label found]")[0] + " ##########\n")
for lLineOpt in lOpt:
for sOpt in lLineOpt:
hDst.write("# " + dOptData["dOptLabel"][sLang].get(sOpt, "[no label found]")[0] + "\n")
hDst.write(sOpt + " = " + ("1" if dOptData["dOptPython"].get(sOpt, None) else "0") + "\n")
hDst.write(sOpt + " = " + ("1" if dOptData["dOptServer"].get(sOpt, None) else "0") + "\n")
hDst.write("html = 1\n")
def createServerZip (sLang, dVars, spLangPack):
"create server zip"
spfZip = "_build/" + dVars['name'] + "-"+ dVars['lang'] +"-v" + dVars['version'] + '.zip'
hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)
|
︙ | | |
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
+
+
|
sCodePlugins += "\n\n" + open(spLang+'/modules-js/'+sf, "r", encoding="utf-8").read()
print(sf, end=", ")
print()
dVars["pluginsJS"] = sCodePlugins
# options data struct
dVars["dOptJavaScript"] = json.dumps(list(dVars["dOptJavaScript"].items()))
dVars["dOptFirefox"] = json.dumps(list(dVars["dOptFirefox"].items()))
dVars["dOptThunderbird"] = json.dumps(list(dVars["dOptThunderbird"].items()))
# create folder
spLangPack = "grammalecte-js/"+sLang
helpers.createCleanFolder(spLangPack)
# create files
for sf in os.listdir("gc_core/js"):
|
︙ | | |
Modified server.py
from [f2aebf4d47]
to [f6702400a5].
︙ | | |
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
-
+
|
if bEmptyIfNoErrors and not aGrammErrs and not aSpellErrs:
return ""
return " " + json.dumps({ "iParagraph": iParagraph, "lGrammarErrors": aGrammErrs, "lSpellingErrors": aSpellErrs }, ensure_ascii=False)
if __name__ == '__main__':
gce.load()
gce.load("Server")
echo("Grammalecte v{}".format(gce.version))
dServerOptions = getServerOptions()
dGCOptions = getConfigOptions("fr")
if dGCOptions:
gce.setOptions(dGCOptions)
dServerGCOptions = gce.getOptions()
echo("Grammar options:\n" + " | ".join([ k + ": " + str(v) for k, v in sorted(dServerGCOptions.items()) ]))
|
︙ | | |
Modified server_options.fr.ini
from [9838e78202]
to [d739170097].
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
|
-
+
|
# Server options. Lang: fr
[gc_options]
########## Typographie ##########
# Signes typographiques
typo = 1
# Apostrophe typographique
apos = 1
# Espaces surnuméraires
esp = 1
# Tabulations surnuméraires
tab = 0
tab = 1
# Espaces insécables
nbsp = 1
# Espaces insécables avant unités de mesure
unit = 1
# Traits d’union
tu = 1
# Majuscules
|
︙ | | |