Index: gc_core/js/lang_core/gc_engine.js ================================================================== --- gc_core/js/lang_core/gc_engine.js +++ gc_core/js/lang_core/gc_engine.js @@ -321,11 +321,11 @@ load: function (sContext="JavaScript", sPath="") { try { if (typeof(require) !== 'undefined') { var spellchecker = require("resource://grammalecte/graphspell/spellchecker.js"); - _oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_filename}.json"); + _oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_personal_filename_js}"); } else { _oSpellChecker = new SpellChecker("${lang}", sPath, "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_personal_filename_js}"); } _sAppContext = sContext; _dOptions = gc_options.getOptions(sContext).gl_shallowCopy(); // duplication necessary, to be able to reset to default Index: gc_lang/fr/build.py ================================================================== --- gc_lang/fr/build.py +++ gc_lang/fr/build.py @@ -77,11 +77,11 @@ "create extension for Thunderbird" print("Building extension for Thunderbird") sExtensionName = dVars['tb_identifier'] + "-v" + dVars['version'] + '.xpi' spfZip = "_build/" + sExtensionName hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED) - _copyGrammalecteJSPackageInZipFile(hZip, spLangPack, dVars['dic_filename']+".json") + _copyGrammalecteJSPackageInZipFile(hZip, spLangPack) for spf in ["LICENSE.txt", "LICENSE.fr.txt"]: hZip.write(spf) dVars = _createOptionsForThunderbird(dVars) helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/tb", "", dVars, True) spDict = "gc_lang/"+sLang+"/xpi/data/dictionaries" @@ -108,16 +108,18 @@ for sLang in dVars['dOptLabel'].keys(): dVars['gc_options_labels_'+sLang] = "\n".join( [ "' for sOpt in dVars['dOptLabel'][sLang] ] ) return dVars -def _copyGrammalecteJSPackageInZipFile (hZip, spLangPack, sDicName, sAddPath=""): +def _copyGrammalecteJSPackageInZipFile (hZip, spLangPack, sAddPath=""): for sf in os.listdir("grammalecte-js"): if not os.path.isdir("grammalecte-js/"+sf): hZip.write("grammalecte-js/"+sf, sAddPath+"grammalecte-js/"+sf) for sf in os.listdir("grammalecte-js/graphspell"): if not os.path.isdir("grammalecte-js/graphspell/"+sf): hZip.write("grammalecte-js/graphspell/"+sf, sAddPath+"grammalecte-js/graphspell/"+sf) - hZip.write("grammalecte-js/graphspell/_dictionaries/"+sDicName, sAddPath+"grammalecte-js/graphspell/_dictionaries/"+sDicName) + for sf in os.listdir("grammalecte-js/graphspell/_dictionaries"): + if not os.path.isdir("grammalecte-js/graphspell/_dictionaries/"+sf): + hZip.write("grammalecte-js/graphspell/_dictionaries/"+sf, sAddPath+"grammalecte-js/graphspell/_dictionaries/"+sf) for sf in os.listdir(spLangPack): if not os.path.isdir(spLangPack+"/"+sf): hZip.write(spLangPack+"/"+sf, sAddPath+spLangPack+"/"+sf) Index: gc_lang/fr/tb/worker/gce_worker.js ================================================================== --- gc_lang/fr/tb/worker/gce_worker.js +++ gc_lang/fr/tb/worker/gce_worker.js @@ -49,11 +49,11 @@ let tkz = null; // module: tokenizer let lxg = null; // module: lexicographer let helpers = null; let oTokenizer = null; -let oDict = null; +let oSpellChecker = null; let oLxg = null; function loadGrammarChecker (sGCOptions="", sContext="JavaScript") { if (gce === null) { try { @@ -63,11 +63,11 @@ tkz = require("resource://grammalecte/graphspell/tokenizer.js"); //lxg = require("resource://grammalecte/fr/lexicographe.js"); oTokenizer = new tkz.Tokenizer("fr"); //helpers.setLogOutput(worker.log); gce.load(sContext); - oDict = gce.getDictionary(); + oSpellChecker = gce.getSpellChecker(); if (sGCOptions !== "") { gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); } // we always retrieve options from the gce, for setOptions filters obsolete options return gce.getOptions().gl_toString(); @@ -83,11 +83,11 @@ return JSON.stringify(aGrammErr); } function parseAndSpellcheck (sText, sCountry, bDebug, bContext) { let aGrammErr = gce.parse(sText, sCountry, bDebug, bContext); - let aSpellErr = oTokenizer.getSpellingErrors(sText, oDict); + let aSpellErr = oTokenizer.getSpellingErrors(sText, oSpellChecker); return JSON.stringify({ aGrammErr: aGrammErr, aSpellErr: aSpellErr }); } function getOptions () { return gce.getOptions().gl_toString(); @@ -111,11 +111,11 @@ gce.resetOptions(); return gce.getOptions().gl_toString(); } function fullTests (sGCOptions="") { - if (!gce || !oDict) { + if (!gce || !oSpellChecker) { return "# Error: grammar checker or dictionary not loaded." } let dMemoOptions = gce.getOptions(); if (sGCOptions) { gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); Index: graphspell-js/ibdawg.js ================================================================== --- graphspell-js/ibdawg.js +++ graphspell-js/ibdawg.js @@ -120,11 +120,11 @@ /* end of bug workaround */ if (!this.sHeader.startsWith("/pyfsa/")) { throw TypeError("# Error. Not a pyfsa binary dictionary. Header: " + this.sHeader); } - if (!(this.nCompressionMethod == "1" || this.nCompressionMethod == "2" || this.nCompressionMethod == "3")) { + if (!(this.nCompressionMethod == 1 || this.nCompressionMethod == 2 || this.nCompressionMethod == 3)) { 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(); Index: graphspell-js/spellchecker.js ================================================================== --- graphspell-js/spellchecker.js +++ graphspell-js/spellchecker.js @@ -25,24 +25,24 @@ ]); class SpellChecker { - constructor (sLangCode, sPath="", mainDic=null, extentedDic=null, personalDic=null) { + constructor (sLangCode, sPath="", mainDic="", extentedDic="", personalDic="") { // returns true if the main dictionary is loaded this.sLangCode = sLangCode; - if (mainDic === null) { + if (!mainDic) { mainDic = dDefaultDictionaries.gl_get(sLangCode, ""); } this.oMainDic = this._loadDictionary(mainDic, sPath, true); this.oExtendedDic = this._loadDictionary(extentedDic, sPath); this.oPersonalDic = this._loadDictionary(personalDic, sPath); } _loadDictionary (dictionary, sPath, bNecessary=false) { // returns an IBDAWG object - if (dictionary === null) { + if (!dictionary) { return null; } try { if (typeof(require) !== 'undefined') { return new ibdawg.IBDAWG(dictionary); // dictionary can be a filename or a JSON object @@ -157,7 +157,7 @@ } } } if (typeof(exports) !== 'undefined') { - exports.Spellchecker = Spellchecker; + exports.SpellChecker = SpellChecker; } Index: graphspell-js/str_transform.js ================================================================== --- graphspell-js/str_transform.js +++ graphspell-js/str_transform.js @@ -211,8 +211,8 @@ } }; if (typeof(exports) !== 'undefined') { - exports.getStemFromSuffixCode = str_transform.getStemFromSuffixCode; - exports.getStemFromAffixCode = str_transform.getStemFromAffixCode; + exports.changeWordWithSuffixCode = str_transform.changeWordWithSuffixCode; + exports.changeWordWithAffixCode = str_transform.changeWordWithAffixCode; }