Index: gc_lang/fr/mailext/worker/gce_worker.js ================================================================== --- gc_lang/fr/mailext/worker/gce_worker.js +++ gc_lang/fr/mailext/worker/gce_worker.js @@ -43,10 +43,11 @@ // no console here, use “dump” let gce = null; // module: grammar checker engine +let gco = null; let text = null; let tkz = null; // module: tokenizer let lxg = null; // module: lexicographer let helpers = null; @@ -55,23 +56,24 @@ let oLxg = null; function loadGrammarChecker (sGCOptions="", sContext="JavaScript") { if (gce === null) { try { + gco = require("resource://grammalecte/fr/gc_options.js"); gce = require("resource://grammalecte/fr/gc_engine.js"); helpers = require("resource://grammalecte/graphspell/helpers.js"); text = require("resource://grammalecte/text.js"); tkz = require("resource://grammalecte/graphspell/tokenizer.js"); //lxg = require("resource://grammalecte/fr/lexicographe.js"); oTokenizer = new tkz.Tokenizer("fr"); gce.load(sContext, "sCSS"); oSpellChecker = gce.getSpellChecker(); if (sGCOptions !== "") { - gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); + gco.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); } // we always retrieve options from the gce, for setOptions filters obsolete options - return gce.getOptions().gl_toString(); + return gco.getOptions().gl_toString(); } catch (e) { console.log("# Error: " + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); } } @@ -117,45 +119,45 @@ } return lSugg.join("|"); } function getOptions () { - return gce.getOptions().gl_toString(); + return gco.getOptions().gl_toString(); } function getDefaultOptions () { - return gce.getDefaultOptions().gl_toString(); + return gco.getDefaultOptions().gl_toString(); } function setOptions (sGCOptions) { - gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); - return gce.getOptions().gl_toString(); + gco.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); + return gco.getOptions().gl_toString(); } function setOption (sOptName, bValue) { - gce.setOptions(new Map([ [sOptName, bValue] ])); - return gce.getOptions().gl_toString(); + gco.setOptions(new Map([ [sOptName, bValue] ])); + return gco.getOptions().gl_toString(); } function resetOptions () { - gce.resetOptions(); - return gce.getOptions().gl_toString(); + gco.resetOptions(); + return gco.getOptions().gl_toString(); } function fullTests (sGCOptions="") { - if (!gce || !oSpellChecker) { + if (!gce || !oSpellChecker || !gco) { return "# Error: grammar checker or dictionary not loaded." } - let dMemoOptions = gce.getOptions(); + let dMemoOptions = gco.getOptions(); if (sGCOptions) { - gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); + gco.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); } let tests = require("resource://grammalecte/tests.js"); let oTest = new tests.TestGrammarChecking(gce); let sAllRes = ""; for (let sRes of oTest.testParse()) { console.log(sRes+"\n"); sAllRes += sRes+"\n"; } - gce.setOptions(dMemoOptions); + gco.setOptions(dMemoOptions); return sAllRes; }