Grammalecte  Check-in [2ce9bd0c2a]

Overview
Comment:[fr][bug] conj generator: clone array/list before adding elements
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fr | multid
Files: files | file ages | folders
SHA3-256: 2ce9bd0c2a7213875b717deb3099fbade3c36ba24ddc9396973154ddf18a30b5
User & Date: olr on 2018-03-11 23:28:14
Original Comment: [fr][bug] clone array/list before adding elements
Other Links: branch diff | manifest | tags
Context
2018-03-11
23:39
[fr][js] conj generator: Array.from() is much more readable than .slice(0) to clone an Array check-in: 33dbc61ec2 user: olr tags: fr, multid
23:28
[fr][bug] conj generator: clone array/list before adding elements check-in: 2ce9bd0c2a user: olr tags: fr, multid
22:22
[fx] lexicon editor: ui update check-in: b36b4dcdfe user: olr tags: fx, multid
Changes

Modified gc_lang/fr/modules-js/conj_generator.js from [5170da2586] to [d5f86107a9].

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
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







+






-
+




-
+

-
+




-
+



-
+

-
-

+
-
+

-
+

+
-
+







        if (sVerb.endsWith("re")) {
            return "3";
        }
        return "4";
    },

    getConjRules: function (sVerb, bVarPpas=true, nGroup=2) {
        // .slice(0): clone an Array
        let lConj = null;
        let sVarPpas = (bVarPpas) ? "true" : "false";
        if (sVerb.endsWith("er")) {
            // premier groupe, conjugaison en fonction de la terminaison du lemme
            // 5 lettres
            if (sVerb.slice(-5) in this.oConj["V1"]) {
                lConj = this.oConj["V1"][sVerb.slice(-5)];
                lConj = this.oConj["V1"][sVerb.slice(-5)].slice(0);
            }
            // 4 lettres
            else if (sVerb.slice(-4) in this.oConj["V1"]) {
                if (sVerb.endsWith("eler") || sVerb.endsWith("eter")) {
                    lConj = this.oConj["V1"][sVerb.slice(-4)]["1"];
                    lConj = this.oConj["V1"][sVerb.slice(-4)]["1"].slice(0);
                } else {
                    lConj = this.oConj["V1"][sVerb.slice(-4)];
                    lConj = this.oConj["V1"][sVerb.slice(-4)].slice(0);
                }
            }
            // 3 lettres
            else if (sVerb.slice(-3) in this.oConj["V1"]) {
                lConj = this.oConj["V1"][sVerb.slice(-3)];
                lConj = this.oConj["V1"][sVerb.slice(-3)].slice(0);
            }
            // 2 lettres
            else {
                lConj = this.oConj["V1"]["er"];
                lConj = this.oConj["V1"]["er"].slice(0);
            }
            //console.log(lConj);
            //console.log(this.oConj["V1_ppas"][sVarPpas]);
            lConj.push(...this.oConj["V1_ppas"][sVarPpas]);
        }
        } else if (sVerb.endsWith("ir") && nGroup <= 2) {
        else if (sVerb.endsWith("ir") && nGroup <= 2) {
            // deuxième groupe
            lConj = this.oConj["V2"];
            lConj = this.oConj["V2"].slice(0);
            lConj.push(...this.oConj["V2_ppas"][sVarPpas]);
        }
        } else {
        else {
            // TODO: troisième groupe
            lConj = [ [0, "", ":Y/*", false] ];
        }
        return lConj;
    },

    oConj: {

Modified gc_lang/fr/modules/conj_generator.py from [c321680ceb] to [4f543d9f23].

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
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







-
+



-
+

-
+


-
+


-
+



-
+









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:]]
            lConj = list(oConj["V1"][sVerb[-5:]])
        # 4 lettres
        elif sVerb[-4:] in oConj["V1"]:
            if sVerb.endswith(("eler", "eter")):
                lConj = oConj["V1"][sVerb[-4:]]["1"]
                lConj = list(oConj["V1"][sVerb[-4:]]["1"])
            else:
                lConj = oConj["V1"][sVerb[-4:]]
                lConj = list(oConj["V1"][sVerb[-4:]])
        # 3 lettres
        elif sVerb[-3:] in oConj["V1"]:
            lConj = oConj["V1"][sVerb[-3:]]
            lConj = list(oConj["V1"][sVerb[-3:]])
        # 2 lettres
        else:
            lConj = oConj["V1"]["er"]
            lConj = list(oConj["V1"]["er"])
        lConj.extend(oConj["V1_ppas"][bVarPpas])
    elif sVerb.endswith("ir") and nGroup <= 2:
        # deuxième groupe
        lConj = oConj["V2"]
        lConj = list(oConj["V2"])
        lConj.extend(oConj["V2_ppas"][bVarPpas])
    else:
        # TODO: troisième groupe
        lConj = [ [0, "", ":Y/*", False] ]
    return lConj