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 @@ -66,16 +66,16 @@ load: function (sContext="JavaScript", sColorType="aRGB", sPath="") { try { if(typeof(process) !== 'undefined') { var spellchecker = require("../graphspell/spellchecker.js"); - _oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}"); + _oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_main_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}"); } else if (typeof(require) !== 'undefined') { var spellchecker = require("resource://grammalecte/graphspell/spellchecker.js"); - _oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}"); + _oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_main_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}"); } else { - _oSpellChecker = new SpellChecker("${lang}", sPath, "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}"); + _oSpellChecker = new SpellChecker("${lang}", sPath, "${dic_main_filename_js}", "${dic_community_filename_js}", "${dic_personal_filename_js}"); } _sAppContext = sContext; _dOptions = gc_options.getOptions(sContext).gl_shallowCopy(); // duplication necessary, to be able to reset to default _dOptionsColors = gc_options.getOptionsColors(sContext, sColorType); _oTokenizer = _oSpellChecker.getTokenizer(); Index: gc_core/py/lang_core/gc_engine.py ================================================================== --- gc_core/py/lang_core/gc_engine.py +++ gc_core/py/lang_core/gc_engine.py @@ -60,11 +60,11 @@ global _sAppContext global _dOptions global _dOptionsColors global _oTokenizer try: - _oSpellChecker = SpellChecker("${lang}", "${dic_main_filename_py}", "${dic_extended_filename_py}", "${dic_community_filename_py}", "${dic_personal_filename_py}") + _oSpellChecker = SpellChecker("${lang}", "${dic_main_filename_py}", "${dic_community_filename_py}", "${dic_personal_filename_py}") _sAppContext = sContext _dOptions = dict(gc_options.getOptions(sContext)) # duplication necessary, to be able to reset to default _dOptionsColors = gc_options.getOptionsColors(sContext, sColorType) _oTokenizer = _oSpellChecker.getTokenizer() _oSpellChecker.activateStorage() Index: gc_lang/fr/config.ini ================================================================== --- gc_lang/fr/config.ini +++ gc_lang/fr/config.ini @@ -20,15 +20,10 @@ dic_name = fr-allvars,fr-classic,fr-reform dic_description = Français (Toutes variantes),Français (Classique),Français (Réforme 1990) dic_filter = ,[*CMPX]$,[*RPX]$ dic_default_filename_py = fr-allvars dic_default_filename_js = fr-allvars -# extended dictionary -lexicon_extended_src = lexicons/French.extended.lex -dic_extended_filename = fr.extended -dic_extended_name = fr.extended -dic_extended_description = Français - dictionnaire étendu # community dictionary lexicon_community_src = lexicons/French.community.lex dic_community_filename = fr.community dic_community_name = fr.community dic_community_description = Français - dictionnaire communautaire Index: gc_lang/fr/oxt/Graphspell.py ================================================================== --- gc_lang/fr/oxt/Graphspell.py +++ gc_lang/fr/oxt/Graphspell.py @@ -64,17 +64,17 @@ try: personal_dic = json.loads(sPersonalDicJSON) except: print("Graphspell: wrong personal_dic") traceback.print_exc() - self.oGraphspell = SpellChecker("fr", "fr-"+sMainDicName+".bdic", "", "", personal_dic) + self.oGraphspell = SpellChecker("fr", "fr-"+sMainDicName+".bdic", "", personal_dic) self.loadHunspell() # print("Graphspell: init done") except: print("Graphspell: init failed") traceback.print_exc() - + def loadHunspell (self): # Hunspell is a fallback spellchecker try: self.xHunspell = self.xSvMgr.createInstance("org.openoffice.lingu.MySpellSpellChecker") except: @@ -106,14 +106,14 @@ return True for e in self.locales: if aLocale.Language == e.Language and (e.Country == aLocale.Country or e.Country == ""): return True return False - + def getLocales (self): return self.locales - + # XSpellChecker # http://www.openoffice.org/api/docs/common/ref/com/sun/star/linguistic2/XSpellChecker.html def isValid (self, aWord, rLocale, aProperties): try: aWord = zElidedWords.sub("", aWord.rstrip("."), count=1) @@ -155,41 +155,41 @@ # print("Spell checker: %s" % xSpellChecker) # break class SpellAlternatives (unohelper.Base, XSpellAlternatives): - + def __init__ (self, sWord, lSugg): try: self.sWord = sWord self.lSugg = lSugg self.xLocale = Locale('fr', 'FR', '') except: traceback.print_exc() - + # XSpellAlternatives # http://www.openoffice.org/api/docs/common/ref/com/sun/star/linguistic2/XSpellAlternatives.html def getWord (self): return self.sWord - + def getLocale (self): return self.xLocale - + def getFailureType (self): return 4 # IS_NEGATIVE_WORD = 2 # The word is a negative one, that is, it should not be used. # CAPTION_ERROR = 3 # The capitalization of the word is wrong. # SPELLING_ERROR = 4 # The spelling of the word is wrong (or at least not known to be correct). # No difference -> red underline - + def getAlternativesCount (self): return len(self.lSugg) - + def getAlternatives (self): return self.lSugg g_ImplementationHelper = unohelper.ImplementationHelper() g_ImplementationHelper.addImplementation(Graphspell, "net.grammalecte.graphspell", ("com.sun.star.linguistic2.SpellChecker",),) Index: graphspell-js/spellchecker.js ================================================================== --- graphspell-js/spellchecker.js +++ graphspell-js/spellchecker.js @@ -2,12 +2,11 @@ // Wrapper for the IBDAWG class. // Useful to check several dictionaries at once. // To avoid iterating over a pile of dictionaries, it is assumed that 3 are enough: // - the main dictionary, bundled with the package -// - the extended dictionary -// - the community dictionary, added by an organization +// - the community dictionary, a merge of different external dictionaries // - the personal dictionary, created by the user for its own convenience /* jshint esversion:6, -W097 */ /* jslint esversion:6 */ /* global require, exports, console, IBDAWG, Tokenizer */ @@ -31,21 +30,19 @@ ]); class SpellChecker { - constructor (sLangCode, sPath="", mainDic="", extentedDic="", communityDic="", personalDic="") { + constructor (sLangCode, sPath="", mainDic="", communityDic="", personalDic="") { // returns true if the main dictionary is loaded this.sLangCode = sLangCode; if (!mainDic) { mainDic = dDefaultDictionaries.gl_get(sLangCode, ""); } this.oMainDic = this._loadDictionary(mainDic, sPath, true); - this.oExtendedDic = this._loadDictionary(extentedDic, sPath); this.oCommunityDic = this._loadDictionary(communityDic, sPath); this.oPersonalDic = this._loadDictionary(personalDic, sPath); - this.bExtendedDic = Boolean(this.oExtendedDic); this.bCommunityDic = Boolean(this.oCommunityDic); this.bPersonalDic = Boolean(this.oPersonalDic); this.oTokenizer = null; // storage this.bStorage = false; @@ -95,17 +92,10 @@ // returns true if the dictionary is loaded this.oMainDic = this._loadDictionary(dictionary, sPath, true); return Boolean(this.oMainDic); } - setExtendedDictionary (dictionary, sPath="", bActivate=true) { - // returns true if the dictionary is loaded - this.oExtendedDic = this._loadDictionary(dictionary, sPath); - this.bExtendedDic = (bActivate) ? Boolean(this.oExtendedDic) : false; - return Boolean(this.oExtendedDic); - } - setCommunityDictionary (dictionary, sPath="", bActivate=true) { // returns true if the dictionary is loaded this.oCommunityDic = this._loadDictionary(dictionary, sPath); this.bCommunityDic = (bActivate) ? Boolean(this.oCommunityDic) : false; return Boolean(this.oCommunityDic); @@ -116,26 +106,18 @@ this.oPersonalDic = this._loadDictionary(dictionary, sPath); this.bPersonalDic = (bActivate) ? Boolean(this.oPersonalDic) : false; return Boolean(this.oPersonalDic); } - activateExtendedDictionary () { - this.bExtendedDic = Boolean(this.oExtendedDic); - } - activateCommunityDictionary () { this.bCommunityDic = Boolean(this.oCommunityDic); } activatePersonalDictionary () { this.bPersonalDic = Boolean(this.oPersonalDic); } - deactivateExtendedDictionary () { - this.bExtendedDic = false; - } - deactivateCommunityDictionary () { this.bCommunityDic = false; } deactivatePersonalDictionary () { @@ -179,13 +161,10 @@ isValidToken (sToken) { // checks if sToken is valid (if there is hyphens in sToken, sToken is split, each part is checked) if (this.oMainDic.isValidToken(sToken)) { return true; } - if (this.bExtendedDic && this.oExtendedDic.isValidToken(sToken)) { - return true; - } if (this.bCommunityDic && this.oCommunityDic.isValidToken(sToken)) { return true; } if (this.bPersonalDic && this.oPersonalDic.isValidToken(sToken)) { return true; @@ -196,13 +175,10 @@ isValid (sWord) { // checks if sWord is valid (different casing tested if the first letter is a capital) if (this.oMainDic.isValid(sWord)) { return true; } - if (this.bExtendedDic && this.oExtendedDic.isValid(sWord)) { - return true; - } if (this.bCommunityDic && this.oCommunityDic.isValid(sWord)) { return true; } if (this.bPersonalDic && this.oPersonalDic.isValid(sWord)) { return true; @@ -213,13 +189,10 @@ lookup (sWord) { // checks if sWord is in dictionary as is (strict verification) if (this.oMainDic.lookup(sWord)) { return true; } - if (this.bExtendedDic && this.oExtendedDic.lookup(sWord)) { - return true; - } if (this.bCommunityDic && this.oCommunityDic.lookup(sWord)) { return true; } if (this.bPersonalDic && this.oPersonalDic.lookup(sWord)) { return true; @@ -231,13 +204,10 @@ // retrieves morphologies list, different casing allowed if (this.bStorage && this._dMorphologies.has(sWord)) { return this._dMorphologies.get(sWord); } let lMorph = this.oMainDic.getMorph(sWord); - if (this.bExtendedDic) { - lMorph.push(...this.oExtendedDic.getMorph(sWord)); - } if (this.bCommunityDic) { lMorph.push(...this.oCommunityDic.getMorph(sWord)); } if (this.bPersonalDic) { lMorph.push(...this.oPersonalDic.getMorph(sWord)); @@ -262,13 +232,10 @@ } * suggest (sWord, nSuggLimit=10) { // generator: returns 1, 2 or 3 lists of suggestions yield this.oMainDic.suggest(sWord, nSuggLimit); - if (this.bExtendedDic) { - yield this.oExtendedDic.suggest(sWord, nSuggLimit); - } if (this.bCommunityDic) { yield this.oCommunityDic.suggest(sWord, nSuggLimit); } if (this.bPersonalDic) { yield this.oPersonalDic.suggest(sWord, nSuggLimit); @@ -276,13 +243,10 @@ } * select (sFlexPattern="", sTagsPattern="") { // generator: returns all entries which flexion fits and morphology fits yield* this.oMainDic.select(sFlexPattern, sTagsPattern); - if (this.bExtendedDic) { - yield* this.oExtendedDic.select(sFlexPattern, sTagsPattern); - } if (this.bCommunityDic) { yield* this.oCommunityDic.select(sFlexPattern, sTagsPattern); } if (this.bPersonalDic) { yield* this.oPersonalDic.select(sFlexPattern, sTagsPattern); @@ -290,13 +254,10 @@ } getSimilarEntries (sWord, nSuggLimit=10) { // return a list of tuples (similar word, stem, morphology) let lResult = this.oMainDic.getSimilarEntries(sWord, nSuggLimit); - if (this.bExtendedDic) { - lResult.push(...this.oExtendedDic.getSimilarEntries(sWord, nSuggLimit)); - } if (this.bCommunityDic) { lResult.push(...this.oCommunityDic.getSimilarEntries(sWord, nSuggLimit)); } if (this.bPersonalDic) { lResult.push(...this.oPersonalDic.getSimilarEntries(sWord, nSuggLimit)); Index: graphspell/spellchecker.py ================================================================== --- graphspell/spellchecker.py +++ graphspell/spellchecker.py @@ -23,20 +23,18 @@ class SpellChecker (): "SpellChecker: wrapper for the IBDAWG class" - def __init__ (self, sLangCode, sfMainDic="", sfExtendedDic="", sfCommunityDic="", sfPersonalDic=""): + def __init__ (self, sLangCode, sfMainDic="", sfCommunityDic="", sfPersonalDic=""): "returns True if the main dictionary is loaded" self.sLangCode = sLangCode if not sfMainDic: sfMainDic = dDefaultDictionaries.get(sLangCode, "") self.oMainDic = self._loadDictionary(sfMainDic, True) - self.oExtendedDic = self._loadDictionary(sfExtendedDic) self.oCommunityDic = self._loadDictionary(sfCommunityDic) self.oPersonalDic = self._loadDictionary(sfPersonalDic) - self.bExtendedDic = bool(self.oExtendedDic) self.bCommunityDic = bool(self.oCommunityDic) self.bPersonalDic = bool(self.oPersonalDic) self.oTokenizer = None # Default suggestions self.dDefaultSugg = None @@ -71,16 +69,10 @@ def setMainDictionary (self, source): "returns True if the dictionary is loaded" self.oMainDic = self._loadDictionary(source, True) return bool(self.oMainDic) - def setExtendedDictionary (self, source, bActivate=True): - "returns True if the dictionary is loaded" - self.oExtendedDic = self._loadDictionary(source) - self.bExtendedDic = False if not bActivate else bool(self.oExtendedDic) - return bool(self.oExtendedDic) - def setCommunityDictionary (self, source, bActivate=True): "returns True if the dictionary is loaded" self.oCommunityDic = self._loadDictionary(source) self.bCommunityDic = False if not bActivate else bool(self.oCommunityDic) return bool(self.oCommunityDic) @@ -89,26 +81,18 @@ "returns True if the dictionary is loaded" self.oPersonalDic = self._loadDictionary(source) self.bPersonalDic = False if not bActivate else bool(self.oPersonalDic) return bool(self.oPersonalDic) - def activateExtendedDictionary (self): - "activate extended dictionary (if available)" - self.bExtendedDic = bool(self.oExtendedDic) - def activateCommunityDictionary (self): "activate community dictionary (if available)" self.bCommunityDic = bool(self.oCommunityDic) def activatePersonalDictionary (self): "activate personal dictionary (if available)" self.bPersonalDic = bool(self.oPersonalDic) - def deactivateExtendedDictionary (self): - "deactivate extended dictionary" - self.bExtendedDic = False - def deactivateCommunityDictionary (self): "deactivate community dictionary" self.bCommunityDic = False def deactivatePersonalDictionary (self): @@ -182,12 +166,10 @@ def isValidToken (self, sToken): "checks if sToken is valid (if there is hyphens in sToken, sToken is split, each part is checked)" if self.oMainDic.isValidToken(sToken): return True - if self.bExtendedDic and self.oExtendedDic.isValidToken(sToken): - return True if self.bCommunityDic and self.oCommunityDic.isValidToken(sToken): return True if self.bPersonalDic and self.oPersonalDic.isValidToken(sToken): return True return False @@ -194,12 +176,10 @@ def isValid (self, sWord): "checks if sWord is valid (different casing tested if the first letter is a capital)" if self.oMainDic.isValid(sWord): return True - if self.bExtendedDic and self.oExtendedDic.isValid(sWord): - return True if self.bCommunityDic and self.oCommunityDic.isValid(sWord): return True if self.bPersonalDic and self.oPersonalDic.isValid(sWord): return True return False @@ -206,12 +186,10 @@ def lookup (self, sWord): "checks if sWord is in dictionary as is (strict verification)" if self.oMainDic.lookup(sWord): return True - if self.bExtendedDic and self.oExtendedDic.lookup(sWord): - return True if self.bCommunityDic and self.oCommunityDic.lookup(sWord): return True if self.bPersonalDic and self.oPersonalDic.lookup(sWord): return True return False @@ -219,12 +197,10 @@ def getMorph (self, sWord): "retrieves morphologies list, different casing allowed" if self.bStorage and sWord in self._dMorphologies: return self._dMorphologies[sWord] lMorph = self.oMainDic.getMorph(sWord) - if self.bExtendedDic: - lMorph.extend(self.oExtendedDic.getMorph(sWord)) if self.bCommunityDic: lMorph.extend(self.oCommunityDic.getMorph(sWord)) if self.bPersonalDic: lMorph.extend(self.oPersonalDic.getMorph(sWord)) if self.bStorage: @@ -250,33 +226,26 @@ yield list(map(lambda sSugg: sSugg[0:1].upper()+sSugg[1:], lRes)) else: yield self.oMainDic.suggest(sWord, nSuggLimit) else: yield self.oMainDic.suggest(sWord, nSuggLimit) - if self.bExtendedDic: - yield self.oExtendedDic.suggest(sWord, nSuggLimit) if self.bCommunityDic: yield self.oCommunityDic.suggest(sWord, nSuggLimit) if self.bPersonalDic: yield self.oPersonalDic.suggest(sWord, nSuggLimit) def select (self, sFlexPattern="", sTagsPattern=""): "generator: returns all entries which flexion fits and morphology fits " yield from self.oMainDic.select(sFlexPattern, sTagsPattern) - if self.bExtendedDic: - yield from self.oExtendedDic.select(sFlexPattern, sTagsPattern) if self.bCommunityDic: yield from self.oCommunityDic.select(sFlexPattern, sTagsPattern) if self.bPersonalDic: yield from self.oPersonalDic.select(sFlexPattern, sTagsPattern) def drawPath (self, sWord): "draw the path taken by within the word graph: display matching nodes and their arcs" self.oMainDic.drawPath(sWord) - if self.bExtendedDic: - print("-----") - self.oExtendedDic.drawPath(sWord) if self.bCommunityDic: print("-----") self.oCommunityDic.drawPath(sWord) if self.bPersonalDic: print("-----") @@ -283,12 +252,10 @@ self.oPersonalDic.drawPath(sWord) def getSimilarEntries (self, sWord, nSuggLimit=10): "return a list of tuples (similar word, stem, morphology)" lResult = self.oMainDic.getSimilarEntries(sWord, nSuggLimit) - if self.bExtendedDic: - lResult.extend(self.oExtendedDic.getSimilarEntries(sWord, nSuggLimit)) if self.bCommunityDic: lResult.extend(self.oCommunityDic.getSimilarEntries(sWord, nSuggLimit)) if self.bPersonalDic: lResult.extend(self.oPersonalDic.getSimilarEntries(sWord, nSuggLimit)) return lResult Index: make.py ================================================================== --- make.py +++ make.py @@ -309,23 +309,19 @@ if not os.path.isdir("graphspell-js/"+sf): file_util.copy_file("graphspell-js/"+sf, "grammalecte-js/graphspell") helpers.copyAndFileTemplate("graphspell-js/"+sf, "grammalecte-js/graphspell/"+sf, dVars) -def copyGraphspellDictionaries (dVars, bJavaScript=False, bExtendedDict=False, bCommunityDict=False, bPersonalDict=False): +def copyGraphspellDictionaries (dVars, bJavaScript=False, bCommunityDict=False, bPersonalDict=False): "copy requested Graphspell dictionaries in Grammalecte package" dVars["dic_main_filename_py"] = "" dVars["dic_main_filename_js"] = "" - dVars["dic_extended_filename_py"] = "" - dVars["dic_extended_filename_js"] = "" dVars["dic_community_filename_py"] = "" dVars["dic_community_filename_js"] = "" dVars["dic_personal_filename_py"] = "" dVars["dic_personal_filename_js"] = "" lDict = [ ("main", s) for s in dVars['dic_filenames'].split(",") ] - if bExtendedDict: - lDict.append(("extended", dVars['dic_extended_filename'])) if bCommunityDict: lDict.append(("community", dVars['dic_community_filename'])) if bPersonalDict: lDict.append(("personal", dVars['dic_personal_filename'])) for sType, sFileName in lDict: @@ -353,16 +349,11 @@ lDescription = dVars['dic_description'].split(",") lFilter = dVars['dic_filter'].split(",") for sfDictDst, sDicName, sDescription, sFilter in zip(lSfDictDst, lDicName, lDescription, lFilter): lex_build.build(spfLexSrc, dVars['lang'], dVars['lang_name'], sfDictDst, bJavaScript, sDicName, sDescription, sFilter, dVars['stemming_method'], int(dVars['fsa_method'])) else: - if sType == "extended": - spfLexSrc = dVars['lexicon_extended_src'] - sfDictDst = dVars['dic_extended_filename'] - sDicName = dVars['dic_extended_name'] - sDescription = dVars['dic_extended_description'] - elif sType == "community": + if sType == "community": spfLexSrc = dVars['lexicon_community_src'] sfDictDst = dVars['dic_community_filename'] sDicName = dVars['dic_community_name'] sDescription = dVars['dic_community_description'] elif sType == "personal": @@ -385,11 +376,10 @@ xParser.add_argument("-d", "--dict", help="generate FSA dictionary", action="store_true") xParser.add_argument("-t", "--tests", help="run unit tests", action="store_true") xParser.add_argument("-p", "--perf", help="run performance tests", action="store_true") xParser.add_argument("-pm", "--perf_memo", help="run performance tests and store results in perf_memo.txt", action="store_true") xParser.add_argument("-js", "--javascript", help="JavaScript build for Firefox", action="store_true") - xParser.add_argument("-aed", "--add_extended_dictionary", help="add extended dictionary to the build", action="store_true") xParser.add_argument("-acd", "--add_community_dictionary", help="add community dictionary to the build", action="store_true") xParser.add_argument("-apd", "--add_personal_dictionary", help="add personal dictionary to the build", action="store_true") xParser.add_argument("-fx", "--firefox", help="Launch Firefox Developper for WebExtension testing", action="store_true") xParser.add_argument("-we", "--web_ext", help="Launch Firefox Nightly for WebExtension testing", action="store_true") xParser.add_argument("-l", "--lint_web_ext", help="web-ext lint on the WebExtension", action="store_true") @@ -412,12 +402,10 @@ for sLang in xArgs.lang: if os.path.exists("gc_lang/"+sLang) and os.path.isdir("gc_lang/"+sLang): xConfig = getConfig(sLang) dVars = xConfig._sections['args'] - if not dVars["lexicon_extended_src"]: - xArgs.add_extended_dictionary = False if not dVars["lexicon_community_src"]: xArgs.add_community_dictionary = False if not dVars["lexicon_personal_src"]: xArgs.add_personal_dictionary = False @@ -431,21 +419,19 @@ print("# Error. Couldn’t import file build_data.py in folder gc_lang/"+sLang) if databuild and xArgs.build_data_before: databuild.before('gc_lang/'+sLang, dVars, xArgs.javascript) if xArgs.dict: buildDictionary(dVars, "main", xArgs.javascript) - if xArgs.add_extended_dictionary: - buildDictionary(dVars, "extended", xArgs.javascript) if xArgs.add_community_dictionary: buildDictionary(dVars, "community", xArgs.javascript) if xArgs.add_personal_dictionary: buildDictionary(dVars, "personal", xArgs.javascript) if databuild and xArgs.build_data_after: databuild.after('gc_lang/'+sLang, dVars, xArgs.javascript) # copy dictionaries from Graphspell - copyGraphspellDictionaries(dVars, xArgs.javascript, xArgs.add_extended_dictionary, xArgs.add_community_dictionary, xArgs.add_personal_dictionary) + copyGraphspellDictionaries(dVars, xArgs.javascript, xArgs.add_community_dictionary, xArgs.add_personal_dictionary) # make sVersion = create(sLang, xConfig, xArgs.install, xArgs.javascript, xArgs.use_cache) # tests