Overview
Comment: | [core][js] fix spell suggestion engine |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | core |
Files: | files | file ages | folders |
SHA3-256: |
4b57907a818e5b677a5550ddf81c7672 |
User & Date: | olr on 2017-09-15 10:01:02 |
Original Comment: | [core][js] fx spell suggestion engine |
Other Links: | manifest | tags |
Context
2017-09-15
| ||
13:12 | [core][js] fix Damerau-Levenshtein distance check-in: 4486055937 user: olr tags: trunk, core | |
10:01 | [core][js] fix spell suggestion engine check-in: 4b57907a81 user: olr tags: trunk, core | |
08:16 | [core][fx] ibdawg: fix bugs, WebExt: retrieve spelling suggestion check-in: d7eb5a15ee user: olr tags: trunk, core, fx | |
Changes
Modified gc_core/js/ibdawg.js from [8b27735529] to [da811a4bb4].
︙ | ︙ | |||
37 38 39 40 41 42 43 | */ if (!this.sHeader.startsWith("/pyfsa/")) { throw TypeError("# Error. Not a pyfsa binary dictionary. Header: " + this.sHeader); } if (!(this.nVersion == "1" || this.nVersion == "2" || this.nVersion == "3")) { throw RangeError("# Error. Unknown dictionary version: " + this.nVersion); } | | > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | */ if (!this.sHeader.startsWith("/pyfsa/")) { throw TypeError("# Error. Not a pyfsa binary dictionary. Header: " + this.sHeader); } if (!(this.nVersion == "1" || this.nVersion == "2" || this.nVersion == "3")) { throw RangeError("# Error. Unknown dictionary version: " + this.nVersion); } // <dChar> to get the value of an arc, <dCharVal> to get the char of an arc with its value this.dChar = helpers.objectToMap(this.dChar); this.dCharVal = this.dChar.gl_reverse(); //this.byDic = new Uint8Array(this.byDic); // not quicker, even slower if (this.cStemming == "S") { this.funcStemming = str_transform.getStemFromSuffixCode; } else if (this.cStemming == "A") { this.funcStemming = str_transform.getStemFromAffixCode; } else { |
︙ | ︙ | |||
263 264 265 266 267 268 269 | _getTails (iAddr, sTail="", n=2) { // return a list of suffixes ending at a distance of <n> from <iAddr> let aTails = new Set(); for (let [nVal, jAddr] of this._getArcs(iAddr)) { if (nVal < this.nChar) { if (this._convBytesToInteger(this.byDic.slice(jAddr, jAddr+this.nBytesArc)) & this._finalNodeMask) { | | | | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | _getTails (iAddr, sTail="", n=2) { // return a list of suffixes ending at a distance of <n> from <iAddr> let aTails = new Set(); for (let [nVal, jAddr] of this._getArcs(iAddr)) { if (nVal < this.nChar) { if (this._convBytesToInteger(this.byDic.slice(jAddr, jAddr+this.nBytesArc)) & this._finalNodeMask) { aTails.add(sTail + this.dCharVal.get(nVal)); } if (n && aTails.size == 0) { aTails.gl_update(this._getTails(jAddr, sTail+this.dCharVal.get(nVal), n-1)); } } } return aTails; } _suggestWithCrushedUselessChars (sWord, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=false) { |
︙ | ︙ | |||
293 294 295 296 297 298 299 | } return aSugg; } * _getSimilarArcsAndCrushedChars (cChar, iAddr) { // generator: yield similar char of <cChar> and address of the following node for (let [nVal, jAddr] of this._getArcs(iAddr)) { | | | | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | } return aSugg; } * _getSimilarArcsAndCrushedChars (cChar, iAddr) { // generator: yield similar char of <cChar> and address of the following node for (let [nVal, jAddr] of this._getArcs(iAddr)) { if (this.dCharVal.get(nVal, null) in char_player.aVovels) { yield [this.dCharVal[nVal], jAddr]; } } yield* this._getSimilarArcs(cChar, iAddr); } // morph (sWord) { // is defined in constructor |
︙ | ︙ |
Modified gc_core/js/jsex_map.js from [3dc39be41a] to [640f46f082].
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 | Map.prototype.gl_updateOnlyExistingKeys = function (dDict) { for (let [k, v] of dDict.entries()) { if (this.has(k)){ this.set(k, v); } } }; Map.prototype.grammalecte = true; } | > > > > > > > > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | Map.prototype.gl_updateOnlyExistingKeys = function (dDict) { for (let [k, v] of dDict.entries()) { if (this.has(k)){ this.set(k, v); } } }; Map.prototype.gl_reverse = function () { let dNewMap = new Map(); this.forEach((val, key) => { dNewMap.set(val, key); }); return dNewMap; }; Map.prototype.grammalecte = true; } |
Modified gc_lang/fr/webext/gce_worker.js from [5edde2a5fd] to [ad4b1695da].
︙ | ︙ | |||
284 285 286 287 288 289 290 | function getSpellSuggestions (sWord, dInfo) { if (!oDict) { postMessage(createResponse("getSpellSuggestions", "# Error. Dictionary not loaded.", dInfo, true)); return; } let aSugg = oDict.suggest(sWord); | < | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | function getSpellSuggestions (sWord, dInfo) { if (!oDict) { postMessage(createResponse("getSpellSuggestions", "# Error. Dictionary not loaded.", dInfo, true)); return; } let aSugg = oDict.suggest(sWord); postMessage(createResponse("getSpellSuggestions", {sWord: sWord, aSugg: aSugg}, dInfo, true)); } // Lexicographer function getListOfTokens (sText, dInfo={}) { |
︙ | ︙ |