115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
break;
case "textToTest":
textToTest(dParam.sText, dParam.sCountry, dParam.bDebug, dParam.bContext, dInfo);
break;
case "fullTests":
fullTests(dInfo);
break;
case "getListOfTokens":
getListOfTokens(dParam.sText, dInfo);
break;
default:
console.log("[Worker] Unknown command: " + sCommand);
showData(e.data);
}
|
>
>
>
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
break;
case "textToTest":
textToTest(dParam.sText, dParam.sCountry, dParam.bDebug, dParam.bContext, dInfo);
break;
case "fullTests":
fullTests(dInfo);
break;
case "getSpellSuggestions":
getSpellSuggestions(dParam.sWord, dInfo);
break;
case "getListOfTokens":
getListOfTokens(dParam.sText, dInfo);
break;
default:
console.log("[Worker] Unknown command: " + sCommand);
showData(e.data);
}
|
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
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
|
let aRes = gc_engine.parse("Je suit...");
for (let oErr of aRes) {
console.log(text.getReadableError(oErr));
}
}
function textToTest (sText, sCountry, bDebug, bContext, dInfo={}) {
if (!gc_engine || !oDict) {
postMessage(createResponse("textToTest", "# Grammar checker or dictionary not loaded.", dInfo, true));
return;
}
let aGrammErr = gc_engine.parse(sText, sCountry, bDebug, bContext);
let sMsg = "";
for (let oErr of aGrammErr) {
sMsg += text.getReadableError(oErr) + "\n";
}
if (sMsg == "") {
sMsg = "Aucune erreur détectée.";
}
postMessage(createResponse("textToTest", sMsg, dInfo, true));
}
function fullTests (dInfo={}) {
if (!gc_engine || !oDict) {
postMessage(createResponse("fullTests", "# Grammar checker or dictionary not loaded.", dInfo, true));
return;
}
let dMemoOptions = gc_engine.getOptions();
let dTestOptions = gc_engine.getDefaultOptions();
dTestOptions.set("nbsp", true);
dTestOptions.set("esp", true);
dTestOptions.set("unit", true);
dTestOptions.set("num", true);
gc_engine.setOptions(dTestOptions);
let sMsg = "";
for (let sRes of oTest.testParse()) {
sMsg += sRes + "\n";
console.log(sRes);
}
gc_engine.setOptions(dMemoOptions);
postMessage(createResponse("fullTests", sMsg, dInfo, true));
}
// Lexicographer
function getListOfTokens (sText, dInfo={}) {
try {
for (let sParagraph of text.getParagraph(sText)) {
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
|
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
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
294
295
296
297
298
299
300
|
let aRes = gc_engine.parse("Je suit...");
for (let oErr of aRes) {
console.log(text.getReadableError(oErr));
}
}
function textToTest (sText, sCountry, bDebug, bContext, dInfo={}) {
if (!gc_engine) {
postMessage(createResponse("textToTest", "# Grammar checker not loaded.", dInfo, true));
return;
}
let aGrammErr = gc_engine.parse(sText, sCountry, bDebug, bContext);
let sMsg = "";
for (let oErr of aGrammErr) {
sMsg += text.getReadableError(oErr) + "\n";
}
if (sMsg == "") {
sMsg = "Aucune erreur détectée.";
}
postMessage(createResponse("textToTest", sMsg, dInfo, true));
}
function fullTests (dInfo={}) {
if (!gc_engine) {
postMessage(createResponse("fullTests", "# Grammar checker not loaded.", dInfo, true));
return;
}
let dMemoOptions = gc_engine.getOptions();
let dTestOptions = gc_engine.getDefaultOptions();
dTestOptions.set("nbsp", true);
dTestOptions.set("esp", true);
dTestOptions.set("unit", true);
dTestOptions.set("num", true);
gc_engine.setOptions(dTestOptions);
let sMsg = "";
for (let sRes of oTest.testParse()) {
sMsg += sRes + "\n";
console.log(sRes);
}
gc_engine.setOptions(dMemoOptions);
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);
console.log(aSugg);
postMessage(createResponse("getSpellSuggestions", {sWord: sWord, aSugg: aSugg}, dInfo, true));
}
// Lexicographer
function getListOfTokens (sText, dInfo={}) {
try {
for (let sParagraph of text.getParagraph(sText)) {
|