Index: gc_lang/fr/modules-js/gce_analyseur.js ================================================================== --- gc_lang/fr/modules-js/gce_analyseur.js +++ gc_lang/fr/modules-js/gce_analyseur.js @@ -61,66 +61,66 @@ return false; } function isAmbiguousAndWrong (sWord1, sWord2, sReqMorphNA, sReqMorphConj) { //// use it if sWord1 won’t be a verb; word2 is assumed to be true via isAmbiguousNAV - let a2 = _oSpellChecker.getMorph(sWord2); - if (a2.length === 0) { + let lMorph2 = _oSpellChecker.getMorph(sWord2); + if (lMorph2.length === 0) { return false; } - if (cregex.checkConjVerb(a2, sReqMorphConj)) { + if (cregex.checkConjVerb(lMorph2, sReqMorphConj)) { // verb word2 is ok return false; } - let a1 = _oSpellChecker.getMorph(sWord1); - if (a1.length === 0) { + let lMorph1 = _oSpellChecker.getMorph(sWord1); + if (lMorph1.length === 0) { return false; } - if (cregex.checkAgreement(a1, a2) && (cregex.mbAdj(a2) || cregex.mbAdj(a1))) { + if (cregex.checkAgreement(lMorph1, lMorph2) && (cregex.mbAdj(lMorph2) || cregex.mbAdj(lMorph1))) { return false; } return true; } function isVeryAmbiguousAndWrong (sWord1, sWord2, sReqMorphNA, sReqMorphConj, bLastHopeCond) { //// use it if sWord1 can be also a verb; word2 is assumed to be true via isAmbiguousNAV - let a2 = _oSpellChecker.getMorph(sWord2); - if (a2.length === 0) { + let lMorph2 = _oSpellChecker.getMorph(sWord2); + if (lMorph2.length === 0) { return false; } - if (cregex.checkConjVerb(a2, sReqMorphConj)) { + if (cregex.checkConjVerb(lMorph2, sReqMorphConj)) { // verb word2 is ok return false; } - let a1 = _oSpellChecker.getMorph(sWord1); - if (a1.length === 0) { + let lMorph1 = _oSpellChecker.getMorph(sWord1); + if (lMorph1.length === 0) { return false; } - if (cregex.checkAgreement(a1, a2) && (cregex.mbAdj(a2) || cregex.mbAdjNb(a1))) { + if (cregex.checkAgreement(lMorph1, lMorph2) && (cregex.mbAdj(lMorph2) || cregex.mbAdjNb(lMorph1))) { return false; } // now, we know there no agreement, and conjugation is also wrong - if (cregex.isNomAdj(a1)) { + if (cregex.isNomAdj(lMorph1)) { return true; } - //if cregex.isNomAdjVerb(a1): # considered true + //if cregex.isNomAdjVerb(lMorph1): # considered true if (bLastHopeCond) { return true; } return false; } function checkAgreement (sWord1, sWord2) { - let a2 = _oSpellChecker.getMorph(sWord2); - if (a2.length === 0) { + let lMorph2 = _oSpellChecker.getMorph(sWord2); + if (lMorph2.length === 0) { return true; } - let a1 = _oSpellChecker.getMorph(sWord1); - if (a1.length === 0) { + let lMorph1 = _oSpellChecker.getMorph(sWord1); + if (lMorph1.length === 0) { return true; } - return cregex.checkAgreement(a1, a2); + return cregex.checkAgreement(lMorph1, lMorph2); } function mbUnit (s) { if (/[µ\/⁰¹²³⁴⁵⁶⁷⁸⁹Ωℓ·]/.test(s)) { return true; Index: gc_lang/fr/modules/gce_analyseur.py ================================================================== --- gc_lang/fr/modules/gce_analyseur.py +++ gc_lang/fr/modules/gce_analyseur.py @@ -23,11 +23,11 @@ return "nous" if s2 == "vous": return "vous" if s2 == "eux": return "ils" - if s2 == "elle" or s2 == "elles": + if s2 in ("elle", "elles"): if cr.mbNprMasNotFem(_oSpellChecker.getMorph(s1)): return "ils" # si épicène, indéterminable, mais OSEF, le féminin l’emporte return "elles" return s1 + " et " + s2 @@ -48,55 +48,55 @@ return False def isAmbiguousAndWrong (sWord1, sWord2, sReqMorphNA, sReqMorphConj): "use it if won’t be a verb; is assumed to be True via isAmbiguousNAV" - a2 = _oSpellChecker.getMorph(sWord2) - if not a2: + lMorph2 = _oSpellChecker.getMorph(sWord2) + if not lMorph2: return False - if cr.checkConjVerb(a2, sReqMorphConj): + if cr.checkConjVerb(lMorph2, sReqMorphConj): # verb word2 is ok return False - a1 = _oSpellChecker.getMorph(sWord1) - if not a1: + lMorph1 = _oSpellChecker.getMorph(sWord1) + if not lMorph1: return False - if cr.checkAgreement(a1, a2) and (cr.mbAdj(a2) or cr.mbAdj(a1)): + if cr.checkAgreement(lMorph1, lMorph2) and (cr.mbAdj(lMorph2) or cr.mbAdj(lMorph1)): return False return True def isVeryAmbiguousAndWrong (sWord1, sWord2, sReqMorphNA, sReqMorphConj, bLastHopeCond): "use it if can be also a verb; is assumed to be True via isAmbiguousNAV" - a2 = _oSpellChecker.getMorph(sWord2) - if not a2: + lMorph2 = _oSpellChecker.getMorph(sWord2) + if not lMorph2: return False - if cr.checkConjVerb(a2, sReqMorphConj): + if cr.checkConjVerb(lMorph2, sReqMorphConj): # verb word2 is ok return False - a1 = _oSpellChecker.getMorph(sWord1) - if not a1: + lMorph1 = _oSpellChecker.getMorph(sWord1) + if not lMorph1: return False - if cr.checkAgreement(a1, a2) and (cr.mbAdj(a2) or cr.mbAdjNb(a1)): + if cr.checkAgreement(lMorph1, lMorph2) and (cr.mbAdj(lMorph2) or cr.mbAdjNb(lMorph1)): return False # now, we know there no agreement, and conjugation is also wrong - if cr.isNomAdj(a1): + if cr.isNomAdj(lMorph1): return True - #if cr.isNomAdjVerb(a1): # considered True + #if cr.isNomAdjVerb(lMorph1): # considered True if bLastHopeCond: return True return False def checkAgreement (sWord1, sWord2): "check agreement between and " - a2 = _oSpellChecker.getMorph(sWord2) - if not a2: + lMorph2 = _oSpellChecker.getMorph(sWord2) + if not lMorph2: return True - a1 = _oSpellChecker.getMorph(sWord1) - if not a1: + lMorph1 = _oSpellChecker.getMorph(sWord1) + if not lMorph1: return True - return cr.checkAgreement(a1, a2) + return cr.checkAgreement(lMorph1, lMorph2) _zUnitSpecial = re.compile("[µ/⁰¹²³⁴⁵⁶⁷⁸⁹Ωℓ·]") _zUnitNumbers = re.compile("[0-9]") Index: gc_lang/fr/modules/lexicographe.py ================================================================== --- gc_lang/fr/modules/lexicographe.py +++ gc_lang/fr/modules/lexicographe.py @@ -200,11 +200,11 @@ if m2: aMorph.append( "-{} : {}".format(m2.group(2), self._formatSuffix(m2.group(2).lower())) ) # Verbes aVerb = { s[1:s.find("/")] for s in lMorph if ":V" in s } return (aMorph, aVerb) - except: + except (IndexError, TypeError): traceback.print_exc() return (["#erreur"], None) def formatTags (self, sTags): "returns string: readable tags" Index: gc_lang/fr/modules/mfsp.py ================================================================== --- gc_lang/fr/modules/mfsp.py +++ gc_lang/fr/modules/mfsp.py @@ -43,7 +43,7 @@ return "" if sSfx == "0": return sWord try: return sWord[:-(ord(sSfx[0])-48)] + sSfx[1:] if sSfx[0] != '0' else sWord + sSfx[1:] # 48 is the ASCII code for "0" - except: + except (IndexError, TypeError): return "## erreur, code : " + str(sSfx) + " ##" Index: gc_lang/fr/modules/textformatter.py ================================================================== --- gc_lang/fr/modules/textformatter.py +++ gc_lang/fr/modules/textformatter.py @@ -251,10 +251,11 @@ for sOpt, lTup in dReplTable.items(): for i, t in enumerate(lTup): lTup[i] = (re.compile(t[0]), t[1]) def formatText (self, sText): + "returns formatted text" for sOptName, bVal in lOptRepl: if bVal: for zRgx, sRep in dReplTable[sOptName]: sText = zRgx.sub(sRep, sText) return sText