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 @@ -13,12 +13,10 @@ from ..graphspell.spellchecker import SpellChecker from ..graphspell.tokenizer import Tokenizer from ..graphspell.echo import echo from . import gc_options -from .gc_rules_graph import dAllGraph, dRule - try: # LibreOffice / OpenOffice from com.sun.star.linguistic2 import SingleProofreadingError from com.sun.star.text.TextMarkupType import PROOFREADING from com.sun.star.beans import PropertyValue @@ -43,12 +41,13 @@ version = "${version}" author = "${author}" # Modules _rules = None # module gc_rules +_rules_graph = None # module gc_rules_graph -# data +# Data _sAppContext = "" # what software is running _dOptions = None _oSpellChecker = None _oTokenizer = None _aIgnoredRules = set() @@ -85,12 +84,15 @@ return _rules.lParagraphRules def _loadRules (): from . import gc_rules + from . import gc_rules_graph global _rules + global _rules_graph _rules = gc_rules + _rules_graph = gc_rules_graph # compile rules regex for sOption, lRuleGroup in chain(_rules.lParagraphRules, _rules.lSentenceRules): if sOption != "@@@@": for aRule in lRuleGroup: try: @@ -282,11 +284,11 @@ bChange = False for sGraphName, sLineId in lRuleGroup: if sGraphName not in dOptions or dOptions[sGraphName]: if bDebug: print("\n>>>> GRAPH:", sGraphName, sLineId) - sText = self.parseGraph(dAllGraph[sGraphName], sCountry, dOptions, bShowRuleId, bDebug, bContext) + sText = self.parseGraph(_rules_graph.dAllGraph[sGraphName], sCountry, dOptions, bShowRuleId, bDebug, bContext) elif not sOption or dOptions.get(sOption, False): # regex rules for zRegex, bUppercase, sLineId, sRuleId, nPriority, lActions in lRuleGroup: if sRuleId not in _aIgnoredRules: for m in zRegex.finditer(sText): @@ -505,11 +507,11 @@ bCondMemo = None for sRuleId in dGraph[nextNodeKey]: try: if bDebug: print(" >TRY:", sRuleId) - sOption, sFuncCond, cActionType, sWhat, *eAct = dRule[sRuleId] + sOption, sFuncCond, cActionType, sWhat, *eAct = _rules_graph.dRule[sRuleId] # Suggestion [ option, condition, "-", replacement/suggestion/action, iTokenStart, iTokenEnd, cStartLimit, cEndLimit, bCaseSvty, nPriority, sMessage, sURL ] # TextProcessor [ option, condition, "~", replacement/suggestion/action, iTokenStart, iTokenEnd, bCaseSvty ] # Disambiguator [ option, condition, "=", replacement/suggestion/action ] # Tag [ option, condition, "/", replacement/suggestion/action, iTokenStart, iTokenEnd ] # Immunity [ option, condition, "%", "", iTokenStart, iTokenEnd ] @@ -567,11 +569,11 @@ self.dTags[sWhat][0] = min(nTokenStart, self.dTags[sWhat][0]) self.dTags[sWhat][1] = max(nTokenEnd, self.dTags[sWhat][1]) elif cActionType == "%": # immunity if bDebug: - print(" IMMUNITY:\n ", dRule[sRuleId]) + print(" IMMUNITY:\n ", _rules_graph.dRule[sRuleId]) nTokenStart = nTokenOffset + eAct[0] if eAct[0] > 0 else nLastToken + eAct[0] nTokenEnd = nTokenOffset + eAct[1] if eAct[1] > 0 else nLastToken + eAct[1] if nTokenEnd - nTokenStart == 0: self.lToken[nTokenStart]["bImmune"] = True nErrorStart = self.nOffsetWithinParagraph + self.lToken[nTokenStart]["nStart"]