Index: graphspell-js/spellchecker.js ================================================================== --- graphspell-js/spellchecker.js +++ graphspell-js/spellchecker.js @@ -23,17 +23,15 @@ ["fr", "fr.json"], ["en", "en.json"] ]); -class Spellchecker { +class SpellChecker { - constructor (sLangCode, mainDic=null, extentedDic=null, personalDic=null, sPath="") { + constructor (sLangCode, sPath="", mainDic=null, extentedDic=null, personalDic=null) { // returns true if the main dictionary is loaded this.sLangCode = sLangCode; - console.log(sLangCode); - console.log(mainDic); if (mainDic === null) { mainDic = dDefaultDictionaries.gl_get(sLangCode, ""); } this.oMainDic = this._loadDictionary(mainDic, sPath, true); this.oExtendedDic = this._loadDictionary(extentedDic, sPath); @@ -44,23 +42,21 @@ // returns an IBDAWG object if (dictionary === null) { return null; } try { - if (typeof(require) !== 'undefined') { - console.log(">>>> "); + if (typeof(require) !== 'undefined') { return new ibdawg.IBDAWG(dictionary); // dictionary can be a filename or a JSON object } else { - console.log(">>>> no "); return new IBDAWG(dictionary, sPath); // dictionary can be a filename or a JSON object } } catch (e) { - if (bNecessary) { - throw e.message; - } console.log(e.message); + if (bNecessary) { + throw e.message; + } return null; } } setMainDictionary (dictionary) { @@ -97,44 +93,44 @@ return false; } isValid (sWord) { // checks if sWord is valid (different casing tested if the first letter is a capital) - if (this.oMainDic.isValid(sToken)) { + if (this.oMainDic.isValid(sWord)) { return true; } - if (this.oExtendedDic && this.oExtendedDic.isValid(sToken)) { + if (this.oExtendedDic && this.oExtendedDic.isValid(sWord)) { return true; } - if (this.oPersonalDic && this.oPersonalDic.isValid(sToken)) { + if (this.oPersonalDic && this.oPersonalDic.isValid(sWord)) { return true; } return false; } lookup (sWord) { // checks if sWord is in dictionary as is (strict verification) - if (this.oMainDic.lookup(sToken)) { + if (this.oMainDic.lookup(sWord)) { return true; } - if (this.oExtendedDic && this.oExtendedDic.lookup(sToken)) { + if (this.oExtendedDic && this.oExtendedDic.lookup(sWord)) { return true; } - if (this.oPersonalDic && this.oPersonalDic.lookup(sToken)) { + if (this.oPersonalDic && this.oPersonalDic.lookup(sWord)) { return true; } return false; } getMorph (sWord) { // retrieves morphologies list, different casing allowed - let lResult = this.oMainDic.getMorph(sToken); + let lResult = this.oMainDic.getMorph(sWord); if (this.oExtendedDic) { - lResult.extends(this.oExtendedDic.getMorph(sToken)); + lResult.extends(this.oExtendedDic.getMorph(sWord)); } if (this.oPersonalDic) { - lResult.extends(this.oPersonalDic.getMorph(sToken)); + lResult.extends(this.oPersonalDic.getMorph(sWord)); } return lResult; } * suggest (sWord, nSuggLimit=10) {