@@ -39,12 +39,13 @@ 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); } - + // 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.byDic = new Uint8Array(this.byDic); // not quicker, even slower if (this.cStemming == "S") { this.funcStemming = str_transform.getStemFromSuffixCode; } else if (this.cStemming == "A") { @@ -265,14 +266,14 @@ // return a list of suffixes ending at a distance of from 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.dChar.get(nVal)); + aTails.add(sTail + this.dCharVal.get(nVal)); } if (n && aTails.size == 0) { - aTails.gl_update(this._getTails(jAddr, sTail+this.dChar.get(nVal), n-1)); + aTails.gl_update(this._getTails(jAddr, sTail+this.dCharVal.get(nVal), n-1)); } } } return aTails; } @@ -295,12 +296,12 @@ } * _getSimilarArcsAndCrushedChars (cChar, iAddr) { // generator: yield similar char of and address of the following node for (let [nVal, jAddr] of this._getArcs(iAddr)) { - if (this.dChar.get(nVal, null) in char_player.aVovels) { - yield [this.dChar[nVal], jAddr]; + if (this.dCharVal.get(nVal, null) in char_player.aVovels) { + yield [this.dCharVal[nVal], jAddr]; } } yield* this._getSimilarArcs(cChar, iAddr); }