Index: gc_lang/fr/modules/gce_suggestions.py ================================================================== --- gc_lang/fr/modules/gce_suggestions.py +++ gc_lang/fr/modules/gce_suggestions.py @@ -5,12 +5,26 @@ from . import phonet ## Verbs -def suggVerb (sFlex, sWho, funcSugg2=None): +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")): + iRight = sVerb.rfind("-") + sSuffix = sVerb[iRight:] + sSuffix + sVerb = sVerb[:iRight] + return sVerb, sSuffix + + +def suggVerb (sFlex, sWho, funcSugg2=None, bVC=False): "change conjugation according to " + if bVC: + sFlex, sSfx = splitVerb(sFlex) aSugg = set() for sStem in _oSpellChecker.getLemma(sFlex): tTags = conj._getTags(sStem) if tTags: # we get the tense @@ -35,10 +49,12 @@ if funcSugg2: aSugg2 = funcSugg2(sFlex) if aSugg2: aSugg.add(aSugg2) if aSugg: + if bVC: + aSugg = list(map(lambda sSug: sSug + sSfx, aSugg)) return "|".join(aSugg) return "" def suggVerbPpas (sFlex, sPattern=None): @@ -377,17 +393,21 @@ def hasSimil (sWord, sPattern=None): "return True if there is words phonetically similar to (according to if required)" return phonet.hasSimil(sWord, sPattern) -def suggSimil (sWord, sPattern=None, bSubst=False): +def suggSimil (sWord, sPattern=None, bSubst=False, bVC=False): "return list of words phonetically similar to sWord and whom POS is matching sPattern" + if bVC: + sWord, sSfx = splitVerb(sWord) aSugg = phonet.selectSimil(sWord, sPattern) 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)) return "|".join(aSugg) return "" def suggCeOrCet (sWord):