Grammalecte  Diff

Differences From Artifact [2b6010474b]:

To Artifact [908448219c]:


     1         -# Conjugation data
            1  +# Conjugation generator
            2  +# beta stage, unfinished, the root for a new way to generate flexions…
     2      3   
     3         -# beta stage, unfinished, may be useless or the root for a new way to generate flexions…
            4  +import re
     4      5   
     5         -# Règles de conjugaison
            6  +
            7  +def conjugate (sVerb, sVerbTag="i_____a", bVarPpas=True):
            8  +    lConj = []
            9  +    cGroup = getVerbGroupChar(sVerb)
           10  +    for nCut, sAdd, sFlexTags, sPattern in getConjRules(sVerb):
           11  +        if not sPattern or re.search(sPattern, sVerb):
           12  +            lConj.append((sVerb[0:-nCut]+sAdd, ":V" + cGroup + "_" + sVerbTag + sFlexTags))
           13  +    return lConj
           14  +
           15  +
           16  +def getVerbGroupChar (sVerb, ):
           17  +    sVerb = sVerb.lower()
           18  +    if sVerb.endswith("er"):
           19  +        return "1"
           20  +    if sVerb.endswith("ir"):
           21  +        return "2"
           22  +    if sVerb == "être" or sVerb == "avoir":
           23  +        return "0"
           24  +    if sVerb.endswith("re"):
           25  +        return "3"
           26  +    return "4"
           27  +
           28  +
           29  +def getConjRules (sVerb, bVarPpas=True, nGroup=2):
           30  +    if sVerb.endswith("er"):
           31  +        # premier groupe, conjugaison en fonction de la terminaison du lemme
           32  +        # 5 lettres
           33  +        if sVerb[-5:] in oConj["V1"]:
           34  +            lConj = oConj["V1"][sVerb[-5:]]
           35  +        # 4 lettres
           36  +        elif sVerb[-4:] in oConj["V1"]:
           37  +            if sVerb.endswith(("eler", "eter")):
           38  +                lConj = oConj["V1"][sVerb[-4:]]["1"]
           39  +            lConj = oConj["V1"][sVerb[-4:]]
           40  +        # 3 lettres
           41  +        elif sVerb[-3:] in oConj["V1"]:
           42  +            lConj = oConj["V1"][sVerb[-3:]]
           43  +        else:
           44  +            lConj = oConj["V1"]["er"]
           45  +        lConj.extend(oConj["V1_ppas"][bVarPpas])
           46  +    elif sVerb.endswith("ir") and nGroup <= 2:
           47  +        # deuxième groupe
           48  +        lConj = oConj["V2"]
           49  +        lConj.extend(oConj["V2_ppas"][bVarPpas])
           50  +    else:
           51  +        # TODO: troisième groupe
           52  +        lConj = [ [0, "", ":Y/*", false] ]
           53  +    return lConj
           54  +
     6     55   
     7     56   oConj = {
     8     57       "V1_ppas": {
     9         -        "var": [
           58  +        True: [
    10     59               [2,     "é",           ":Q:A:1ŝ:m:s/*",     False],
    11     60               [2,     "és",          ":Q:A:m:p/*",        False],
    12     61               [2,     "ée",          ":Q:A:f:s/*",        False],
    13     62               [2,     "ées",         ":Q:A:f:p/*",        False],
    14     63           ],
    15         -        "invar": [
           64  +        False: [
    16     65               [2,     "é",           ":Q:e:i/*",          False],
    17     66           ]
    18     67       },
    19     68   
    20     69       "V2_ppas": {
    21         -        "var": [
           70  +        True: [
    22     71               [2,     "i",           ":Q:A:m:s/*",        False],
    23     72               [2,     "is",          ":Q:A:m:p/*",        False],
    24     73               [2,     "ie",          ":Q:A:f:s/*",        False],
    25     74               [2,     "ies",         ":Q:A:f:p/*",        False],
    26     75           ],
    27         -        "invar": [
           76  +        False: [
    28     77               [2,     "i",           ":Q:e:i/*",          False],
    29     78           ]
    30     79       },
    31     80   
    32     81       # deuxième groupe (le seul groupe régulier)
    33     82       "V2": [
    34     83           [2,     "ir",           ":Y/*",             False],