Overview
Comment: | [core][fr] code cleaning (pylint) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | fr | core |
Files: | files | file ages | folders |
SHA3-256: |
16611cf6645d27571442ae30073b1f40 |
User & Date: | olr on 2019-05-11 18:50:40 |
Other Links: | manifest | tags |
Context
2019-05-12
| ||
10:00 | [graphspell] code cleaning (pylint) check-in: c2f4d1d4ee user: olr tags: trunk, graphspell | |
2019-05-11
| ||
18:50 | [core][fr] code cleaning (pylint) check-in: 16611cf664 user: olr tags: trunk, fr, core | |
18:49 | version 1.0.3 check-in: 4c24296679 user: olr tags: trunk | |
Changes
Modified gc_lang/fr/modules-js/gce_analyseur.js from [09241345b5] to [3d0c792715].
︙ | ︙ | |||
59 60 61 62 63 64 65 | return true; } 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 | | | | | | | | | | | | | | | | | | | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | return true; } 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 lMorph2 = _oSpellChecker.getMorph(sWord2); if (lMorph2.length === 0) { return false; } if (cregex.checkConjVerb(lMorph2, sReqMorphConj)) { // verb word2 is ok return false; } let lMorph1 = _oSpellChecker.getMorph(sWord1); if (lMorph1.length === 0) { return false; } 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 lMorph2 = _oSpellChecker.getMorph(sWord2); if (lMorph2.length === 0) { return false; } if (cregex.checkConjVerb(lMorph2, sReqMorphConj)) { // verb word2 is ok return false; } let lMorph1 = _oSpellChecker.getMorph(sWord1); if (lMorph1.length === 0) { return false; } 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(lMorph1)) { return true; } //if cregex.isNomAdjVerb(lMorph1): # considered true if (bLastHopeCond) { return true; } return false; } function checkAgreement (sWord1, sWord2) { let lMorph2 = _oSpellChecker.getMorph(sWord2); if (lMorph2.length === 0) { return true; } let lMorph1 = _oSpellChecker.getMorph(sWord1); if (lMorph1.length === 0) { return true; } return cregex.checkAgreement(lMorph1, lMorph2); } function mbUnit (s) { if (/[µ\/⁰¹²³⁴⁵⁶⁷⁸⁹Ωℓ·]/.test(s)) { return true; } if (s.length > 1 && s.length < 16 && s.slice(0, 1).gl_isLowerCase() && (!s.slice(1).gl_isLowerCase() || /[0-9]/.test(s))) { |
︙ | ︙ |
Modified gc_lang/fr/modules/gce_analyseur.py from [bae6058302] to [36994d46b4].
︙ | ︙ | |||
21 22 23 24 25 26 27 | return "vous" if s2 == "nous": return "nous" if s2 == "vous": return "vous" if s2 == "eux": return "ils" | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | return "vous" if s2 == "nous": return "nous" if s2 == "vous": return "vous" if s2 == "eux": return "ils" 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 |
︙ | ︙ | |||
46 47 48 49 50 51 52 | if cr.mbVconj(lMorph) and not cr.mbMG(lMorph): return True return False def isAmbiguousAndWrong (sWord1, sWord2, sReqMorphNA, sReqMorphConj): "use it if <sWord1> won’t be a verb; <sWord2> is assumed to be True via isAmbiguousNAV" | | | | | | | | | | | | | | | | | | | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | if cr.mbVconj(lMorph) and not cr.mbMG(lMorph): return True return False def isAmbiguousAndWrong (sWord1, sWord2, sReqMorphNA, sReqMorphConj): "use it if <sWord1> won’t be a verb; <sWord2> is assumed to be True via isAmbiguousNAV" lMorph2 = _oSpellChecker.getMorph(sWord2) if not lMorph2: return False if cr.checkConjVerb(lMorph2, sReqMorphConj): # verb word2 is ok return False lMorph1 = _oSpellChecker.getMorph(sWord1) if not lMorph1: return False 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 <sWord1> can be also a verb; <sWord2> is assumed to be True via isAmbiguousNAV" lMorph2 = _oSpellChecker.getMorph(sWord2) if not lMorph2: return False if cr.checkConjVerb(lMorph2, sReqMorphConj): # verb word2 is ok return False lMorph1 = _oSpellChecker.getMorph(sWord1) if not lMorph1: return False 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(lMorph1): return True #if cr.isNomAdjVerb(lMorph1): # considered True if bLastHopeCond: return True return False def checkAgreement (sWord1, sWord2): "check agreement between <sWord1> and <sWord1>" lMorph2 = _oSpellChecker.getMorph(sWord2) if not lMorph2: return True lMorph1 = _oSpellChecker.getMorph(sWord1) if not lMorph1: return True return cr.checkAgreement(lMorph1, lMorph2) _zUnitSpecial = re.compile("[µ/⁰¹²³⁴⁵⁶⁷⁸⁹Ωℓ·]") _zUnitNumbers = re.compile("[0-9]") def mbUnit (s): "returns True it can be a measurement unit" |
︙ | ︙ |
Modified gc_lang/fr/modules/lexicographe.py from [21e3c3d170] to [d87b1c36de].
︙ | ︙ | |||
198 199 200 201 202 203 204 | 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 = { s[1:s.find("/")] for s in lMorph if ":V" in s } return (aMorph, aVerb) | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | 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 = { s[1:s.find("/")] for s in lMorph if ":V" in s } return (aMorph, aVerb) except (IndexError, TypeError): traceback.print_exc() return (["#erreur"], None) def formatTags (self, sTags): "returns string: readable tags" sRes = "" sTags = re.sub("(?<=V[1-3])[itpqnmr_eaxz]+", "", sTags) |
︙ | ︙ |
Modified gc_lang/fr/modules/mfsp.py from [8b7759e076] to [9096dedca9].
︙ | ︙ | |||
41 42 43 44 45 46 47 | "returns sWord modified by sSfx" if not sSfx: 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" | | | 41 42 43 44 45 46 47 48 49 | "returns sWord modified by sSfx" if not sSfx: 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 (IndexError, TypeError): return "## erreur, code : " + str(sSfx) + " ##" |
Modified gc_lang/fr/modules/textformatter.py from [a8d17c5bd5] to [e20bd3ea84].
︙ | ︙ | |||
249 250 251 252 253 254 255 256 257 258 259 260 | def __init__ (self): for sOpt, lTup in dReplTable.items(): for i, t in enumerate(lTup): lTup[i] = (re.compile(t[0]), t[1]) def formatText (self, sText): for sOptName, bVal in lOptRepl: if bVal: for zRgx, sRep in dReplTable[sOptName]: sText = zRgx.sub(sRep, sText) return sText | > | 249 250 251 252 253 254 255 256 257 258 259 260 261 | def __init__ (self): 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 |