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 @@ -37,10 +37,11 @@ // data let _sAppContext = ""; // what software is running let _dOptions = null; let _aIgnoredRules = new Set(); let _oDict = null; +let _oSpellChecker = null; let _dAnalyses = new Map(); // cache for data from dictionary var gc_engine = { @@ -320,14 +321,19 @@ //// Initialization load: function (sContext="JavaScript", sPath="") { try { if (typeof(require) !== 'undefined') { - var ibdawg = require("resource://grammalecte/graphspell/ibdawg.js"); - _oDict = new ibdawg.IBDAWG("${dic_filename}.json"); + //var ibdawg = require("resource://grammalecte/graphspell/ibdawg.js"); + //_oDict = new ibdawg.IBDAWG("${dic_filename}.json"); + console.log(""); + var spellchecker = require("resource://grammalecte/graphspell/spellchecker.js"); + _oSpellChecker = new spellchecker.Spellchecker("${lang}", "${dic_filename}.json"); } else { - _oDict = new IBDAWG("${dic_filename}.json", sPath); + //_oDict = new IBDAWG("${dic_filename}.json", sPath); + console.log("no "); + _oSpellChecker = new Spellchecker("${lang}", "${dic_filename}.json", sPath); } _sAppContext = sContext; _dOptions = gc_options.getOptions(sContext).gl_shallowCopy(); // duplication necessary, to be able to reset to default } catch (e) { @@ -334,11 +340,11 @@ helpers.logerror(e); } }, getDictionary: function () { - return _oDict; + return _oSpellChecker; }, //// Options setOption: function (sOpt, bVal) { @@ -388,13 +394,13 @@ helpers.echo("FSA: " + _dAnalyses.get(aWord[1])); return true; } function _storeMorphFromFSA (sWord) { - // retrieves morphologies list from _oDict -> _dAnalyses - //helpers.echo("register: "+sWord + " " + _oDict.getMorph(sWord).toString()) - _dAnalyses.set(sWord, _oDict.getMorph(sWord)); + // retrieves morphologies list from _oSpellChecker -> _dAnalyses + //helpers.echo("register: "+sWord + " " + _oSpellChecker.getMorph(sWord).toString()) + _dAnalyses.set(sWord, _oSpellChecker.getMorph(sWord)); return !!_dAnalyses.get(sWord); } function morph (dDA, aWord, sPattern, bStrict=true, bNoWord=false) { // analyse a tuple (position, word), return true if sPattern in morphologies (disambiguation on) Index: gc_lang/fr/webext/gce_worker.js ================================================================== --- gc_lang/fr/webext/gce_worker.js +++ gc_lang/fr/webext/gce_worker.js @@ -34,10 +34,11 @@ importScripts("grammalecte/graphspell/helpers.js"); importScripts("grammalecte/graphspell/str_transform.js"); importScripts("grammalecte/graphspell/char_player.js"); importScripts("grammalecte/graphspell/ibdawg.js"); +importScripts("grammalecte/graphspell/spellchecker.js"); importScripts("grammalecte/text.js"); importScripts("grammalecte/graphspell/tokenizer.js"); importScripts("grammalecte/fr/conj.js"); importScripts("grammalecte/fr/mfsp.js"); importScripts("grammalecte/fr/phonet.js");