Overview
Comment: | [fx] initialize only once the grammar checker |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | fx | we_sw |
Files: | files | file ages | folders |
SHA3-256: |
dc16695aca20ff30975056cf299e983e |
User & Date: | olr on 2017-08-11 11:18:59 |
Other Links: | branch diff | manifest | tags |
Context
2017-08-11
| ||
11:18 | [fx] initialize only once the grammar checker Leaf check-in: dc16695aca user: olr tags: fx, we_sw | |
11:06 | [fx] use objects for communication with SharedWorker (normalization) check-in: 8f064f32f6 user: olr tags: fx, we_sw | |
Changes
Modified gc_lang/fr/webext/gce_sharedworker.js from [a479ff2c47] to [30d96d41ac].
︙ | ︙ | |||
82 83 84 85 86 87 88 | for (let sParam in e) { console.log(sParam); console.log(e[sParam]); } } onconnect = function (e) { | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | for (let sParam in e) { console.log(sParam); console.log(e[sParam]); } } onconnect = function (e) { console.log("[Sharedworker] START CONNECTION"); xPort = e.ports[0]; xPort.onmessage = function (e) { console.log("[Sharedworker] ONMESSAGE"); let {sCommand, dParam, dInfo} = e.data; console.log(e.data); switch (sCommand) { |
︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | console.log("Unknown command: " + sCommand); showData(e.data); } } //xPort.start(); } let oDict = null; let oTokenizer = null; let oLxg = null; let oTest = null; function init (sExtensionPath, sGCOptions="", sContext="JavaScript", dInfo={}) { try { | > > | | | | | | | | | | | | | | | | > > > > | 131 132 133 134 135 136 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 163 164 165 166 167 168 169 170 171 172 173 174 175 | console.log("Unknown command: " + sCommand); showData(e.data); } } //xPort.start(); } let bInitDone = false; let oDict = null; let oTokenizer = null; let oLxg = null; let oTest = null; function init (sExtensionPath, sGCOptions="", sContext="JavaScript", dInfo={}) { try { if (!bInitDone) { console.log("[Sharedworker] 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("[Sharedworker] 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))); } oTokenizer = new Tokenizer("fr"); //tests(); // we always retrieve options from the gc_engine, for setOptions filters obsolete options //xPort.postMessage(["options", gc_engine.getOptions().gl_toString()]); bInitDone = true; } else { console.log("[Sharedworker] Already initialized…") } xPort.postMessage(createResponse("init", gc_engine.getOptions().gl_toString(), dInfo)); } catch (e) { helpers.logerror(e); xPort.postMessage(createResponse("init", createErrorResult(e, "init failed"), dInfo, true)); } } |
︙ | ︙ | |||
218 219 220 221 222 223 224 | for (let oErr of aRes) { console.log(text.getReadableError(oErr)); } } function textToTest (sText, sCountry, bDebug, bContext, dInfo={}) { if (!gc_engine || !oDict) { | | | | 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | for (let oErr of aRes) { console.log(text.getReadableError(oErr)); } } function textToTest (sText, sCountry, bDebug, bContext, dInfo={}) { if (!gc_engine || !oDict) { xPort.postMessage(createResponse("textToTest", "# Grammar checker or dictionary not loaded.", dInfo)); return; } let aGrammErr = gc_engine.parse(sText, sCountry, bDebug, bContext); let sMsg = ""; for (let oErr of aGrammErr) { sMsg += text.getReadableError(oErr) + "\n"; } //xPort.postMessage(["text_to_test_result", sMsg]); xPort.postMessage(createResponse("textToTest", sMsg, dInfo)); } function fullTests (sGCOptions="", dInfo={}) { if (!gc_engine || !oDict) { xPort.postMessage(createResponse("fullTests", "# Grammar checker or dictionary not loaded.", dInfo)); return; } let dMemoOptions = gc_engine.getOptions(); if (sGCOptions) { gc_engine.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); } let sMsg = ""; |
︙ | ︙ |