25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
*/
"use strict";
console.log("[Worker] GC Engine Worker [start]");
//console.log(self);
importScripts("grammalecte/helpers.js");
importScripts("grammalecte/str_transform.js");
importScripts("grammalecte/ibdawg.js");
importScripts("grammalecte/text.js");
importScripts("grammalecte/tokenizer.js");
|
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
*/
"use strict";
//console.log("[Worker] GC Engine Worker [start]");
//console.log(self);
importScripts("grammalecte/helpers.js");
importScripts("grammalecte/str_transform.js");
importScripts("grammalecte/ibdawg.js");
importScripts("grammalecte/text.js");
importScripts("grammalecte/tokenizer.js");
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
Message Event Object
https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
*/
onmessage = function (e) {
console.log("[Worker] message received");
let {sCommand, dParam, dInfo} = e.data;
switch (sCommand) {
case "init":
init(dParam.sExtensionPath, dParam.sOptions, dParam.sContext, dInfo);
break;
case "parse":
parse(dParam.sText, dParam.sCountry, dParam.bDebug, dParam.bContext, dInfo);
|
<
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
Message Event Object
https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
*/
onmessage = function (e) {
let {sCommand, dParam, dInfo} = e.data;
switch (sCommand) {
case "init":
init(dParam.sExtensionPath, dParam.sOptions, dParam.sContext, dInfo);
break;
case "parse":
parse(dParam.sText, dParam.sCountry, dParam.bDebug, dParam.bContext, dInfo);
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
That’s why the full text to analyze is send in one block, but analyse is returned paragraph
by paragraph.
*/
function init (sExtensionPath, sGCOptions="", sContext="JavaScript", dInfo={}) {
try {
if (!bInitDone) {
console.log("[Worker] Loading… Extension path: " + sExtensionPath);
conj.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/conj_data.json"));
phonet.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/phonet_data.json"));
mfsp.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/mfsp_data.json"));
console.log("[Worker] Modules have been initialized…");
gc_engine.load(sContext, sExtensionPath+"grammalecte/_dictionaries");
oDict = gc_engine.getDictionary();
oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json");
oLxg = new Lexicographe(oDict);
if (sGCOptions !== "") {
gc_engine.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
}
|
|
|
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
That’s why the full text to analyze is send in one block, but analyse is returned paragraph
by paragraph.
*/
function init (sExtensionPath, sGCOptions="", sContext="JavaScript", dInfo={}) {
try {
if (!bInitDone) {
//console.log("[Worker] Loading… Extension path: " + sExtensionPath);
conj.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/conj_data.json"));
phonet.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/phonet_data.json"));
mfsp.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/mfsp_data.json"));
//console.log("[Worker] Modules have been initialized…");
gc_engine.load(sContext, sExtensionPath+"grammalecte/_dictionaries");
oDict = gc_engine.getDictionary();
oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json");
oLxg = new Lexicographe(oDict);
if (sGCOptions !== "") {
gc_engine.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
}
|