Index: gc_lang/fr/modules-js/gce_suggestions.js ================================================================== --- gc_lang/fr/modules-js/gce_suggestions.js +++ gc_lang/fr/modules-js/gce_suggestions.js @@ -16,11 +16,11 @@ function splitVerb (sVerb) { // renvoie le verbe et les pronoms séparément let iRight = sVerb.lastIndexOf("-"); let sSuffix = sVerb.slice(iRight); sVerb = sVerb.slice(0, iRight); - if (sVerb.endsWith("-t") || sVerb.endsWith("-le") || sVerb.endsWith("-la") || sVerb.endsWith("-les")) { + if (sVerb.endsWith("-t") || sVerb.endsWith("-le") || sVerb.endsWith("-la") || sVerb.endsWith("-les") || sVerb.endsWith("-nous") || sVerb.endsWith("-vous") || sVerb.endsWith("-leur") || sVerb.endsWith("-lui")) { iRight = sVerb.lastIndexOf("-"); sSuffix = sVerb.slice(iRight) + sSuffix; sVerb = sVerb.slice(0, iRight); } return [sVerb, sSuffix]; @@ -140,10 +140,39 @@ if (aSugg.size > 0) { return Array.from(aSugg).join("|"); } return ""; } + +function suggVerbFrom (sStem, sFlex, sWho="") { + "conjugate according to (and eventually )" + let aSugg = new Set(); + for (let sMorph of gc_engine.oSpellChecker.getMorph(sFlex)) { + let lTenses = [ ...sMorph.matchAll(/:(?:Y|I[pqsf]|S[pq]|K|P|Q)/g) ]; + if (sWho) { + for (let sTense of lTenses) { + if (conj.hasConj(sStem, sTense, sWho)) { + aSugg.add(conj.getConj(sStem, sTense, sWho)); + } + } + } + else { + for (let sTense of lTenses) { + for (let sWho of [ ...sMorph.matchAll(/:[123][sp]/g) ]) { + if (conj.hasConj(sStem, sTense, sWho)) { + aSugg.add(conj.getConj(sStem, sTense, sWho)); + } + } + } + } + } + if (aSugg.size > 0) { + return Array.from(aSugg).join("|"); + } + return ""; +} + function suggVerbImpe (sFlex, bVC=false) { let sSfx; if (bVC) { [sFlex, sSfx] = splitVerb(sFlex); @@ -163,11 +192,11 @@ } } } if (aSugg.size > 0) { if (bVC) { - return Array.from(aSugg).map((sSugg) => { return ((sSugg.endsWith("e") || sSugg.endsWith("a")) && (sSfx.endsWith("-en") || sSfx.endsWith("-y"))) ? sSugg + "s" + sSfx : sSugg + sSfx; }).join("|"); + return Array.from(aSugg).map((sSugg) => { return ((sSugg.endsWith("e") || sSugg.endsWith("a")) && (sSfx == "-en" || sSfx == "-y")) ? sSugg + "s" + sSfx : sSugg + sSfx; }).join("|"); } return Array.from(aSugg).join("|"); } return ""; } @@ -590,11 +619,11 @@ } } } if (aSugg.size > 0) { if (bVC) { - return Array.from(aSugg).map((sSugg) => { return sSugg + sSfx; }).join("|"); + return Array.from(aSugg).map((sSugg) => { return ((sSugg.endsWith("e") || sSugg.endsWith("a")) && (sSfx == "-en" || sSfx == "-y")) ? sSugg + "s" + sSfx : sSugg + sSfx; }).join("|"); } return Array.from(aSugg).join("|"); } return ""; } Index: gc_lang/fr/modules/gce_suggestions.py ================================================================== --- gc_lang/fr/modules/gce_suggestions.py +++ gc_lang/fr/modules/gce_suggestions.py @@ -10,11 +10,11 @@ def splitVerb (sVerb): "renvoie le verbe et les pronoms séparément" iRight = sVerb.rfind("-") sSuffix = sVerb[iRight:] sVerb = sVerb[:iRight] - if sVerb.endswith(("-t", "-le", "-la", "-les")): + if sVerb.endswith(("-t", "-le", "-la", "-les", "-nous", "-vous", "-leur", "-lui")): iRight = sVerb.rfind("-") sSuffix = sVerb[iRight:] + sSuffix sVerb = sVerb[:iRight] return sVerb, sSuffix @@ -109,10 +109,29 @@ aSugg.add(conj.getConj(sStem, sTense, sWho)) if aSugg: return "|".join(aSugg) return "" + +def suggVerbFrom (sStem, sFlex, sWho=""): + "conjugate according to (and eventually )" + aSugg = set() + for sMorph in _oSpellChecker.getMorph(sFlex): + lTenses = [ m.group(0) for m in re.finditer(":(?:Y|I[pqsf]|S[pq]|K|P|Q)", sMorph) ] + if sWho: + for sTense in lTenses: + if conj.hasConj(sStem, sTense, sWho): + aSugg.add(conj.getConj(sStem, sTense, sWho)) + else: + for sTense in lTenses: + for sWho in [ m.group(0) for m in re.finditer(":[123][sp]", sMorph) ]: + if conj.hasConj(sStem, sTense, sWho): + aSugg.add(conj.getConj(sStem, sTense, sWho)) + if aSugg: + return "|".join(aSugg) + return "" + def suggVerbImpe (sFlex, bVC=False): "change to a verb at imperative form" if bVC: sFlex, sSfx = splitVerb(sFlex) @@ -126,11 +145,11 @@ aSugg.add(conj._getConjWithTags(sStem, tTags, ":E", ":1p")) if conj._hasConjWithTags(tTags, ":E", ":2p"): aSugg.add(conj._getConjWithTags(sStem, tTags, ":E", ":2p")) if aSugg: if bVC: - aSugg = list(map(lambda sSug: sSug + "s" + sSfx if sSfx.endswith(("-en", "-y")) and sSug.endswith(("e", "a")) else sSug + sSfx, aSugg)) + aSugg = list(map(lambda sSug: sSug + "s" + sSfx if (sSfx == "-en" or sSfx == "-y") and sSug.endswith(("e", "a")) else sSug + sSfx, aSugg)) return "|".join(aSugg) return "" def suggVerbInfi (sFlex): @@ -454,11 +473,11 @@ for sMorph in _oSpellChecker.getMorph(sWord): aSugg.update(conj.getSimil(sWord, sMorph, bSubst)) break if aSugg: if bVC: - aSugg = list(map(lambda sSug: sSug + sSfx, aSugg)) + aSugg = list(map(lambda sSug: sSug + "s" + sSfx if (sSfx == "-en" or sSfx == "-y") and sSug.endswith(("e", "a")) else sSug + sSfx, aSugg)) return "|".join(aSugg) return "" def suggCeOrCet (sWord): Index: gc_lang/fr/webext/manifest.json ================================================================== --- gc_lang/fr/webext/manifest.json +++ gc_lang/fr/webext/manifest.json @@ -5,15 +5,15 @@ "version": "${version}", "applications": { "gecko": { "id": "French-GC@grammalecte.net", - "strict_min_version": "57.0" + "strict_min_version": "67.0" } }, - "minimum_chrome_version": "61", + "minimum_chrome_version": "73", "author": "Olivier R.", "homepage_url": "https://grammalecte.net/", "description": "Correcteur grammatical, orthographique et typographique pour le français.",