Grammalecte  Check-in [456aa2a2aa]

Overview
Comment:[lo][fr][py] générateur de conjugaisons: nouvelles fonctions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fr | lo | multid
Files: files | file ages | folders
SHA3-256: 456aa2a2aa3f0dc66e0693b16c7f8439c579e06db35b00ddce026d8086078dc4
User & Date: olr on 2018-03-06 16:44:41
Original Comment: [lo][fr] générateur de conjugaisons: nouvelles fonctions
Other Links: branch diff | manifest | tags
Context
2018-03-06
18:16
[fx][fr][js] générateur de conjugaisons: nouvelles fonctions check-in: 0230771aa5 user: olr tags: fr, fx, multid
16:44
[lo][fr][py] générateur de conjugaisons: nouvelles fonctions check-in: 456aa2a2aa user: olr tags: fr, lo, multid
15:38
[core][fr] générateur de conjugaisons comme module (déplacement de fichiers) check-in: fb9f2914eb user: olr tags: core, fr, multid
Changes

Modified gc_lang/fr/modules/conj_generator.py from [2b6010474b] to [908448219c].

1

2
3

4
5
6

















































7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Conjugation data


# beta stage, unfinished, may be useless or the root for a new way to generate flexions…


# Règles de conjugaison


















































oConj = {
    "V1_ppas": {
        "var": [
            [2,     "é",           ":Q:A:1ŝ:m:s/*",     False],
            [2,     "és",          ":Q:A:m:p/*",        False],
            [2,     "ée",          ":Q:A:f:s/*",        False],
            [2,     "ées",         ":Q:A:f:p/*",        False],
        ],
        "invar": [
            [2,     "é",           ":Q:e:i/*",          False],
        ]
    },

    "V2_ppas": {
        "var": [
            [2,     "i",           ":Q:A:m:s/*",        False],
            [2,     "is",          ":Q:A:m:p/*",        False],
            [2,     "ie",          ":Q:A:f:s/*",        False],
            [2,     "ies",         ":Q:A:f:p/*",        False],
        ],
        "invar": [
            [2,     "i",           ":Q:e:i/*",          False],
        ]
    },

    # deuxième groupe (le seul groupe régulier)
    "V2": [
        [2,     "ir",           ":Y/*",             False],
|
>

<
>

<

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|





|





|





|







1
2
3

4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
# Conjugation generator
# beta stage, unfinished, the root for a new way to generate flexions…


import re



def conjugate (sVerb, sVerbTag="i_____a", bVarPpas=True):
    lConj = []
    cGroup = getVerbGroupChar(sVerb)
    for nCut, sAdd, sFlexTags, sPattern in getConjRules(sVerb):
        if not sPattern or re.search(sPattern, sVerb):
            lConj.append((sVerb[0:-nCut]+sAdd, ":V" + cGroup + "_" + sVerbTag + sFlexTags))
    return lConj


def getVerbGroupChar (sVerb, ):
    sVerb = sVerb.lower()
    if sVerb.endswith("er"):
        return "1"
    if sVerb.endswith("ir"):
        return "2"
    if sVerb == "être" or sVerb == "avoir":
        return "0"
    if sVerb.endswith("re"):
        return "3"
    return "4"


def getConjRules (sVerb, bVarPpas=True, nGroup=2):
    if sVerb.endswith("er"):
        # premier groupe, conjugaison en fonction de la terminaison du lemme
        # 5 lettres
        if sVerb[-5:] in oConj["V1"]:
            lConj = oConj["V1"][sVerb[-5:]]
        # 4 lettres
        elif sVerb[-4:] in oConj["V1"]:
            if sVerb.endswith(("eler", "eter")):
                lConj = oConj["V1"][sVerb[-4:]]["1"]
            lConj = oConj["V1"][sVerb[-4:]]
        # 3 lettres
        elif sVerb[-3:] in oConj["V1"]:
            lConj = oConj["V1"][sVerb[-3:]]
        else:
            lConj = oConj["V1"]["er"]
        lConj.extend(oConj["V1_ppas"][bVarPpas])
    elif sVerb.endswith("ir") and nGroup <= 2:
        # deuxième groupe
        lConj = oConj["V2"]
        lConj.extend(oConj["V2_ppas"][bVarPpas])
    else:
        # TODO: troisième groupe
        lConj = [ [0, "", ":Y/*", false] ]
    return lConj


oConj = {
    "V1_ppas": {
        True: [
            [2,     "é",           ":Q:A:1ŝ:m:s/*",     False],
            [2,     "és",          ":Q:A:m:p/*",        False],
            [2,     "ée",          ":Q:A:f:s/*",        False],
            [2,     "ées",         ":Q:A:f:p/*",        False],
        ],
        False: [
            [2,     "é",           ":Q:e:i/*",          False],
        ]
    },

    "V2_ppas": {
        True: [
            [2,     "i",           ":Q:A:m:s/*",        False],
            [2,     "is",          ":Q:A:m:p/*",        False],
            [2,     "ie",          ":Q:A:f:s/*",        False],
            [2,     "ies",         ":Q:A:f:p/*",        False],
        ],
        False: [
            [2,     "i",           ":Q:e:i/*",          False],
        ]
    },

    # deuxième groupe (le seul groupe régulier)
    "V2": [
        [2,     "ir",           ":Y/*",             False],

Modified gc_lang/fr/oxt/DictOptions/LexiconEditor.py from [afd65cf50b] to [2c842dcb12].

397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
...
442
443
444
445
446
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
                    c_m = "m"  if self.xV_m.State  else "_"
                    c_ae = "e"  if self.xV_ae.State  else "_"
                    c_aa = "a"  if self.xV_aa.State  else "_"
                    sVerbTag = c_i + c_t + c_n + c_p + c_m + c_ae + c_aa
                    if not sVerbTag.endswith("__") and not sVerbTag.startswith("____"):
                        sVerbPattern = self.xVpattern.Text.strip()
                        if not sVerbPattern:
                            if sLemma.endswith("er") or sLemma.endswith("ir"):
                                # tables de conjugaison du 1er et du 2e groupe
                                cGroup = "1"  if sLemma.endswith("er")  else "2"
                                for nCut, sAdd, sFlexTags, sPattern in self._getConjRules(sLemma):
                                    if not sPattern or re.search(sPattern, sLemma):
                                        self.lGeneratedFlex.append((sLemma[0:-nCut]+sAdd, sLemma, ":V" + cGroup + "_" + sVerbTag + sFlexTags))
                                # participes passés
                                bPpasVar = "var"  if self.xV_pp.State  else "invar"
                                lPpasRules = conjgen.oConj["V1_ppas"][bPpasVar]  if sLemma.endswith("er")  else conjgen.oConj["V2_ppas"][bPpasVar]
                                for nCut, sAdd, sFlexTags, sPattern in lPpasRules:
                                    if not sPattern or re.search(sPattern, sLemma):
                                        self.lGeneratedFlex.append((sLemma[0:-nCut]+sAdd, sLemma, ":V" + cGroup + "_" + sVerbTag + sFlexTags))
                        else:
                            # copie du motif d’un autre verbe : utilisation du conjugueur
                            if conj.isVerb(sVerbPattern):
                                oVerb = conj.Verb(sLemma, sVerbPattern)
                                for sTag1, dFlex in oVerb.dConj.items():
                                    if sTag1 != ":Q":
                                        for sTag2, sConj in dFlex.items():
................................................................................
                # Autre
                sFlexion = self.xFlexion.Text.strip()
                sTags = self.xTags.Text.strip()
                if sFlexion and sTags.startswith(":"):
                    self.lGeneratedFlex.append((sFlexion, sLemma, sTags))
        self._showGenWords()

    def _getConjRules (self, sVerb):
        if sVerb.endswith("ir"):
            # deuxième groupe
            return conjgen.oConj["V2"]
        elif sVerb.endswith("er"):
            # premier groupe, conjugaison en fonction de la terminaison du lemme
            # 5 lettres
            if sVerb[-5:] in conjgen.oConj["V1"]:
                return conjgen.oConj["V1"][sVerb[-5:]]
            # 4 lettres
            if sVerb[-4:] in conjgen.oConj["V1"]:
                if sVerb.endswith(("eler", "eter")):
                    return conjgen.oConj["V1"][sVerb[-4:]]["1"]
                return conjgen.oConj["V1"][sVerb[-4:]]
            # 3 lettres
            if sVerb[-3:] in conjgen.oConj["V1"]:
                return conjgen.oConj["V1"][sVerb[-3:]]
            return conjgen.oConj["V1"]["er"]
        else:
            # troisième groupe
            return [ [0, "", ":Y/*", false] ]

    def _showGenWords (self):
        xGridDataModel = self.xGridModelNew.GridDataModel
        xGridDataModel.removeAllRows()
        if not self.lGeneratedFlex:
            self.xAdd.Enabled = False
            return
        for i, (sFlexion, sLemma, sTag) in enumerate(self.lGeneratedFlex):







|
|
<
<
<
|
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







397
398
399
400
401
402
403
404
405



406






407
408
409
410
411
412
413
...
433
434
435
436
437
438
439






















440
441
442
443
444
445
446
                    c_m = "m"  if self.xV_m.State  else "_"
                    c_ae = "e"  if self.xV_ae.State  else "_"
                    c_aa = "a"  if self.xV_aa.State  else "_"
                    sVerbTag = c_i + c_t + c_n + c_p + c_m + c_ae + c_aa
                    if not sVerbTag.endswith("__") and not sVerbTag.startswith("____"):
                        sVerbPattern = self.xVpattern.Text.strip()
                        if not sVerbPattern:
                            # Utilisation du générateur de conjugaison
                            for sFlexion, sFlexTags in conjgen.conjugate(sLemma, sVerbTag, bool(self.xV_pp.State)):



                                self.lGeneratedFlex.append((sFlexion, sLemma, sFlexTags))






                        else:
                            # copie du motif d’un autre verbe : utilisation du conjugueur
                            if conj.isVerb(sVerbPattern):
                                oVerb = conj.Verb(sLemma, sVerbPattern)
                                for sTag1, dFlex in oVerb.dConj.items():
                                    if sTag1 != ":Q":
                                        for sTag2, sConj in dFlex.items():
................................................................................
                # Autre
                sFlexion = self.xFlexion.Text.strip()
                sTags = self.xTags.Text.strip()
                if sFlexion and sTags.startswith(":"):
                    self.lGeneratedFlex.append((sFlexion, sLemma, sTags))
        self._showGenWords()























    def _showGenWords (self):
        xGridDataModel = self.xGridModelNew.GridDataModel
        xGridDataModel.removeAllRows()
        if not self.lGeneratedFlex:
            self.xAdd.Enabled = False
            return
        for i, (sFlexion, sLemma, sTag) in enumerate(self.lGeneratedFlex):