Index: gc_core/py/lang_core/gc_options.py ================================================================== --- gc_core/py/lang_core/gc_options.py +++ gc_core/py/lang_core/gc_options.py @@ -3,18 +3,18 @@ """ # generated code, do not edit def getUI (sLang): - "returns dictionary of UI labels" + "returns dictionary of UI labels" if sLang in _dOptLabel: return _dOptLabel[sLang] return _dOptLabel["fr"] def getOptions (sContext="Python"): - "returns dictionary of options" + "returns dictionary of options" if sContext in dOpt: return dOpt[sContext] return dOpt["Python"] Index: gc_core/py/text.py ================================================================== --- gc_core/py/text.py +++ gc_core/py/text.py @@ -45,27 +45,27 @@ lSpellErrs = sorted(aSpellErrs, key=lambda d: d['nStart']) sText = "" nOffset = 0 for sLine in wrap(sParagraph, nWidth): # textwrap.wrap(sParagraph, nWidth, drop_whitespace=False) sText += sLine + "\n" - ln = len(sLine) + nLineLen = len(sLine) sErrLine = "" nLenErrLine = 0 nGrammErr = 0 nSpellErr = 0 for dErr in lGrammErrs: nStart = dErr["nStart"] - nOffset - if nStart < ln: + if nStart < nLineLen: nGrammErr += 1 if nStart >= nLenErrLine: sErrLine += " " * (nStart - nLenErrLine) + "^" * (dErr["nEnd"] - dErr["nStart"]) nLenErrLine = len(sErrLine) else: break for dErr in lSpellErrs: nStart = dErr['nStart'] - nOffset - if nStart < ln: + if nStart < nLineLen: nSpellErr += 1 nEnd = dErr['nEnd'] - nOffset if nEnd > len(sErrLine): sErrLine += " " * (nEnd - len(sErrLine)) sErrLine = sErrLine[:nStart] + "°" * (nEnd - nStart) + sErrLine[nEnd:] @@ -77,11 +77,11 @@ sText += getReadableErrors(lGrammErrs[:nGrammErr], nWidth) del lGrammErrs[0:nGrammErr] if nSpellErr: sText += getReadableErrors(lSpellErrs[:nSpellErr], nWidth, True) del lSpellErrs[0:nSpellErr] - nOffset += ln + nOffset += nLineLen return sText def getReadableErrors (lErrs, nWidth, bSpell=False): "Returns lErrs errors as readable errors" @@ -99,19 +99,19 @@ def getReadableError (dErr, bSpell=False): "Returns an error dErr as a readable error" try: if bSpell: - s = u"* {nStart}:{nEnd} # {sValue}:".format(**dErr) + sText = u"* {nStart}:{nEnd} # {sValue}:".format(**dErr) else: - s = u"* {nStart}:{nEnd} # {sLineId} / {sRuleId}:\n".format(**dErr) - s += " " + dErr.get("sMessage", "# error : message not found") + sText = u"* {nStart}:{nEnd} # {sLineId} / {sRuleId}:\n".format(**dErr) + sText += " " + dErr.get("sMessage", "# error : message not found") if dErr.get("aSuggestions", None): - s += "\n > Suggestions : " + " | ".join(dErr.get("aSuggestions", "# error : suggestions not found")) + sText += "\n > Suggestions : " + " | ".join(dErr.get("aSuggestions", "# error : suggestions not found")) if dErr.get("URL", None): - s += "\n > URL: " + dErr["URL"] - return s + sText += "\n > URL: " + dErr["URL"] + return sText except KeyError: return u"* Non-compliant error: {}".format(dErr) def createParagraphWithLines (lLine): Index: gc_lang/fr/modules/conj.py ================================================================== --- gc_lang/fr/modules/conj.py +++ gc_lang/fr/modules/conj.py @@ -173,11 +173,11 @@ self.bProWithEn = (self._sRawInfo[5] == "e") self._tTags = _getTags(sVerbPattern) if not self._tTags: raise ValueError("Unknown verb.") self._tTagsAux = _getTags(self.sVerbAux) - self.cGroup = self._sRawInfo[0]; + self.cGroup = self._sRawInfo[0] self.dConj = { ":Y": { "label": "Infinitif", ":": sVerb, }, Index: gc_lang/fr/modules/cregex.py ================================================================== --- gc_lang/fr/modules/cregex.py +++ gc_lang/fr/modules/cregex.py @@ -101,10 +101,11 @@ if mbFem(l1) and not mbFem(l2): return False return True def checkConjVerb (lMorph, sReqConj): + "returns True if in " return any(sReqConj in s for s in lMorph) def getGender (lMorph): "returns gender of word (':m', ':f', ':e' or empty string)." sGender = "" @@ -197,17 +198,17 @@ "returns True if one morphology is “nom” or “adjectif”" return any(NA.search(s) for s in lMorph) def mbNomNotAdj (lMorph): "returns True if one morphology is “nom”, but not “adjectif”" - b = False + bResult = False for s in lMorph: if ":A" in s: return False if ":N" in s: - b = True - return b + bResult = True + return bResult def mbPpasNomNotAdj (lMorph): "returns True if one morphology is “nom” or “participe passé”, but not “adjectif”" return any(PNnotA.search(s) for s in lMorph) Index: gc_lang/fr/modules/lexicographe.py ================================================================== --- gc_lang/fr/modules/lexicographe.py +++ gc_lang/fr/modules/lexicographe.py @@ -156,18 +156,20 @@ "s'en": " (se) pronom personnel objet + (en) pronom adverbial", } class Lexicographe: + "Lexicographer - word analyzer" def __init__ (self, oSpellChecker): self.oSpellChecker = oSpellChecker self._zElidedPrefix = re.compile("(?i)^([dljmtsncç]|quoiqu|lorsqu|jusqu|puisqu|qu)['’](.+)") self._zCompoundWord = re.compile("(?i)(\\w+)-((?:les?|la)-(?:moi|toi|lui|[nv]ous|leur)|t-(?:il|elle|on)|y|en|[mts][’'](?:y|en)|les?|l[aà]|[mt]oi|leur|lui|je|tu|ils?|elles?|on|[nv]ous)$") self._zTag = re.compile("[:;/][\\w*][^:;/]*") def analyzeWord (self, sWord): + "returns a tuple (a list of morphologies, a set of verb at infinitive form)" try: if not sWord: return (None, None) if sWord.count("-") > 4: return (["élément complexe indéterminé"], None) @@ -195,17 +197,18 @@ aMorph.append( "{} : inconnu du dictionnaire".format(sWord) ) # suffixe d’un mot composé if m2: aMorph.append( "-{} : {}".format(m2.group(2), self._formatSuffix(m2.group(2).lower())) ) # Verbes - aVerb = set([ s[1:s.find(" ")] for s in lMorph if ":V" in s ]) + aVerb = set([ s[1:s.find("/")] for s in lMorph if ":V" in s ]) return (aMorph, aVerb) except: traceback.print_exc() return (["#erreur"], None) def formatTags (self, sTags): + "returns string: readable tags" sRes = "" sTags = re.sub("(?<=V[1-3])[itpqnmr_eaxz]+", "", sTags) sTags = re.sub("(?<=V0[ea])[itpqnmr_eaxz]+", "", sTags) for m in self._zTag.finditer(sTags): sRes += _dTAGS.get(m.group(0), " [{}]".format(m.group(0)))[0]