158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
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/graphspell/_dictionaries");
oDict = gc_engine.getDictionary();
oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json");
oTokenizer = new Tokenizer("fr");
oLocution = helpers.loadFile(sExtensionPath + "/grammalecte/fr/locutions_data.json");
oLxg = new Lexicographe(oDict, oTokenizer, oLocution);
if (dOptions !== null) {
gc_engine.setOptions(dOptions);
}
//tests();
bInitDone = true;
} else {
console.log("[Worker] Already initialized…")
|
|
|
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
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/graphspell/_dictionaries");
oSpellChecker = gc_engine.getSpellChecker();
oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json");
oTokenizer = new Tokenizer("fr");
oLocution = helpers.loadFile(sExtensionPath + "/grammalecte/fr/locutions_data.json");
oLxg = new Lexicographe(oSpellChecker, oTokenizer, oLocution);
if (dOptions !== null) {
gc_engine.setOptions(dOptions);
}
//tests();
bInitDone = true;
} else {
console.log("[Worker] Already initialized…")
|
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
}
function parseAndSpellcheck (sText, sCountry, bDebug, bContext, dInfo={}) {
let i = 0;
sText = sText.replace(//g, "").normalize("NFC");
for (let sParagraph of text.getParagraph(sText)) {
let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, bContext);
let aSpellErr = oTokenizer.getSpellingErrors(sParagraph, oDict);
postMessage(createResponse("parseAndSpellcheck", {sParagraph: sParagraph, iParaNum: i, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, dInfo, false));
i += 1;
}
postMessage(createResponse("parseAndSpellcheck", null, dInfo, true));
}
function parseAndSpellcheck1 (sParagraph, sCountry, bDebug, bContext, dInfo={}) {
sParagraph = sParagraph.replace(//g, "").normalize("NFC");
let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, bContext);
let aSpellErr = oTokenizer.getSpellingErrors(sParagraph, oDict);
postMessage(createResponse("parseAndSpellcheck1", {sParagraph: sParagraph, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, dInfo, true));
}
function getOptions (dInfo={}) {
postMessage(createResponse("getOptions", gc_engine.getOptions(), dInfo, true));
}
|
|
|
|
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
}
function parseAndSpellcheck (sText, sCountry, bDebug, bContext, dInfo={}) {
let i = 0;
sText = sText.replace(//g, "").normalize("NFC");
for (let sParagraph of text.getParagraph(sText)) {
let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, bContext);
let aSpellErr = oTokenizer.getSpellingErrors(sParagraph, oSpellChecker);
postMessage(createResponse("parseAndSpellcheck", {sParagraph: sParagraph, iParaNum: i, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, dInfo, false));
i += 1;
}
postMessage(createResponse("parseAndSpellcheck", null, dInfo, true));
}
function parseAndSpellcheck1 (sParagraph, sCountry, bDebug, bContext, dInfo={}) {
sParagraph = sParagraph.replace(//g, "").normalize("NFC");
let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, bContext);
let aSpellErr = oTokenizer.getSpellingErrors(sParagraph, oSpellChecker);
postMessage(createResponse("parseAndSpellcheck1", {sParagraph: sParagraph, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, dInfo, true));
}
function getOptions (dInfo={}) {
postMessage(createResponse("getOptions", gc_engine.getOptions(), dInfo, true));
}
|
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
postMessage(createResponse("fullTests", sMsg, dInfo, true));
}
// Spellchecker
function getSpellSuggestions (sWord, dInfo) {
if (!oDict) {
postMessage(createResponse("getSpellSuggestions", "# Error. Dictionary not loaded.", dInfo, true));
return;
}
let aSugg = oDict.suggest(sWord);
postMessage(createResponse("getSpellSuggestions", {sWord: sWord, aSugg: aSugg}, dInfo, true));
}
// Lexicographer
function getListOfTokens (sText, dInfo={}) {
try {
|
|
>
|
|
>
>
|
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
postMessage(createResponse("fullTests", sMsg, dInfo, true));
}
// Spellchecker
function getSpellSuggestions (sWord, dInfo) {
if (!oSpellChecker) {
postMessage(createResponse("getSpellSuggestions", "# Error. Dictionary not loaded.", dInfo, true));
return;
}
let i = 1;
for (let aSugg of oSpellChecker.suggest(sWord)) {
postMessage(createResponse("getSpellSuggestions", {sWord: sWord, aSugg: aSugg, iSugg: i}, dInfo, true));
i += 1;
}
}
// Lexicographer
function getListOfTokens (sText, dInfo={}) {
try {
|