Overview
Comment: | Some change to javascript to work in node |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | graphspell | njs | nodejs |
Files: | files | file ages | folders |
SHA3-256: |
a3687f4fd354247fe5fde6cd76eeaefc |
User & Date: | IllusionPerdu on 2018-10-10 09:19:04 |
Other Links: | branch diff | manifest | tags |
Context
2018-10-10
| ||
09:36 | Minimal file to use in node check-in: b79bb889b9 user: IllusionPerdu tags: graphspell, njs, nodejs | |
09:19 | Some change to javascript to work in node check-in: a3687f4fd3 user: IllusionPerdu tags: graphspell, njs, nodejs | |
2018-10-09
| ||
11:07 | [graphspell][js] useless comments check-in: 4d2953e2f6 user: olr tags: trunk, graphspell | |
Changes
Modified graphspell-js/char_player.js from [626d7d161b] to [27827e9132].
1 2 3 4 5 6 7 8 9 10 | 1 2 3 4 5 6 7 8 9 10 11 12 13 | + + + | // list of similar chars // useful for suggestion mechanism /* jshint esversion:6 */ /* jslint esversion:6 */ ${map} var char_player = { _xTransCharsForSpelling: new Map([ ['ſ', 's'], ['ffi', 'ffi'], ['ffl', 'ffl'], ['ff', 'ff'], ['ſt', 'ft'], ['fi', 'fi'], ['fl', 'fl'], ['st', 'st'] |
︙ | |||
21 22 23 24 25 26 27 | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | - + | _xTransCharsForSimplification: new Map([ ['à', 'a'], ['é', 'e'], ['î', 'i'], ['ô', 'o'], ['û', 'u'], ['ÿ', 'i'], ['y', 'i'], ['â', 'a'], ['è', 'e'], ['ï', 'i'], ['ö', 'o'], ['ù', 'u'], ['ŷ', 'i'], ['ä', 'a'], ['ê', 'e'], ['í', 'i'], ['ó', 'o'], ['ü', 'u'], ['ý', 'i'], ['á', 'a'], ['ë', 'e'], ['ì', 'i'], ['ò', 'o'], ['ú', 'u'], ['ỳ', 'i'], ['ā', 'a'], ['ē', 'e'], ['ī', 'i'], ['ō', 'o'], ['ū', 'u'], ['ȳ', 'i'], ['ç', 'c'], ['ñ', 'n'], ['k', 'q'], ['w', 'v'], |
︙ | |||
100 101 102 103 104 105 106 | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | - + | ["Ë", "EeÉéÈèÊêËëĒēŒœ"], ["f", "fF"], ["F", "Ff"], ["g", "gGjJĵĴ"], ["G", "GgJjĴĵ"], |
︙ | |||
378 379 380 381 382 383 384 | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | - + - + | }, // Other functions filterSugg: function (aSugg) { return aSugg.filter((sSugg) => { return !sSugg.endsWith("è") && !sSugg.endsWith("È"); }); } |
︙ |
Modified graphspell-js/dawg.js from [d94e6b7163] to [56edbc7aa3].
1 2 3 4 5 6 7 8 9 10 11 12 | 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 27 28 | + + + + - - - + + + + - | // JavaScript // FSA DICTIONARY BUILDER // // by Olivier R. // License: MPL 2 // // This tool encodes lexicon into an indexable binary dictionary // Input files MUST be encoded in UTF-8. /* jshint esversion:6, -W097 */ /* jslint esversion:6 */ /* global require, exports, console, helpers */ "use strict"; |
︙ | |||
96 97 98 99 100 101 102 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | - + | let lWord = []; for (let [sFlex, iAff, iTag] of lEntry) { let lTemp = []; for (let c of sFlex) { lTemp.push(dChar.get(c)); } lTemp.push(iAff+nChar); |
︙ | |||
426 427 428 429 430 431 432 | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | - + | this.nNextId += 1; return this.nNextId-1; }, reset: function () { this.nNextId = 0; } |
︙ | |||
540 541 542 543 544 545 546 | 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | - + | convValueToHexString (nVal, nByte) { // nVal: value to convert, nByte: number of bytes let sHexVal = nVal.toString(16); // conversion to hexadecimal string //console.log(`value: ${nVal} in ${nByte} bytes`); if (sHexVal.length < (nByte*2)) { return "0".repeat((nByte*2) - sHexVal.length) + sHexVal; } else if (sHexVal.length == (nByte*2)) { |
︙ |
Modified graphspell-js/helpers.js from [6ccb02c60d] to [2ed0ee7e88].
| 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | - + + - - + + + + + + + - - - - - - - + + + + + + + + |
|
︙ | |||
57 58 59 60 61 62 63 | 64 65 66 67 68 69 70 71 72 73 74 75 76 | - + | obj[k] = v; } return obj; } }; |
Modified graphspell-js/ibdawg.js from [26e5034903] to [ad47fc175d].
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | - - - + + + + + - - - - - + + + + + + + + - |
|
︙ | |||
219 220 221 222 223 224 225 | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | - + | "l2grams": this.l2grams }; return oJSON; } isValidToken (sToken) { // checks if sToken is valid (if there is hyphens in sToken, sToken is split, each part is checked) |
︙ | |||
296 297 298 299 300 301 302 | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | - + - - + + - + - - + | } } return Boolean(this._convBytesToInteger(this.byDic.slice(iAddr, iAddr+this.nBytesArc)) & this._finalNodeMask); } getMorph (sWord) { // retrieves morphologies list, different casing allowed |
︙ | |||
587 588 589 590 591 592 593 | 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | - + | } iAddr = iEndArcAddr + this.nBytesNodeAddress; } } } * _getArcs1 (iAddr) { |
︙ | |||
628 629 630 631 632 633 634 | 631 632 633 634 635 636 637 638 639 640 | - + | _lookupArcNode3 (nVal, iAddr) { // to do } } |
Modified graphspell-js/spellchecker.js from [b26374afa0] to [6b69161b99].
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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 27 28 29 30 | + + + - - - - + + + + + + - | // Spellchecker // Wrapper for the IBDAWG class. // Useful to check several dictionaries at once. // To avoid iterating over a pile of dictionaries, it is assumed that 3 are enough: // - the main dictionary, bundled with the package // - the extended dictionary // - the community dictionary, added by an organization // - the personal dictionary, created by the user for its own convenience /* jshint esversion:6, -W097 */ /* jslint esversion:6 */ /* global require, exports, console, IBDAWG, Tokenizer */ "use strict"; |
︙ | |||
62 63 64 65 66 67 68 | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | - + | } } catch (e) { let sfDictionary = (typeof(dictionary) == "string") ? dictionary : dictionary.sLangName + "/" + dictionary.sFileName; if (bNecessary) { throw "Error: <" + sfDictionary + "> not loaded. " + e.message; } |
︙ | |||
193 194 195 196 197 198 199 | 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 222 223 224 225 226 227 228 | - + - + | // checks if sWord is valid (different casing tested if the first letter is a capital) if (this.oMainDic.isValid(sWord)) { return true; } if (this.bExtendedDic && this.oExtendedDic.isValid(sWord)) { return true; } |
︙ | |||
269 270 271 272 273 274 275 | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | - + | if (this.bPersonalDic) { yield this.oPersonalDic.suggest(sWord, nSuggLimit); } } * select (sFlexPattern="", sTagsPattern="") { // generator: returns all entries which flexion fits <sFlexPattern> and morphology fits <sTagsPattern> |
︙ | |||
297 298 299 300 301 302 303 | 301 302 303 304 305 306 307 308 309 310 | - + | if (this.bPersonalDic) { lResult.push(...this.oPersonalDic.getSimilarEntries(sWord, nSuggLimit)); } return lResult; } } |
Modified graphspell-js/str_transform.js from [63ae767339] to [2ff1a56a97].
| 1 2 3 4 5 6 7 8 9 10 11 12 | - - + + + + + |
|
︙ | |||
216 217 218 219 220 221 222 | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | - + | let [sPfxCode, sSfxCode] = sAffCode.split('/'); sWord = sPfxCode.slice(1) + sWord.slice(sPfxCode.charCodeAt(0)-48); return sSfxCode[0] == '0' ? sWord + sSfxCode.slice(1) : sWord.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1); } }; |
Modified graphspell-js/tokenizer.js from [88bacac87d] to [541689c69f].
1 2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 | + + - - + + | // JavaScript // Very simple tokenizer /* jshint esversion:6, -W097 */ |
︙ | |||
68 69 70 71 72 73 74 | 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 | - + - + | while (sText) { let iCut = 1; for (let [zRegex, sType] of this.aRules) { if (sType !== "SPACE" || bWithSpaces) { try { if ((m = zRegex.exec(sText)) !== null) { iToken += 1; |