Grammalecte  Diff

Differences From Artifact [af72bab83b]:

To Artifact [bb0326be30]:


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
_dImpePro = { ":2s": "-toi", ":1p": "-nous", ":2p": "-vous" }
_dImpeProNeg = { ":2s": "ne te ", ":1p": "ne nous ", ":2p": "ne vous " }
_dImpeProEn = { ":2s": "-t’en", ":1p": "-nous-en", ":2p": "-vous-en" }
_dImpeProNegEn = { ":2s": "ne t’en ", ":1p": "ne nous en ", ":2p": "ne vous en " }

_dGroup = { "0": "auxiliaire", "1": "1ᵉʳ groupe", "2": "2ᵉ groupe", "3": "3ᵉ groupe" }

_dTenseIdx = { ":PQ": 0, ":Ip": 1, ":Iq": 2, ":Is": 3, ":If": 4, ":K": 5, ":Sp": 6, ":Sq": 7, ":E": 8 }



def isVerb (sVerb):
    "return True if it’s a existing verb"
    return sVerb in _dVerb








|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
_dImpePro = { ":2s": "-toi", ":1p": "-nous", ":2p": "-vous" }
_dImpeProNeg = { ":2s": "ne te ", ":1p": "ne nous ", ":2p": "ne vous " }
_dImpeProEn = { ":2s": "-t’en", ":1p": "-nous-en", ":2p": "-vous-en" }
_dImpeProNegEn = { ":2s": "ne t’en ", ":1p": "ne nous en ", ":2p": "ne vous en " }

_dGroup = { "0": "auxiliaire", "1": "1ᵉʳ groupe", "2": "2ᵉ groupe", "3": "3ᵉ groupe" }

_dTenseIdx = { ":P": 0, ":Q": 1, ":Ip": 2, ":Iq": 3, ":Is": 4, ":If": 5, ":K": 6, ":Sp": 7, ":Sq": 8, ":E": 9 }



def isVerb (sVerb):
    "return True if it’s a existing verb"
    return sVerb in _dVerb

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
    if sVerb in _dVerbNames:
        # there are names derivated from the verb
        return list(_dVerbNames[sVerb])
    else:
        # we suggest past participles
        tTags = _getTags(sVerb)
        if tTags:
            aSugg = [ _getConjWithTags(sVerb, tTags, ":PQ", ":Q1") ]
            if _hasConjWithTags(tTags, ":PQ", ":Q2"):
                aSugg.append(_getConjWithTags(sVerb, tTags, ":PQ", ":Q2"))
            if _hasConjWithTags(tTags, ":PQ", ":Q3"):
                aSugg.append(_getConjWithTags(sVerb, tTags, ":PQ", ":Q3"))
            if _hasConjWithTags(tTags, ":PQ", ":Q4"):
                aSugg.append(_getConjWithTags(sVerb, tTags, ":PQ", ":Q4"))
            # if there is only one past participle (epi inv), unreliable.
            return aSugg  if len(aSugg) > 1  else []
        return []


def getConjSimilInfiV1 (sInfi):
    "returns verbal forms phonetically similar to infinitive form (for verb in group 1)"







|
|
|
|
|
|
|







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
    if sVerb in _dVerbNames:
        # there are names derivated from the verb
        return list(_dVerbNames[sVerb])
    else:
        # we suggest past participles
        tTags = _getTags(sVerb)
        if tTags:
            aSugg = [ _getConjWithTags(sVerb, tTags, ":Q", ":m:s") ]
            if _hasConjWithTags(tTags, ":Q", ":f:s"):
                aSugg.append(_getConjWithTags(sVerb, tTags, ":Q", ":f:s"))
            if _hasConjWithTags(tTags, ":Q", ":m:p"):
                aSugg.append(_getConjWithTags(sVerb, tTags, ":Q", ":m:p"))
            if _hasConjWithTags(tTags, ":Q", ":f:p"):
                aSugg.append(_getConjWithTags(sVerb, tTags, ":Q", ":f:p"))
            # if there is only one past participle (epi inv), unreliable.
            return aSugg  if len(aSugg) > 1  else []
        return []


def getConjSimilInfiV1 (sInfi):
    "returns verbal forms phonetically similar to infinitive form (for verb in group 1)"
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
            self.nPronominable = 2
        else:
            self.sProLabel = "# erreur #"
            self.nPronominable = -1
        self.dConj = {
            ":Y": {
                "label": "Infinitif",
                ":": sVerb,
            },
            ":P": {
                "label": "Participe présent",
                ":": _getConjWithTags(sVerb, self._tTags, ":PQ", ":P"),
            },
            ":Q": {
                "label": "Participes passés",
                ":Q1": _getConjWithTags(sVerb, self._tTags, ":PQ", ":Q1"),
                ":Q2": _getConjWithTags(sVerb, self._tTags, ":PQ", ":Q2"),
                ":Q3": _getConjWithTags(sVerb, self._tTags, ":PQ", ":Q3"),
                ":Q4": _getConjWithTags(sVerb, self._tTags, ":PQ", ":Q4"),
            },
            ":Ip": {
                "label": "Présent",
                ":1s": _getConjWithTags(sVerb, self._tTags, ":Ip", ":1s"),
                ":1ś": _getConjWithTags(sVerb, self._tTags, ":Ip", ":1ś"),
                ":2s": _getConjWithTags(sVerb, self._tTags, ":Ip", ":2s"),
                ":3s": _getConjWithTags(sVerb, self._tTags, ":Ip", ":3s"),







|



|



|
|
|
|







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
            self.nPronominable = 2
        else:
            self.sProLabel = "# erreur #"
            self.nPronominable = -1
        self.dConj = {
            ":Y": {
                "label": "Infinitif",
                ":Y": sVerb,
            },
            ":P": {
                "label": "Participe présent",
                ":P": _getConjWithTags(sVerb, self._tTags, ":P", ":P"),
            },
            ":Q": {
                "label": "Participes passés",
                ":m:s": _getConjWithTags(sVerb, self._tTags, ":Q", ":m:s"),
                ":f:s": _getConjWithTags(sVerb, self._tTags, ":Q", ":f:s"),
                ":m:p": _getConjWithTags(sVerb, self._tTags, ":Q", ":m:p"),
                ":f:p": _getConjWithTags(sVerb, self._tTags, ":Q", ":f:p"),
            },
            ":Ip": {
                "label": "Présent",
                ":1s": _getConjWithTags(sVerb, self._tTags, ":Ip", ":1s"),
                ":1ś": _getConjWithTags(sVerb, self._tTags, ":Ip", ":1ś"),
                ":2s": _getConjWithTags(sVerb, self._tTags, ":Ip", ":2s"),
                ":3s": _getConjWithTags(sVerb, self._tTags, ":Ip", ":3s"),
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
        except KeyError:
            traceback.print_exc()
            return "# erreur"

    def participePresent (self, bPro, bNeg, bTpsCo, bInt, bFem):
        "returns string (conjugaison du participe présent)"
        try:
            if not self.dConj[":P"][":"]:
                return ""
            if bTpsCo:
                sPartPre = _getConjWithTags(self.sVerbAux, self._tTagsAux, ":PQ", ":P")  if not bPro  else  getConj("être", ":PQ", ":P")
            else:
                sPartPre = self.dConj[":P"][":"]
            if not sPartPre:
                return ""
            bEli = bool(_zStartVoy.search(sPartPre))
            if bPro:
                if self.bProWithEn:
                    sPartPre = "s’en " + sPartPre
                else:







|


|

|







329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
        except KeyError:
            traceback.print_exc()
            return "# erreur"

    def participePresent (self, bPro, bNeg, bTpsCo, bInt, bFem):
        "returns string (conjugaison du participe présent)"
        try:
            if not self.dConj[":P"][":P"]:
                return ""
            if bTpsCo:
                sPartPre = _getConjWithTags(self.sVerbAux, self._tTagsAux, ":P", ":P")  if not bPro  else  getConj("être", ":P", ":P")
            else:
                sPartPre = self.dConj[":P"][":P"]
            if not sPartPre:
                return ""
            bEli = bool(_zStartVoy.search(sPartPre))
            if bPro:
                if self.bProWithEn:
                    sPartPre = "s’en " + sPartPre
                else:
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
        except (KeyError, TypeError, IndexError):
            traceback.print_exc()
            return "# erreur"

    def _seekPpas (self, bPro, bFem, bPlur):
        try:
            if not bPro and self.sVerbAux == "avoir":
                return self.dConj[":Q"][":Q1"]
            if not bFem:
                return self.dConj[":Q"][":Q2"]  if bPlur and self.dConj[":Q"][":Q2"]  else  self.dConj[":Q"][":Q1"]
            if not bPlur:
                return self.dConj[":Q"][":Q3"]  if self.dConj[":Q"][":Q3"]  else  self.dConj[":Q"][":Q1"]
            return self.dConj[":Q"][":Q4"]  if self.dConj[":Q"][":Q4"]  else  self.dConj[":Q"][":Q1"]
        except KeyError:
            traceback.print_exc()
            return "# erreur"

    def createConjTable (self, bPro=False, bNeg=False, bTpsCo=False, bInt=False, bFem=False):
        "return a dictionary of all conjugations with titles, according to options (used to be displayed as is)"
        dConjTable = {
            "t_infi":   "Infinitif",
            "infi":     self.infinitif(bPro, bNeg, bTpsCo, bInt, bFem),
            "t_ppre":   "Participe présent",
            "ppre":     self.participePresent(bPro, bNeg, bTpsCo, bInt, bFem),
            "t_ppas":   "Participes passés",
            "ppas1":    self.participePasse(":Q1"),
            "ppas2":    self.participePasse(":Q2"),
            "ppas3":    self.participePasse(":Q3"),
            "ppas4":    self.participePasse(":Q4"),
            "t_imp":    "Impératif",
            "t_impe":   ""  if bInt  else "Présent"  if not bTpsCo  else "Passé",
            "impe1":    self.imperatif(":2s", bPro, bNeg, bTpsCo, bFem)  if not bInt  else "",
            "impe2":    self.imperatif(":1p", bPro, bNeg, bTpsCo, bFem)  if not bInt  else "",
            "impe3":    self.imperatif(":2p", bPro, bNeg, bTpsCo, bFem)  if not bInt  else "",
            "t_indi":   "Indicatif",
            "t_ipre":   "Présent"      if not bTpsCo  else "Passé composé",







|

|

|
|












|
|
|
|







447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
        except (KeyError, TypeError, IndexError):
            traceback.print_exc()
            return "# erreur"

    def _seekPpas (self, bPro, bFem, bPlur):
        try:
            if not bPro and self.sVerbAux == "avoir":
                return self.dConj[":Q"][":m:s"]
            if not bFem:
                return self.dConj[":Q"][":f:s"]  if bPlur and self.dConj[":Q"][":f:s"]  else  self.dConj[":Q"][":m:s"]
            if not bPlur:
                return self.dConj[":Q"][":m:p"]  if self.dConj[":Q"][":m:p"]  else  self.dConj[":Q"][":m:s"]
            return self.dConj[":Q"][":f:p"]  if self.dConj[":Q"][":f:p"]  else  self.dConj[":Q"][":m:s"]
        except KeyError:
            traceback.print_exc()
            return "# erreur"

    def createConjTable (self, bPro=False, bNeg=False, bTpsCo=False, bInt=False, bFem=False):
        "return a dictionary of all conjugations with titles, according to options (used to be displayed as is)"
        dConjTable = {
            "t_infi":   "Infinitif",
            "infi":     self.infinitif(bPro, bNeg, bTpsCo, bInt, bFem),
            "t_ppre":   "Participe présent",
            "ppre":     self.participePresent(bPro, bNeg, bTpsCo, bInt, bFem),
            "t_ppas":   "Participes passés",
            "ppas1":    self.participePasse(":m:s"),
            "ppas2":    self.participePasse(":f:s"),
            "ppas3":    self.participePasse(":m:p"),
            "ppas4":    self.participePasse(":f:p"),
            "t_imp":    "Impératif",
            "t_impe":   ""  if bInt  else "Présent"  if not bTpsCo  else "Passé",
            "impe1":    self.imperatif(":2s", bPro, bNeg, bTpsCo, bFem)  if not bInt  else "",
            "impe2":    self.imperatif(":1p", bPro, bNeg, bTpsCo, bFem)  if not bInt  else "",
            "impe3":    self.imperatif(":2p", bPro, bNeg, bTpsCo, bFem)  if not bInt  else "",
            "t_indi":   "Indicatif",
            "t_ipre":   "Présent"      if not bTpsCo  else "Passé composé",