Comment: | [graphspell][core][fx][tb][js] get rid of console.log() substitutes, assuming now default console is available from everywhere (eh, print now works as expected in JS! The JS pile of shit is decreasing a little) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | core | tb | fx | graphspell |
Files: | files | file ages | folders |
SHA3-256: |
8e5a2f59009c721ca093299dc72d6512 |
User & Date: | olr on 2018-08-07 08:09:50 |
Other Links: | manifest | tags |
2018-08-07
| ||
08:27 | [graphspell] get rid of console.log() substitutes, assuming now default console is available from everywhere check-in: 1a3885282a user: olr tags: trunk, graphspell | |
08:09 | [graphspell][core][fx][tb][js] get rid of console.log() substitutes, assuming now default console is available from everywhere (eh, print now works as expected in JS! The JS pile of shit is decreasing a little) check-in: 8e5a2f5900 user: olr tags: trunk, core, tb, fx, graphspell | |
2018-08-06
| ||
16:43 | [tb] merge tbnext: update Thunderbird extension for Thunderbird 60 (API update) check-in: b5dece919f user: olr tags: trunk, tb | |
Modified gc_core/js/lang_core/gc_engine.js from [7ee1350cd7] to [ab7d9a98c9].
1 2 3 4 5 6 7 8 9 10 11 12 | // Grammar checker engine /*jslint esversion: 6*/ /*global console,require,exports*/ "use strict"; ${string} ${regex} ${map} if (typeof(require) !== 'undefined') { | | < < < | < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | // Grammar checker engine /*jslint esversion: 6*/ /*global console,require,exports*/ "use strict"; ${string} ${regex} ${map} if (typeof(require) !== 'undefined') { //var helpers = require("resource://grammalecte/graphspell/helpers.js"); var gc_options = require("resource://grammalecte/${lang}/gc_options.js"); var gc_rules = require("resource://grammalecte/${lang}/gc_rules.js"); var cregex = require("resource://grammalecte/${lang}/cregex.js"); var text = require("resource://grammalecte/text.js"); } function capitalizeArray (aArray) { // can’t map on user defined function?? let aNew = []; for (let i = 0; i < aArray.length; i = i + 1) { aNew[i] = aArray[i].gl_toCapitalize(); } |
︙ | ︙ | |||
68 69 70 71 72 73 74 | try { [sNew, dErrors] = this._proofread(sText, sAlt, 0, true, dDA, dPriority, sCountry, bDebug, bContext); if (sNew) { sText = sNew; } } catch (e) { | | < | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | try { [sNew, dErrors] = this._proofread(sText, sAlt, 0, true, dDA, dPriority, sCountry, bDebug, bContext); if (sNew) { sText = sNew; } } catch (e) { console.error(e); } // cleanup if (sText.includes(" ")) { sText = sText.replace(/ /g, ' '); // nbsp } if (sText.includes(" ")) { sText = sText.replace(/ /g, ' '); // snbsp } if (sText.includes("'")) { sText = sText.replace(/'/g, "’"); } if (sText.includes("‑")) { sText = sText.replace(/‑/g, "-"); // nobreakdash } // parse sentence for (let [iStart, iEnd] of this._getSentenceBoundaries(sText)) { if (4 < (iEnd - iStart) < 2000) { dDA.clear(); try { [, errs] = this._proofread(sText.slice(iStart, iEnd), sAlt.slice(iStart, iEnd), iStart, false, dDA, dPriority, sCountry, bDebug, bContext); dErrors.gl_update(errs); } catch (e) { console.error(e); } } } return Array.from(dErrors.values()); }, _zEndOfSentence: new RegExp ('([.?!:;…][ .?!… »”")]*|.$)', "g"), |
︙ | ︙ | |||
131 132 133 134 135 136 137 | for (let [sOption, lRuleGroup] of this._getRules(bParagraph)) { if (!sOption || option(sOption)) { for (let [zRegex, bUppercase, sLineId, sRuleId, nPriority, lActions, lGroups, lNegLookBefore] of lRuleGroup) { if (!_aIgnoredRules.has(sRuleId)) { while ((m = zRegex.gl_exec2(s, lGroups, lNegLookBefore)) !== null) { bCondMemo = null; /*if (bDebug) { | | | | | | | | | | | | | 124 125 126 127 128 129 130 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 176 177 178 179 180 181 182 183 184 185 186 187 188 | for (let [sOption, lRuleGroup] of this._getRules(bParagraph)) { if (!sOption || option(sOption)) { for (let [zRegex, bUppercase, sLineId, sRuleId, nPriority, lActions, lGroups, lNegLookBefore] of lRuleGroup) { if (!_aIgnoredRules.has(sRuleId)) { while ((m = zRegex.gl_exec2(s, lGroups, lNegLookBefore)) !== null) { bCondMemo = null; /*if (bDebug) { console.log(">>>> Rule # " + sLineId + " - Text: " + s + " opt: "+ sOption); }*/ for (let [sFuncCond, cActionType, sWhat, ...eAct] of lActions) { // action in lActions: [ condition, action type, replacement/suggestion/action[, iGroup[, message, URL]] ] try { //console.log(oEvalFunc[sFuncCond]); bCondMemo = (!sFuncCond || oEvalFunc[sFuncCond](s, sx, m, dDA, sCountry, bCondMemo)); if (bCondMemo) { switch (cActionType) { case "-": // grammar error //console.log("-> error detected in " + sLineId + "\nzRegex: " + zRegex.source); nErrorStart = nOffset + m.start[eAct[0]]; if (!dErrs.has(nErrorStart) || nPriority > dPriority.get(nErrorStart)) { dErrs.set(nErrorStart, this._createError(s, sx, sWhat, nOffset, m, eAct[0], sLineId, sRuleId, bUppercase, eAct[1], eAct[2], bIdRule, sOption, bContext)); dPriority.set(nErrorStart, nPriority); } break; case "~": // text processor //console.log("-> text processor by " + sLineId + "\nzRegex: " + zRegex.source); s = this._rewrite(s, sWhat, eAct[0], m, bUppercase); bChange = true; if (bDebug) { console.log("~ " + s + " -- " + m[eAct[0]] + " # " + sLineId); } break; case "=": // disambiguation //console.log("-> disambiguation by " + sLineId + "\nzRegex: " + zRegex.source); oEvalFunc[sWhat](s, m, dDA); if (bDebug) { console.log("= " + m[0] + " # " + sLineId + "\nDA: " + dDA.gl_toString()); } break; case ">": // we do nothing, this test is just a condition to apply all following actions break; default: console.log("# error: unknown action at " + sLineId); } } else { if (cActionType == ">") { break; } } } catch (e) { console.log(s); console.log("# line id: " + sLineId + "\n# rule id: " + sRuleId); console.error(e); } } } } } } } |
︙ | ︙ | |||
265 266 267 268 269 270 271 | if (bUppercase && m[iGroup].slice(0,1).gl_isUpperCase()) { sNew = sNew.gl_toCapitalize(); } } else { sNew = sRepl.gl_expand(m); sNew = sNew + " ".repeat(ln-sNew.length); } | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | if (bUppercase && m[iGroup].slice(0,1).gl_isUpperCase()) { sNew = sNew.gl_toCapitalize(); } } else { sNew = sRepl.gl_expand(m); sNew = sNew + " ".repeat(ln-sNew.length); } //console.log("\n"+s+"\nstart: "+m.start[iGroup]+" end:"+m.end[iGroup]) return s.slice(0, m.start[iGroup]) + sNew + s.slice(m.end[iGroup]); }, // Actions on rules ignoreRule: function (sRuleId) { _aIgnoredRules.add(sRuleId); |
︙ | ︙ | |||
302 303 304 305 306 307 308 | if (!sFilter || sRuleId.test(sFilter)) { yield [sOption, sLineId, sRuleId]; } } } } catch (e) { | | | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | if (!sFilter || sRuleId.test(sFilter)) { yield [sOption, sLineId, sRuleId]; } } } } catch (e) { console.error(e); } }, _getRules: function (bParagraph) { if (!bParagraph) { return gc_rules.lSentenceRules; } |
︙ | ︙ | |||
327 328 329 330 331 332 333 | } else { _oSpellChecker = new SpellChecker("${lang}", sPath, "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}"); } _sAppContext = sContext; _dOptions = gc_options.getOptions(sContext).gl_shallowCopy(); // duplication necessary, to be able to reset to default } catch (e) { | | | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | } else { _oSpellChecker = new SpellChecker("${lang}", sPath, "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}"); } _sAppContext = sContext; _dOptions = gc_options.getOptions(sContext).gl_shallowCopy(); // duplication necessary, to be able to reset to default } catch (e) { console.error(e); } }, getSpellChecker: function () { return _oSpellChecker; }, |
︙ | ︙ | |||
371 372 373 374 375 376 377 | // return true if option sOpt is active return _dOptions.get(sOpt); } function displayInfo (dDA, aWord) { // for debugging: info of word if (!aWord) { | | | | | | | | | | | | | | | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | // return true if option sOpt is active return _dOptions.get(sOpt); } function displayInfo (dDA, aWord) { // for debugging: info of word if (!aWord) { console.log("> nothing to find"); return true; } if (!_dAnalyses.has(aWord[1]) && !_storeMorphFromFSA(aWord[1])) { console.log("> not in FSA"); return true; } if (dDA.has(aWord[0])) { console.log("DA: " + dDA.get(aWord[0])); } console.log("FSA: " + _dAnalyses.get(aWord[1])); return true; } function _storeMorphFromFSA (sWord) { // retrieves morphologies list from _oSpellChecker -> _dAnalyses //console.log("register: "+sWord + " " + _oSpellChecker.getMorph(sWord).toString()) _dAnalyses.set(sWord, _oSpellChecker.getMorph(sWord)); return !!_dAnalyses.get(sWord); } function morph (dDA, aWord, sPattern, bStrict=true, bNoWord=false) { // analyse a tuple (position, word), return true if sPattern in morphologies (disambiguation on) if (!aWord) { //console.log("morph: noword, returns " + bNoWord); return bNoWord; } //console.log("aWord: "+aWord.toString()); if (!_dAnalyses.has(aWord[1]) && !_storeMorphFromFSA(aWord[1])) { return false; } let lMorph = dDA.has(aWord[0]) ? dDA.get(aWord[0]) : _dAnalyses.get(aWord[1]); //console.log("lMorph: "+lMorph.toString()); if (lMorph.length === 0) { return false; } //console.log("***"); if (bStrict) { return lMorph.every(s => (s.search(sPattern) !== -1)); } return lMorph.some(s => (s.search(sPattern) !== -1)); } function morphex (dDA, aWord, sPattern, sNegPattern, bNoWord=false) { // analyse a tuple (position, word), returns true if not sNegPattern in word morphologies and sPattern in word morphologies (disambiguation on) if (!aWord) { //console.log("morph: noword, returns " + bNoWord); return bNoWord; } //console.log("aWord: "+aWord.toString()); if (!_dAnalyses.has(aWord[1]) && !_storeMorphFromFSA(aWord[1])) { return false; } let lMorph = dDA.has(aWord[0]) ? dDA.get(aWord[0]) : _dAnalyses.get(aWord[1]); //console.log("lMorph: "+lMorph.toString()); if (lMorph.length === 0) { return false; } //console.log("***"); // check negative condition if (lMorph.some(s => (s.search(sNegPattern) !== -1))) { return false; } // search sPattern return lMorph.some(s => (s.search(sPattern) !== -1)); } |
︙ | ︙ | |||
528 529 530 531 532 533 534 | try { if (zNegPattern && zNegPattern.test(s)) { return false; } return zPattern.test(s); } catch (e) { | | | | | 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | try { if (zNegPattern && zNegPattern.test(s)) { return false; } return zPattern.test(s); } catch (e) { console.error(e); } return false; } function look_chk1 (dDA, s, nOffset, zPattern, sPatternGroup1, sNegPatternGroup1=null) { // returns True if s has pattern zPattern and m.group(1) has pattern sPatternGroup1 let m = zPattern.gl_exec2(s, null); if (!m) { return false; } try { let sWord = m[1]; let nPos = m.start[1] + nOffset; if (sNegPatternGroup1) { return morphex(dDA, [nPos, sWord], sPatternGroup1, sNegPatternGroup1); } return morph(dDA, [nPos, sWord], sPatternGroup1, false); } catch (e) { console.error(e); return false; } } //////// Disambiguator |
︙ | ︙ |
Modified gc_core/js/tests.js from [7c35f52f2d] to [3d850428e6].
︙ | ︙ | |||
74 75 76 77 78 79 80 | if (i % 1000 === 0) { yield i.toString(); } } bShowUntested = true; } catch (e) { | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | if (i % 1000 === 0) { yield i.toString(); } } bShowUntested = true; } catch (e) { console.error(e); } if (bShowUntested) { i = 0; for (let [sOpt, sLineId, sRuleId] of this.gce.listRules()) { if (!this._aRuleTested.has(sLineId) && !/^[0-9]+[sp]$|^[pd]_/.test(sRuleId)) { sUntestedRules += sRuleId + ", "; |
︙ | ︙ | |||
116 117 118 119 120 121 122 | console.log("\ninfinite loop?\nline:"+sLine+"\nm: "+ m.toString()); break; } } return sRes; } catch (e) { | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | console.log("\ninfinite loop?\nline:"+sLine+"\nm: "+ m.toString()); break; } } return sRes; } catch (e) { console.error(e); } return " ".repeat(sLine.length); } _getFoundErrors (sLine, bDebug, sOption) { try { let aErrs = []; |
︙ | ︙ | |||
141 142 143 144 145 146 147 | sRes = sRes.slice(0, dErr["nStart"]) + "~".repeat(dErr["nEnd"] - dErr["nStart"]) + sRes.slice(dErr["nEnd"]); sListErr += " * {" + dErr['sLineId'] + " / " + dErr['sRuleId'] + "} at " + dErr['nStart'] + ":" + dErr['nEnd'] + "\n"; this._aRuleTested.add(dErr["sLineId"]); } return [sRes, sListErr]; } catch (e) { | | | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | sRes = sRes.slice(0, dErr["nStart"]) + "~".repeat(dErr["nEnd"] - dErr["nStart"]) + sRes.slice(dErr["nEnd"]); sListErr += " * {" + dErr['sLineId'] + " / " + dErr['sRuleId'] + "} at " + dErr['nStart'] + ":" + dErr['nEnd'] + "\n"; this._aRuleTested.add(dErr["sLineId"]); } return [sRes, sListErr]; } catch (e) { console.error(e); } return [" ".repeat(sLine.length), ""]; } } if (typeof(exports) !== 'undefined') { exports.TestGrammarChecking = TestGrammarChecking; } |
Modified gc_core/js/text.js from [09e0f281de] to [c9e7670db8].
1 2 3 4 5 6 | // JavaScript /*jslint esversion: 6*/ /*global require,exports*/ "use strict"; | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 | // JavaScript /*jslint esversion: 6*/ /*global require,exports*/ "use strict"; var text = { getParagraph: function* (sText, sSepParagraph = "\n") { // generator: returns paragraphs of text let iStart = 0; let iEnd = 0; sText = sText.replace("\r\n", "\n").replace("\r", "\n"); |
︙ | ︙ | |||
53 54 55 56 57 58 59 | } if (oErr["URL"] !== "") { sResult += "\n > URL: " + oErr["URL"]; } return sResult; } catch (e) { | | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | } if (oErr["URL"] !== "") { sResult += "\n > URL: " + oErr["URL"]; } return sResult; } catch (e) { console.error(e); return "\n# Error. Data: " + oErr.toString(); } } }; if (typeof(exports) !== 'undefined') { exports.getParagraph = text.getParagraph; exports.wrap = text.wrap; exports.getReadableError = text.getReadableError; } |
Modified gc_lang/fr/modules-js/gce_suggestions.js from [0c31bc1a27] to [5849d4fa9b].
︙ | ︙ | |||
568 569 570 571 572 573 574 | let m = /NF[ -]?(C|E|P|Q|S|X|Z|EN(?:[ -]ISO|))[ -]?([0-9]+(?:[\/‑-][0-9]+|))/i.exec(s); if (!m) { return ""; } return "NF " + m[1].toUpperCase().replace(/ /g, " ").replace(/-/g, " ") + " " + m[2].replace(/\//g, "‑").replace(/-/g, "‑"); } catch (e) { | | | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | let m = /NF[ -]?(C|E|P|Q|S|X|Z|EN(?:[ -]ISO|))[ -]?([0-9]+(?:[\/‑-][0-9]+|))/i.exec(s); if (!m) { return ""; } return "NF " + m[1].toUpperCase().replace(/ /g, " ").replace(/-/g, " ") + " " + m[2].replace(/\//g, "‑").replace(/-/g, "‑"); } catch (e) { console.error(e); return "# erreur #"; } } function undoLigature (c) { if (c == "fi") { return "fi"; |
︙ | ︙ |
Modified gc_lang/fr/modules-js/lexicographe.js from [823f277d47] to [ce143d1120].
1 2 3 4 5 6 7 8 9 10 11 | // Grammalecte - Lexicographe // License: MPL 2 /*jslint esversion: 6*/ /*global require,exports*/ "use strict"; ${string} ${map} | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // Grammalecte - Lexicographe // License: MPL 2 /*jslint esversion: 6*/ /*global require,exports*/ "use strict"; ${string} ${map} const _dTag = new Map([ [':N', [" nom,", "Nom"]], [':A', [" adjectif,", "Adjectif"]], [':M1', [" prénom,", "Prénom"]], [':M2', [" patronyme,", "Patronyme, matronyme, nom de famille…"]], [':MP', [" nom propre,", "Nom propre"]], [':W', [" adverbe,", "Adverbe"]], |
︙ | ︙ | |||
83 84 85 86 87 88 89 | [':O2', [" 2ᵉ pers.,", "Pronom : 2ᵉ personne"]], [':O3', [" 3ᵉ pers.,", "Pronom : 3ᵉ personne"]], [':C', [" conjonction,", "Conjonction"]], [':Ĉ', [" conjonction (él.),", "Conjonction (élément)"]], [':Cc', [" conjonction de coordination,", "Conjonction de coordination"]], [':Cs', [" conjonction de subordination,", "Conjonction de subordination"]], [':Ĉs', [" conjonction de subordination (él.),", "Conjonction de subordination (élément)"]], | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | [':O2', [" 2ᵉ pers.,", "Pronom : 2ᵉ personne"]], [':O3', [" 3ᵉ pers.,", "Pronom : 3ᵉ personne"]], [':C', [" conjonction,", "Conjonction"]], [':Ĉ', [" conjonction (él.),", "Conjonction (élément)"]], [':Cc', [" conjonction de coordination,", "Conjonction de coordination"]], [':Cs', [" conjonction de subordination,", "Conjonction de subordination"]], [':Ĉs', [" conjonction de subordination (él.),", "Conjonction de subordination (élément)"]], [':Ñ', [" locution nominale (él.),", "Locution nominale (élément)"]], [':Â', [" locution adjectivale (él.),", "Locution adjectivale (élément)"]], [':Ṽ', [" locution verbale (él.),", "Locution verbale (élément)"]], [':Ŵ', [" locution adverbiale (él.),", "Locution adverbiale (élément)"]], [':Ŕ', [" locution prépositive (él.),", "Locution prépositive (élément)"]], [':Ĵ', [" locution interjective (él.),", "Locution interjective (élément)"]], |
︙ | ︙ | |||
353 354 355 356 357 358 359 | sValue: oToken.sValue, aLabel: ["mot inconnu du dictionnaire"] }; } break; } } catch (e) { | | | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | sValue: oToken.sValue, aLabel: ["mot inconnu du dictionnaire"] }; } break; } } catch (e) { console.error(e); } return null; } _getMorph (sWord) { let aElem = []; for (let s of this.oSpellChecker.getMorph(sWord)) { |
︙ | ︙ |
Modified gc_lang/fr/tb/worker/gce_worker.js from [d40c8ac28d] to [aee0cb045d].
︙ | ︙ | |||
59 60 61 62 63 64 65 | try { 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"); | < | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | try { 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); oSpellChecker = gce.getSpellChecker(); if (sGCOptions !== "") { gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); } // we always retrieve options from the gce, for setOptions filters obsolete options return gce.getOptions().gl_toString(); |
︙ | ︙ |
Modified gc_lang/fr/webext/gce_worker.js from [cde0b49723] to [221a92cd88].
︙ | ︙ | |||
185 186 187 188 189 190 191 | console.log("[Worker] Already initialized…") } // we always retrieve options from the gc_engine, for setOptions filters obsolete options dOptions = helpers.mapToObject(gc_engine.getOptions()); postMessage(createResponse("init", dOptions, dInfo, true)); } catch (e) { | | | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | console.log("[Worker] Already initialized…") } // we always retrieve options from the gc_engine, for setOptions filters obsolete options dOptions = helpers.mapToObject(gc_engine.getOptions()); postMessage(createResponse("init", dOptions, dInfo, true)); } catch (e) { console.error(e); postMessage(createResponse("init", createErrorResult(e, "init failed"), dInfo, true, true)); } } function parse (sText, sCountry, bDebug, bContext, dInfo={}) { sText = sText.replace(//g, "").normalize("NFC"); |
︙ | ︙ | |||
390 391 392 393 394 395 396 | if (sParagraph.trim() !== "") { postMessage(createResponse("getListOfTokens", oLxg.getListOfTokensReduc(sParagraph, true), dInfo, false)); } } postMessage(createResponse("getListOfTokens", null, dInfo, true)); } catch (e) { | | | 390 391 392 393 394 395 396 397 398 399 400 | if (sParagraph.trim() !== "") { postMessage(createResponse("getListOfTokens", oLxg.getListOfTokensReduc(sParagraph, true), dInfo, false)); } } postMessage(createResponse("getListOfTokens", null, dInfo, true)); } catch (e) { console.error(e); postMessage(createResponse("getListOfTokens", createErrorResult(e, "no tokens"), dInfo, true, true)); } } |
Modified graphspell-js/helpers.js from [d93f7e0941] to [4f9104fefe].
1 2 3 4 5 6 7 | // HELPERS /*jslint esversion: 6*/ /*global console,require,exports,XMLHttpRequest*/ "use strict"; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // HELPERS /*jslint esversion: 6*/ /*global console,require,exports,XMLHttpRequest*/ "use strict"; var helpers = { inspect: function (o) { let sMsg = "__inspect__: " + typeof o; for (let sParam in o) { sMsg += "\n" + sParam + ": " + o.sParam; } sMsg += "\n" + JSON.stringify(o) + "\n__end__"; this.echo(sMsg); |
︙ | ︙ | |||
87 88 89 90 91 92 93 | } return obj; } }; if (typeof(exports) !== 'undefined') { | < < < | 57 58 59 60 61 62 63 64 65 66 67 68 | } return obj; } }; if (typeof(exports) !== 'undefined') { exports.inspect = helpers.inspect; exports.loadFile = helpers.loadFile; exports.objectToMap = helpers.objectToMap; exports.mapToObject = helpers.mapToObject; } |
Modified graphspell-js/str_transform.js from [1ed9d3e05c] to [7b239f9b34].
︙ | ︙ | |||
74 75 76 77 78 79 80 | matrix[i][j] = Math.min(matrix[i][j], matrix[i-2][j-2] + nCost); // Transposition } } } return matrix[nLen1][nLen2]; } catch (e) { | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | matrix[i][j] = Math.min(matrix[i][j], matrix[i-2][j-2] + nCost); // Transposition } } } return matrix[nLen1][nLen2]; } catch (e) { console.error(e); } }, distanceDamerauLevenshtein: function (s1, s2) { // distance of Damerau-Levenshtein between <s1> and <s2> // https://fr.wikipedia.org/wiki/Distance_de_Damerau-Levenshtein try { |
︙ | ︙ | |||
121 122 123 124 125 126 127 | matrix[i+1][j+1] = Math.min(matrix[i+1][j+1], matrix[i1] ? matrix[i1][j1] + (i-i1-1) + 1 + (j-j1-1) : Infinity); } sd[s1[i-1]] = i; } return matrix[nLen1+1][nLen2+1]; } catch (e) { | | | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | matrix[i+1][j+1] = Math.min(matrix[i+1][j+1], matrix[i1] ? matrix[i1][j1] + (i-i1-1) + 1 + (j-j1-1) : Infinity); } sd[s1[i-1]] = i; } return matrix[nLen1+1][nLen2+1]; } catch (e) { console.error(e); } }, showDistance (s1, s2) { console.log(`Distance: ${s1} / ${s2} = ${this.distanceDamerauLevenshtein(s1, s2)})`); }, |
︙ | ︙ | |||
160 161 162 163 164 165 166 | changeWordWithSuffixCode: function (sWord, sSfxCode) { if (sSfxCode == "0") { return sWord; } return sSfxCode[0] == '0' ? sWord + sSfxCode.slice(1) : sWord.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1); }, | | | | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | changeWordWithSuffixCode: function (sWord, sSfxCode) { if (sSfxCode == "0") { return sWord; } return sSfxCode[0] == '0' ? sWord + sSfxCode.slice(1) : sWord.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1); }, // Prefix and suffix defineAffixCode: function (sFlex, sStem) { /* UNTESTED! Returns a string defining how to get stem from flexion. Examples: "0" if stem = flexion "stem" if no common substring "n(pfx)/m(sfx)" with n and m: chars with numeric meaning, "0" = 0, "1" = 1, ... ":" = 10, etc. (See ASCII table.) Says how many letters to strip from flexion. pfx [optional]: string to add before the flexion sfx [optional]: string to add after the flexion */ if (sFlex == sStem) { return "0"; } // is stem a substring of flexion? let n = sFlex.indexOf(sStem); |
︙ | ︙ |
Modified graphspell-js/tokenizer.js from [bdd895b918] to [04c83f2aa3].
1 2 3 4 5 6 7 | // JavaScript // Very simple tokenizer /*jslint esversion: 6*/ /*global require,exports*/ "use strict"; | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // JavaScript // Very simple tokenizer /*jslint esversion: 6*/ /*global require,exports*/ "use strict"; const aTkzPatterns = { // All regexps must start with ^. "default": [ [/^[ \t]+/, 'SPACE'], [/^\/(?:~|bin|boot|dev|etc|home|lib|mnt|opt|root|sbin|tmp|usr|var|Bureau|Documents|Images|Musique|Public|Téléchargements|Vidéos)(?:\/[a-zA-Zà-öÀ-Ö0-9ø-ÿØ-ßĀ-ʯfi-st_.()-]+)*/, 'FOLDERUNIX'], |
︙ | ︙ | |||
76 77 78 79 80 81 82 | yield { "sType": sType, "sValue": m[0], "nStart": i, "nEnd": i + m[0].length } } nCut = m[0].length; break; } } catch (e) { | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | yield { "sType": sType, "sValue": m[0], "nStart": i, "nEnd": i + m[0].length } } nCut = m[0].length; break; } } catch (e) { console.error(e); } } i += nCut; sText = sText.slice(nCut); } } } if (typeof(exports) !== 'undefined') { exports.Tokenizer = Tokenizer; } |
Modified js_extension/regex.js from [0c1a934c00] to [2a516ce8e2].
︙ | ︙ | |||
73 74 75 76 77 78 79 | m.start.push(iPos); m.end.push(iPos + subm.length); } } } } catch (e) { | < < < | < | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | m.start.push(iPos); m.end.push(iPos + subm.length); } } } } catch (e) { console.error(e); } return m; }; RegExp.prototype.grammalecte = true; } |