Grammalecte  Check-in [a89587a82c]

Overview
Comment:[fr][bug] conj: test if tTags exists
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fr | multid
Files: files | file ages | folders
SHA3-256: a89587a82cb64d98235ed2288c9887000ca8fd3bcdcd012cf662e27a9d89e330
User & Date: olr on 2018-04-01 09:31:18
Other Links: branch diff | manifest | tags
Context
2018-04-01
11:23
[fx] lexicon editor: fix label Closed-Leaf check-in: 61c499e9ea user: olr tags: fx, multid
09:31
[fr][bug] conj: test if tTags exists check-in: a89587a82c user: olr tags: fr, multid
08:16
[graphspell] new header <grammalecte-fsa> for binary dictionaries check-in: 8333a8bf1b user: olr tags: graphspell, multid
Changes

Modified gc_lang/fr/modules-js/conj.js from [4a1c359666] to [f544af05b0].

84
85
86
87
88
89
90
91
92


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127




































128
129
130
131
132
133
134
84
85
86
87
88
89
90

91
92
93



































94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136







-

+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







    },

    getSimil: function (sWord, sMorph, bSubst=false) {
        if (!sMorph.includes(":V")) {
            return new Set();
        }
        let sInfi = sMorph.slice(1, sMorph.indexOf(" "));
        let tTags = this._getTags(sInfi);
        let aSugg = new Set();
        let tTags = this._getTags(sInfi);
        if (tTags) {
        if (!bSubst) {
            // we suggest conjugated forms
            if (sMorph.includes(":V1")) {
                aSugg.add(sInfi);
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":2p"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":1s"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":3s"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":3p"));
            } else if (sMorph.includes(":V2")) {
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":1s"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
            } else if (sMorph.includes(":V3")) {
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":1s"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Is", ":1s"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":Is", ":3s"));
            } else if (sMorph.includes(":V0a")) {
                aSugg.add("eus");
                aSugg.add("eut");
            } else {
                aSugg.add("étais");
                aSugg.add("était");
            }
            aSugg.delete("");
        } else {
            // we suggest past participles
            aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q1"));
            aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q2"));
            aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q3"));
            aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q4"));
            aSugg.delete("");
            // if there is only one past participle (epi inv), unreliable.
            if (aSugg.size === 1) {
                aSugg.clear();
            if (!bSubst) {
                // we suggest conjugated forms
                if (sMorph.includes(":V1")) {
                    aSugg.add(sInfi);
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":2p"));
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":1s"));
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":3s"));
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":3p"));
                } else if (sMorph.includes(":V2")) {
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":1s"));
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
                } else if (sMorph.includes(":V3")) {
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":1s"));
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Is", ":1s"));
                    aSugg.add(this._getConjWithTags(sInfi, tTags, ":Is", ":3s"));
                } else if (sMorph.includes(":V0a")) {
                    aSugg.add("eus");
                    aSugg.add("eut");
                } else {
                    aSugg.add("étais");
                    aSugg.add("était");
                }
                aSugg.delete("");
            } else {
                // we suggest past participles
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q1"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q2"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q3"));
                aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q4"));
                aSugg.delete("");
                // if there is only one past participle (epi inv), unreliable.
                if (aSugg.size === 1) {
                    aSugg.clear();
                }
            }
        }
        return aSugg;
    },

    _getTags: function (sVerb) {
        // returns tuple of tags (usable with functions _getConjWithTags and _hasConjWithTags)
179
180
181
182
183
184
185
186

187
188
189
190
191
192
193
194
195



196
197
198
199
200
201
202
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207







-
+









+
+
+









class Verb {

    constructor (sVerb, sVerbPattern="") {
        // conjugate a unknown verb with rules from sVerbPattern
        if (typeof sVerb !== "string" || sVerb === "") {
            throw new TypeError ("The value should be a non-empty string");
            throw new TypeError ("The value should be a non-empty string.");
        }
        if (sVerbPattern.length == 0) {
            sVerbPattern = sVerb;
        }
        this.sVerb = sVerb;
        this.sVerbAux = "";
        this._sRawInfo = conj.getVtyp(sVerbPattern);
        this.sInfo = this._readableInfo(this._sRawInfo);
        this._tTags = conj._getTags(sVerbPattern);
        if (!this._tTags) {
            throw new RangeError ("Unknown verb.");
        }
        this._tTagsAux = conj._getTags(this.sVerbAux);
        this.bProWithEn = (this._sRawInfo[5] === "e");
        this.cGroup = this._sRawInfo[0];
        this.dConj = new Map ([
            [":Y", new Map ([
                ["label", "Infinitif"],
                [":", sVerb]

Modified gc_lang/fr/modules/conj.py from [75ccfbe917] to [c668aaf269].

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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98



































99
100
101
102
103
104
105
106


107
108
109
110
111
112
113







114
115
116
117
118
119
120
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

105
106
107







108
109
110
111
112
113
114
115
116
117
118
119
120
121







-

+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+






-

+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+







    return _lVtyp[_dVerb[sVerb][0]]


def getSimil (sWord, sMorph, bSubst=False):
    if ":V" not in sMorph:
        return set()
    sInfi = sMorph[1:sMorph.find(" ")]
    tTags = _getTags(sInfi)
    aSugg = set()
    tTags = _getTags(sInfi)
    #if ":Q" in sMorph or ":Y" in sMorph:
    if not bSubst:
        # we suggest conjugated forms
        if ":V1" in sMorph:
            aSugg.add(sInfi)
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":3s"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":2p"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":1s"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3s"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3p"))
        elif ":V2" in sMorph:
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":1s"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":3s"))
        elif ":V3" in sMorph:
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":1s"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":3s"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Is", ":1s"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":Is", ":3s"))
        elif ":V0a" in sMorph:
            aSugg.add("eus")
            aSugg.add("eut")
        else:
            aSugg.add("étais")
            aSugg.add("était")
        aSugg.discard("")
    else:
        # we suggest past participles
        aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q1"))
        aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q2"))
        aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q3"))
        aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q4"))
        aSugg.discard("")
        # if there is only one past participle (epi inv), unreliable.
        if len(aSugg) == 1:
            aSugg.clear()
    if tTags:
        if not bSubst:
            # we suggest conjugated forms
            if ":V1" in sMorph:
                aSugg.add(sInfi)
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":3s"))
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":2p"))
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":1s"))
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3s"))
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3p"))
            elif ":V2" in sMorph:
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":1s"))
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":3s"))
            elif ":V3" in sMorph:
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":1s"))
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":3s"))
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Is", ":1s"))
                aSugg.add(_getConjWithTags(sInfi, tTags, ":Is", ":3s"))
            elif ":V0a" in sMorph:
                aSugg.add("eus")
                aSugg.add("eut")
            else:
                aSugg.add("étais")
                aSugg.add("était")
            aSugg.discard("")
        else:
            # we suggest past participles
            aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q1"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q2"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q3"))
            aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q4"))
            aSugg.discard("")
            # if there is only one past participle (epi inv), unreliable.
            if len(aSugg) == 1:
                aSugg.clear()
    return aSugg


def getConjSimilInfiV1 (sInfi):
    if sInfi not in _dVerb:
        return set()
    tTags = _getTags(sInfi)
    aSugg = set()
    tTags = _getTags(sInfi)
    if tTags:
    aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":2s"))
    aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3s"))
    aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3p"))
    aSugg.add(_getConjWithTags(sInfi, tTags, ":Is", ":1s"))
    aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":2p"))
    aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":2p"))
    aSugg.discard("")
        aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":2s"))
        aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3s"))
        aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3p"))
        aSugg.add(_getConjWithTags(sInfi, tTags, ":Is", ":1s"))
        aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":2p"))
        aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":2p"))
        aSugg.discard("")
    return aSugg


def _getTags (sVerb):
    "returns tuple of tags (usable with functions _getConjWithTags and _hasConjWithTags)"
    if sVerb not in _dVerb:
        return None
146
147
148
149
150
151
152
153

154
155

156
157
158
159
160
161
162
163
164
165


166
167
168
169
170
171
172
147
148
149
150
151
152
153

154
155

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175







-
+

-
+










+
+







        


class Verb ():
    def __init__ (self, sVerb, sVerbPattern=""):
        # conjugate a unknown verb with rules from sVerbPattern
        if not isinstance(sVerb, str):
            raise TypeError
            raise TypeError("sVerb should be a string")
        if not sVerb:
            raise ValueError
            raise ValueError("Empty string.")

        if sVerbPattern == "":
            sVerbPattern = sVerb

        self.sVerb = sVerb
        self.sVerbAux = ""
        self._sRawInfo = getVtyp(sVerbPattern)
        self.sInfo = self._readableInfo()
        self.bProWithEn = (self._sRawInfo[5] == "e")
        self._tTags = _getTags(sVerbPattern)
        if not self._tTags:
            raise ValueError("Unknown verb.")
        self._tTagsAux = _getTags(self.sVerbAux)
        self.cGroup = self._sRawInfo[0];
        self.dConj = {
            ":Y": {
                "label": "Infinitif",
                ":": sVerb,
            },