Index: graphspell-js/ibdawg.js ================================================================== --- graphspell-js/ibdawg.js +++ graphspell-js/ibdawg.js @@ -138,10 +138,11 @@ } // to get the value of an arc, to get the char of an arc with its value this.dChar = helpers.objectToMap(this.dChar); this.dCharVal = this.dChar.gl_reverse(); this.a2grams = new Set(this.l2grams); + //console.log(this.l2grams); if (this.cStemming == "S") { this.funcStemming = str_transform.changeWordWithSuffixCode; } else if (this.cStemming == "A") { this.funcStemming = str_transform.changeWordWithAffixCode; @@ -311,10 +312,11 @@ return l; } suggest (sWord, nSuggLimit=10) { // returns a array of suggestions for + //const t0 = Date.now(); sWord = char_player.spellingNormalization(sWord) let sPfx = ""; let sSfx = ""; [sPfx, sWord, sSfx] = char_player.cut(sWord); let nMaxSwitch = Math.max(Math.floor(sWord.length / 3), 1); @@ -326,10 +328,12 @@ let aSugg = oSuggResult.getSuggestions(nSuggLimit); if (sSfx || sPfx) { // we add what we removed return aSugg.map( (sSugg) => { return sPfx + sSugg + sSfx } ); } + //const t1 = Date.now(); + //console.log("Suggestions for " + sWord + " in " + ((t1-t0)/1000).toString() + " s"); return aSugg; } _suggest (oSuggResult, sRemain, nMaxSwitch=0, nMaxDel=0, nMaxHardRepl=0, nMaxJump=0, nDist=0, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=false) { // returns a set of suggestions @@ -402,11 +406,12 @@ isNgramsOK (sChars) { if (sChars.length != 2) { return true; } - return this.a2grams.has(sChars); + return this.a2grams.has(sChars); //slower than indexOf in an Array? + //return this.l2grams.indexOf(sChars) !== false; } * _getCharArcs (iAddr) { // generator: yield all chars and addresses from node at address for (let [nVal, jAddr] of this._getArcs(iAddr)) {