Index: gc_lang/fr/dictionnaire/genfrdic.py ================================================================== --- gc_lang/fr/dictionnaire/genfrdic.py +++ gc_lang/fr/dictionnaire/genfrdic.py @@ -524,15 +524,10 @@ def writeGrammarCheckerLexicon (self, spfDst, version): echo(' * Lexique simplifié >> [ {} ] '.format(spfDst)) with open(spfDst[:-4]+".lex", 'w', encoding='utf-8', newline="\n") as hDst: hDst.write(MPLHEADER) hDst.write("# Lexique simplifié pour Grammalecte v{}\n# Licence : MPL v2.0\n\n".format(version)) - hDst.write("## LangCode: fr\n") - hDst.write("## LangName: Français\n") - hDst.write("## DicName: fr.commun\n") - hDst.write("## Description: Français commun (toutes variantes)\n") - hDst.write("## Author: Olivier R.\n\n") hDst.write(Flexion.simpleHeader()) for oFlex in self.lFlexions: hDst.write(oFlex.getGrammarCheckerRepr()) def createFiles (self, spDst, lDictVars, nMode, bSimplified): Index: graphspell/dawg.py ================================================================== --- graphspell/dawg.py +++ graphspell/dawg.py @@ -20,20 +20,30 @@ from . import str_transform as st from .progressbar import ProgressBar + +dLexiconData = {} def readFile (spf): "generator: read file and return for each line a list of elements separated by a tabulation." print(" < Read lexicon: " + spf) if os.path.isfile(spf): + dLexiconData.clear() with open(spf, "r", encoding="utf-8") as hSrc: for sLine in hSrc: sLine = sLine.strip() - if sLine and not sLine.startswith("#"): + if sLine.startswith("##") : + m = re.match("## *(\\w+) *:(.*)$", sLine) + if m: + dLexiconData[m.group(1)] = m.group(2).strip() + elif sLine and not sLine.startswith("#"): yield sLine.split("\t") + if dLexiconData: + print("Data from dictionary:") + print(dLexiconData) else: raise OSError("# Error. File not found or not loadable: " + spf) @@ -120,10 +130,15 @@ self.sFileName = src if type(src) is str else "[None]" self.sLangCode = sLangCode self.sLangName = sLangName self.sDicName = sDicName self.sDescription = sDescription + if dLexiconData: + self.sLangCode = dLexiconData.get("LangCode", self.sLangCode) + self.sLangName = dLexiconData.get("LangName", self.sLangName) + self.sDicName = dLexiconData.get("DicName", self.sDicName) + self.sDescription = dLexiconData.get("Description", self.sDescription) self.nEntry = len(lWord) self.aPreviousEntry = [] DawgNode.resetNextId() self.oRoot = DawgNode() self.lUncheckedNodes = [] # list of nodes that have not been checked for duplication. Index: lexicons/French.lex ================================================================== --- lexicons/French.lex +++ lexicons/French.lex @@ -3,16 +3,10 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # Lexique simplifié pour Grammalecte v7.0 # Licence : MPL v2.0 -## LangCode: fr -## LangName: Français -## DicName: fr.commun -## Description: Français commun (toutes variantes) -## Author: Olivier R. - # :POS ;LEX ~SEM =FQ /DIC de de :G:D:e:i/* de de :G:R:Rv/* et et :G:Cc/* à à :G:R:Rv/*