Index: graphspell-js/ibdawg.js ================================================================== --- graphspell-js/ibdawg.js +++ graphspell-js/ibdawg.js @@ -146,11 +146,11 @@ throw RangeError("# Error. Unknown dictionary compression method: " + this.nCompressionMethod); } // 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); + this.a2grams = (this.l2grams) ? new Set(this.l2grams) : null; if (this.cStemming == "S") { this.funcStemming = str_transform.changeWordWithSuffixCode; } else if (this.cStemming == "A") { this.funcStemming = str_transform.changeWordWithAffixCode; @@ -412,10 +412,13 @@ } isNgramsOK (sChars) { if (sChars.length != 2) { return true; + } + if (!this.a2grams) { + return true; } return this.a2grams.has(sChars); } * _getCharArcs (iAddr) { Index: graphspell/ibdawg.py ================================================================== --- graphspell/ibdawg.py +++ graphspell/ibdawg.py @@ -188,11 +188,11 @@ def _initJSON (self, oJSON): "initialize with a JSON text file" self.__dict__.update(oJSON) self.byDic = binascii.unhexlify(self.sByDic) self.dCharVal = { v: k for k, v in self.dChar.items() } - self.a2grams = set(self.l2grams) + self.a2grams = set(self.l2grams) if hasattr(self, 'l2grams') else None def getInfo (self): "return string about the IBDAWG" return " Language: {0.sLangName} Lang code: {0.sLangCode} Dictionary name: {0.sDicName}" \ " Compression method: {0.nCompressionMethod:>2} Date: {0.sDate} Stemming: {0.cStemming}FX\n" \ @@ -356,10 +356,12 @@ for sRepl in cp.dFinal1.get(sRemain, ()): self._suggest(oSuggResult, sRepl, nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump, nDist, nDeep+1, iAddr, sNewWord, True) def isNgramsOK (self, sChars): if len(sChars) != 2: + return True + if not self.a2grams: return True return sChars in self.a2grams #@timethis def suggest2 (self, sWord, nSuggLimit=10):