Grammalecte  Check-in [d804292a86]

Overview
Comment:[fx] lexicon editor: conjugate a verb according to another verb
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: d804292a86c12d5a1540dcf4fc95f9d50afd0e92ff6cb7ac60e3f670acd62821
User & Date: olr on 2018-01-29 09:54:13
Other Links: manifest | tags
Context
2018-01-29
19:53
[fx] update: lexicon editor, use verb pattern, + participes passés check-in: d6f8f5c533 user: olr tags: trunk, fx
09:54
[fx] lexicon editor: conjugate a verb according to another verb check-in: d804292a86 user: olr tags: trunk, fx
2018-01-28
18:02
[fx] fix helpers importation from graphspell check-in: eaa436be64 user: olr tags: trunk, fx
Changes

Modified gc_lang/fr/modules-js/conj.js from [8bdb9ef82a] to [5b98fc996d].

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
202
203
204
205
206
207
208
209
210
211
212
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
202
203
204
205
206


207
208
209
210
211
212

213
214
215
216
217
218
219







-
+
+



+
+
+


-
+

-
+





-
+

+
+
+
+
-
-
+
+




-







        }
    }
};


class Verb {

    constructor (sVerb) {
    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");
        }
        if (sVerbPattern.length == 0) {
            sVerbPattern = sVerb;
        }
        this.sVerb = sVerb;
        this.sVerbAux = "";
        this._sRawInfo = conj.getVtyp(this.sVerb);
        this._sRawInfo = conj.getVtyp(sVerbPattern);
        this.sInfo = this._readableInfo(this._sRawInfo);
        this._tTags = conj._getTags(sVerb);
        this._tTags = conj._getTags(sVerbPattern);
        this._tTagsAux = conj._getTags(this.sVerbAux);
        this.bProWithEn = (this._sRawInfo[5] === "e");
        this.dConj = new Map ([
            [":Y", new Map ([
                ["label", "Infinitif"],
                [":Y", sVerb]
                [":", sVerb]
            ])],
            [":P", new Map ([
                ["label", "Participe présent"],
                [":", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":P")]
            ])],
            [":PQ", new Map ([
                ["label", "Participes passés et présent"],
            [":Q", new Map ([
                ["label", "Participes passés"],
                [":Q1", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":Q1")],
                [":Q2", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":Q2")],
                [":Q3", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":Q3")],
                [":Q4", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":Q4")],
                [":P", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":P")]
            ])],
            [":Ip", new Map ([
                ["label", "Présent"],
                [":1s", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":1s")],
                [":1ś", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":1ś")],
                [":2s", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":2s")],
                [":3s", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":3s")],
330
331
332
333
334
335
336
337

338
339
340
341

342
343
344
345
346
347
348

349
350
351
352
353
354
355
337
338
339
340
341
342
343

344
345
346
347

348
349
350
351
352
353
354

355
356
357
358
359
360
361
362







-
+



-
+






-
+







        if (bInt) {
            sInfi += " … ?";
        }
        return sInfi;
    }

    participePasse (sWho) {
        return this.dConj.get(":PQ").get(sWho);
        return this.dConj.get(":Q").get(sWho);
    }

    participePresent (bPro, bNeg, bTpsCo, bInt, bFem) {
        if (!this.dConj.get(":PQ").get(":P")) {
        if (!this.dConj.get(":P").get(":")) {
            return "";
        }
        let sPartPre;
        if (bTpsCo) {
            sPartPre = (!bPro) ? conj._getConjWithTags(this.sVerbAux, this._tTagsAux, ":PQ", ":P") : conj.getConj("être", ":PQ", ":P");
        } else {
            sPartPre = this.dConj.get(":PQ").get(":P");
            sPartPre = this.dConj.get(":P").get(":");
        }
        if (sPartPre === "") {
            return "";
        }
        let bEli = conj._zStartVoy.test(sPartPre);
        if (bPro) {
            if (this.bProWithEn) {
465
466
467
468
469
470
471
472

473
474
475

476
477
478

479
480

481
482
483
484
485
486
487
472
473
474
475
476
477
478

479
480
481

482
483
484

485
486

487
488
489
490
491
492
493
494







-
+


-
+


-
+

-
+







            return sImpe + " " + this._seekPpas(bPro, bFem, sWho.endsWith("p") || this._sRawInfo[5] == "r");
        }
        return sImpe;
    }

    _seekPpas (bPro, bFem, bPlur) {
        if (!bPro && this.sVerbAux == "avoir") {
            return this.dConj.get(":PQ").get(":Q1");
            return this.dConj.get(":Q").get(":Q1");
        }
        if (!bFem) {
            return (bPlur && this.dConj.get(":PQ").get(":Q2")) ? this.dConj.get(":PQ").get(":Q2") : this.dConj.get(":PQ").get(":Q1");
            return (bPlur && this.dConj.get(":Q").get(":Q2")) ? this.dConj.get(":Q").get(":Q2") : this.dConj.get(":Q").get(":Q1");
        }
        if (!bPlur) {
            return (this.dConj.get(":PQ").get(":Q3")) ? this.dConj.get(":PQ").get(":Q3") : this.dConj.get(":PQ").get(":Q1");
            return (this.dConj.get(":Q").get(":Q3")) ? this.dConj.get(":Q").get(":Q3") : this.dConj.get(":Q").get(":Q1");
        }
        return (this.dConj.get(":PQ").get(":Q4")) ? this.dConj.get(":PQ").get(":Q4") : this.dConj.get(":PQ").get(":Q1");
        return (this.dConj.get(":Q").get(":Q4")) ? this.dConj.get(":Q").get(":Q4") : this.dConj.get(":Q").get(":Q1");
    }
}


// Initialization
if (!conj.bInit && typeof(browser) !== 'undefined') {
    // WebExtension Standard (but not in Worker)

Modified gc_lang/fr/modules/conj.py from [99ba236032] to [2a47439b95].

143
144
145
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
173
174
175
176
177
178
179
180
181
182
143
144
145
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
173
174
175
176


177
178
179
180
181
182

183
184
185
186
187
188
189







-
+
+





+
+
+


-
+


-
+





-
+

+
+
+
+
-
-
+
+




-







        return sWord[:-(ord(sSfx[0])-48)] + sSfx[1:]  if sSfx[0] != '0'  else  sWord + sSfx[1:]  # 48 is the ASCII code for "0"
    except:
        return "## erreur, code : " + str(sSfx) + " ##"
        


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

        if sVerbPattern == "":
            sVerbPattern = sVerb

        self.sVerb = sVerb
        self.sVerbAux = ""
        self._sRawInfo = getVtyp(self.sVerb)
        self._sRawInfo = getVtyp(sVerbPattern)
        self.sInfo = self._readableInfo()
        self.bProWithEn = (self._sRawInfo[5] == "e")
        self._tTags = _getTags(sVerb)
        self._tTags = _getTags(sVerbPattern)
        self._tTagsAux = _getTags(self.sVerbAux)

        self.dConj = {
            ":Y": {
                "label": "Infinitif",
                ":Y": sVerb,
                ":": sVerb,
            },
            ":P": {
                "label": "Participe présent",
                ":": _getConjWithTags(sVerb, self._tTags, ":PQ", ":P"),
            },
            ":PQ": {
                "label": "Participes passés et présent",
            ":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"),
                ":P": _getConjWithTags(sVerb, self._tTags, ":PQ", ":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"),
300
301
302
303
304
305
306
307

308
309
310
311
312
313
314

315
316
317
318
319

320
321
322
323
324
325
326
307
308
309
310
311
312
313

314
315
316
317
318
319
320

321
322
323
324
325

326
327
328
329
330
331
332
333







-
+






-
+




-
+







            return sInfi
        except:
            traceback.print_exc()
            return "# erreur"

    def participePasse (self, sWho):
        try:
            return self.dConj[":PQ"][sWho]
            return self.dConj[":Q"][sWho]
        except:
            traceback.print_exc()
            return "# erreur"

    def participePresent (self, bPro, bNeg, bTpsCo, bInt, bFem):
        try:
            if not self.dConj[":PQ"][":P"]:
            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[":PQ"][":P"]
                sPartPre = self.dConj[":P"][":"]
            if not sPartPre:
                return ""
            bEli = True  if _zStartVoy.search(sPartPre)  else  False
            if bPro:
                if self.bProWithEn:
                    sPartPre = "s’en " + sPartPre
                else:
423
424
425
426
427
428
429
430

431
432

433
434
435


436
437
438
430
431
432
433
434
435
436

437
438

439
440


441
442
443
444
445







-
+

-
+

-
-
+
+



        except:
            traceback.print_exc()
            return "# erreur"

    def _seekPpas (self, bPro, bFem, bPlur):
        try:
            if not bPro and self.sVerbAux == "avoir":
                return self.dConj[":PQ"][":Q1"]
                return self.dConj[":Q"][":Q1"]
            if not bFem:
                return self.dConj[":PQ"][":Q2"]  if bPlur and self.dConj[":PQ"][":Q2"]  else  self.dConj[":PQ"][":Q1"]
                return self.dConj[":Q"][":Q2"]  if bPlur and self.dConj[":Q"][":Q2"]  else  self.dConj[":Q"][":Q1"]
            if not bPlur:
                return self.dConj[":PQ"][":Q3"]  if self.dConj[":PQ"][":Q3"]  else  self.dConj[":PQ"][":Q1"]
            return self.dConj[":PQ"][":Q4"]  if self.dConj[":PQ"][":Q4"]  else  self.dConj[":PQ"][":Q1"]
                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:
            traceback.print_exc()
            return "# erreur"

Modified gc_lang/fr/webext/panel/lex_conj_data.js from [6de1178d75] to [0a2c626447].

1
2
3

4
5
6
7
8
9
10
1
2

3
4
5
6
7
8
9
10


-
+







//  JavaScript

"use script";
"use strict";

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

/*
    Règles de conjugaison
*/

Modified gc_lang/fr/webext/panel/lex_editor.css from [2b16d91579] to [0d1be3ff24].

144
145
146
147
148
149
150



151
152
153
154
155
156
157
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160







+
+
+







    padding: 10px;
    background-color: hsl(0, 10%, 90%);
    color: hsl(0, 10%, 50%);
    font-size: 14px;
    border-radius: 3px;
}

ul {
    margin-left: 30px;
}

input[type=text] {
    display: inline-block;
    width: 250px;
    margin-left: 5px;
    padding: 5px 10px;
    border: 2px solid hsl(0, 0%, 80%);

Modified gc_lang/fr/webext/panel/lex_editor.html from [61631e3eb9] to [27635ef8a4].

14
15
16
17
18
19
20
21
22


23
24
25
26
27
28
29
14
15
16
17
18
19
20


21
22
23
24
25
26
27
28
29







-
-
+
+








            <div id="buttons" class="container">
                <div id="lexicon_button" class="main_button">Lexique</div>
                <div id="add_word_button" class="main_button">Ajout</div>
            </div>

            <div id="add_word_page">
                <h2>Nouveau mot</h2>
                <input type="text" id="word" name="word" maxlength="60" value="" placeholder="votre mot" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" autofocus />
                <h2>Nouveau mot (lemme)</h2>
                <input type="text" id="lemma" name="lemma" maxlength="60" value="" placeholder="votre mot" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" autofocus />

                <div id="editor">

                    <div id="categories">
                        <div class="category" id="select_nom" data-tag="N">Nom, adjectif</div>
                        <div class="category" id="select_verbe" data-tag="V">Verbe</div>
                        <div class="category" id="select_adverbe" data-tag="W">Adverbe</div>
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
65
66
67
68
69
70
71

72
73
74
75
76
77
78
79







-
+







                                    <p><input type="radio" id="up_nom_pluriel_s" name="pluriel" value="s" /><label for="up_nom_pluriel_s"> pluriel en ·s</label></p>
                                    <p><input type="radio" id="up_nom_pluriel_x" name="pluriel" value="x" /><label for="up_nom_pluriel_x"> pluriel en ·x</label></p>
                                    <p><input type="radio" id="up_nom_pluriel_i" name="pluriel" value="i" /><label for="up_nom_pluriel_i"> invariable</label></p>
                                </div>
                            </div>

                            <h2>[optionnel] Autre forme (masculine, féminine, variante, etc.)</h2>
                            <input type="text" id="word2" name="word2" maxlength="60" value="" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" placeholder="votre mot" />
                            <input type="text" id="lemma2" name="lemma2" maxlength="60" value="" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" placeholder="votre mot" />
                            <div id="word_section2">
                                <p class="typeline">
                                    <input type="radio" id="up_type_nom2" name="POS2" value=":N" /> <label class="widelabel" for="up_type_nom2">Nom</label>
                                    <input type="radio" id="up_type_adj2" name="POS2" value=":A" /> <label class="widelabel" for="up_type_adj2">Adjectif</label>
                                    <input type="radio" id="up_type_nomadj2" name="POS2" value=":N:A" /> <label class="widelabel" for="up_type_nomadj2">Nom &amp; adjectif</label>
                                </p>
                                <div class="container">
163
164
165
166
167
168
169
170
171


172
173
174
175


176
177
178
179

180
181
182
183
184
185

186
187
188
189
190
191
192
163
164
165
166
167
168
169


170
171
172
173


174
175
176
177
178

179
180
181
182
183
184

185
186
187
188
189
190
191
192







-
-
+
+


-
-
+
+



-
+





-
+







                                        <div class="examples_true">J’ai mangé.<br/>J’ai prié.</div>
                                        <div class="examples_false">Je suis mangé.<br/>Je suis prié.</div>
                                    </div>
                                </details>
                            </div>

                            <div class="block">
                                <h3>Verbe modèle</h3>
                                <p>Indiquez ici le verbe qui doit servir de modèle pour la conjugaison.</p>
                                <h3>Verbe modèle [optionnel]</h3>
                                <p>Ce n’est pas nécessaire pour la très grande majorité des verbes du 1ᵉʳ groupe et du 2ᵉ groupe. Si les formes fléchies engendrées automatiquement ne vous satisfont pas, vous pouvez indiquer le verbe qui doit servir de modèle pour la conjugaison.</p>
                                <input type="text" id="conj_rules_like" name="conj_rules_like" maxlength="60" value="" placeholder="verbe modèle" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ-]+$" />
                                <details>
                                    Il est fortement recommandé d’appliquer les règles d’un verbe du même groupe que celui que vous créez. Mais aucune restriction n’est imposée.<br/>
                                    Classification des groupes :
                                    <p>Il est fortement recommandé d’appliquer les règles d’un verbe du même groupe que celui que vous créez. Mais aucune restriction n’est imposée.</p>
                                    <p>Classification des groupes :</p>
                                    <ul>
                                        <li>1ᵉʳ groupe : verbes finissant par -<i>er</i>. Attention : contrairement au préjugé commun, ce groupe est irrégulier. Beaucoup de verbes voient leur racine modifiée dans certaines formes conjuguées :
                                        <ul>
                                            <li>ajout ou modification de diacritiques (verbes finissant par -<i>ecer</i>, -<i>emer</i>, -<i>ener</i>, -<i>eper</i>, -<i>erer</i>, -<i>eser</i>, -<i>ever</i>, -<i>evrer</i>, -<i>eler</i>, -<i>eter</i>, -<i>ébrer</i>, -<i>écer</i>, -<i>écher</i>, -<i>écrer</i>, -<i>éder</i>, -<i>éger</i>, -<i>égler</i>, -<i>égner</i>, -<i>égrer</i>, -<i>éguer</i>, -<i>éler</i>, -<i>émer</i>, -<i>éner</i>, -<i>éper</i>, -<i>équer</i>, -<i>érer</i>, -<i>éser</i>, -<i>éter</i>, -<i>étrer</i>, -<i>évrer</i>, -<i>éyer</i>),</li>
                                            <li>ajout ou modification de diacritiques (verbes finissant par -<i>cer</i>, -<i>ecer</i>, -<i>emer</i>, -<i>ener</i>, -<i>eper</i>, -<i>erer</i>, -<i>eser</i>, -<i>ever</i>, -<i>evrer</i>, -<i>eler</i>, -<i>eter</i>, -<i>ébrer</i>, -<i>écer</i>, -<i>écher</i>, -<i>écrer</i>, -<i>éder</i>, -<i>éger</i>, -<i>égler</i>, -<i>égner</i>, -<i>égrer</i>, -<i>éguer</i>, -<i>éler</i>, -<i>émer</i>, -<i>éner</i>, -<i>éper</i>, -<i>équer</i>, -<i>érer</i>, -<i>éser</i>, -<i>éter</i>, -<i>étrer</i>, -<i>évrer</i>, -<i>éyer</i>),</li>
                                            <li>un ‹e› euphonique est ajouté sur la plupart des verbes finissant par -<i>ger</i>,</li>
                                            <li>certains verbes finissant par -<i>yer</i> remplacent éventuellement le ‹y› par un ‹i›,</li>
                                            <li>doublement irrégulier de certaines consonnes (<i>geler</i> ne se conjugue pas comme <i>appeler</i>, <i>acheter</i> ne se conjugue pas comme <i>jeter</i>)</li>
                                            <li>irrégularités diverses (<i>aller</i>, <i>envoyer</i>, <i>renvoyer</i>)…
                                        </ul></li>
                                        <li>2ᵉ groupe : verbes finissant par -<i>ir</i>. Ce groupe est de loin le plus régulier. Mais de nombreux verbes finissant par -<i>ir</i> appartiennent au 3ᵉ groupe.</li>
                                        <li>2ᵉ groupe : verbes finissant par -<i>ir</i>. Ce groupe est de loin le plus régulier. Mais de nombreux verbes finissant par -<i>ir</i> appartiennent au 3ᵉgroupe.</li>
                                        <li>3ᵉ groupe. Autres verbes irréguliers.</li>
                                        <li>Les verbes <i>être</i> et <i>avoir</i> n’appartiennent à aucun groupe. Il est recommandé de ne pas s’en servir comme modèle.</li>
                                    </ul>
                                </details>
                            </div>
                        </div>

241
242
243
244
245
246
247
248
249
250



251
252
253
254
255
256
257
241
242
243
244
245
246
247



248
249
250
251
252
253
254
255
256
257







-
-
-
+
+
+







                                    <p>Les noms propres sont invariables en nombre.</p>
                                </div>
                            </div>
                        </div>

                        <div id="section_autre" class="section">
                            <h2>Autre</h2>
                            <p>Indiquez les étiquettes grammaticales que vous voulez appliquer au mot. À utiliser seulement si vous savez ce que vous faites. Dans le cas contraire, tant pis pour vous.</p>
                            <h3>Lemme</h3>
                            <p><input type="text" id="lemma" name="lemma" maxlength="20" value="" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" placeholder="lemme" /></p>
                            <p>Indiquez les étiquettes grammaticales que vous voulez appliquer au mot. À utiliser seulement si vous savez ce que vous faites.</p>
                            <h3>Flexion</h3>
                            <p><input type="text" id="flexion" name="flexion" maxlength="20" value="" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" placeholder="flexion" /></p>
                            <h3>Étiquettes</h3>
                            <p><input type="text" id="tags" name="tags" maxlength="20" value="" pattern="^:[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ:._-]+$" placeholder="étiquettes" /></p>
                        </div>
                    </div>
                </div>
                
                <div id="actions">
273
274
275
276
277
278
279

280
281
282
283
284
273
274
275
276
277
278
279
280
281
282
283
284
285







+





                    
                </table>
            </div>
        </div>


        <script src="../grammalecte/graphspell/helpers.js"></script>
        <script src="../grammalecte/fr/conj.js"></script>
        <script src="lex_conj_data.js"></script>
        <script src="lex_editor.js"></script>
    </body>
    
</html>

Modified gc_lang/fr/webext/panel/lex_editor.js from [65b854aa07] to [4723ccb4db].

26
27
28
29
30
31
32
33

34
35
36
37



38
39
40
41
42
43
44
26
27
28
29
30
31
32

33
34



35
36
37
38
39
40
41
42
43
44







-
+

-
-
-
+
+
+








function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}


document.getElementById("lexicon_button").addEventListener("click", () => { oPage.showPage("lexicon"); }, false);
document.getElementById("add_word_button").addEventListener("click", () => { oPage.showPage("word"); }, false);
document.getElementById("add_word_button").addEventListener("click", () => { oPage.showPage("lemma"); }, false);
document.getElementById("editor").addEventListener("click", (xEvent) => { oPage.onSelectionClick(xEvent); }, false);
document.getElementById("word").addEventListener("keyup", () => { oPage.onWrite(); }, false);
document.getElementById("word2").addEventListener("keyup", () => { oPage.onWrite2(); }, false);
document.getElementById("lemma").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("lemma").addEventListener("keyup", () => { oPage.onWrite(); }, false);
document.getElementById("lemma2").addEventListener("keyup", () => { oPage.onWrite2(); }, false);
document.getElementById("flexion").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("tags").addEventListener("keyup", () => { oFlex.update(); }, false);
document.getElementById("add_to_lexicon").addEventListener("click", () => { oFlex.addToLexicon(); }, false);



/*
    ACTIONS
82
83
84
85
86
87
88
89

90
91
92
93
94
95
96
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96







-
+







        if (document.getElementById(sName)) {
            document.getElementById(sName).style.display = "block";
        }
    },

    clear: function () {
        try {
            document.getElementById("word2").value = "";
            document.getElementById("lemma2").value = "";
            this.hideWord2();
            // nom, adjectif, noms propres
            for (let xElem of document.getElementsByName("POS")) {
                xElem.checked = false;
            }
            for (let xElem of document.getElementsByName("POS2")) {
                xElem.checked = false;
112
113
114
115
116
117
118
119

120
121
122
123
124
125
126
112
113
114
115
116
117
118

119
120
121
122
123
124
125
126







-
+







            document.getElementById("up_v_t").checked = false;
            document.getElementById("up_v_n").checked = false;
            document.getElementById("up_v_p").checked = false;
            document.getElementById("up_v_m").checked = false;
            document.getElementById("up_v_ae").checked = false;
            document.getElementById("up_v_aa").checked = false;
            // autre
            document.getElementById("lemma").value = "";
            document.getElementById("flexion").value = "";
            document.getElementById("tags").value = "";
        }
        catch (e) {
            showError(e);
        }
    },

139
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155
156

157
158
159
160
161
162
163
139
140
141
142
143
144
145

146
147
148
149
150
151
152
153
154
155

156
157
158
159
160
161
162
163







-
+









-
+







        }
        catch (e) {
            showError(e);
        }
    },

    onWrite: function () {
        if (document.getElementById("word").value.trim() !== "") {
        if (document.getElementById("lemma").value.trim() !== "") {
            this.showEditor();
        } else {
            this.showSection("section_vide");
            this.hideEditor();
            this.hideActions();
        }
    },

    onWrite2: function () {
        if (document.getElementById("word2").value.trim() !== "") {
        if (document.getElementById("lemma2").value.trim() !== "") {
            this.showWord2();
        } else {
            this.hideWord2();
        }
    },

    showWord2: function () {
198
199
200
201
202
203
204
205
206


207
208
209
210
211
212
213
214
215
216


217
218
219
220


221
222
223

224
225
226
227


228
229
230
231
232


233
234
235
236


237
238
239

240
241
242
243
244
245

246
247
248
249


250
251
252
253
254
255
256
257
258



259
260

















261
262
263
264
265
266
267


268
269
270

271
272
273

274
275
276
277

278
279
280

281
282
283
284
285
286

287
288
289
290

291
292
293


294
295
296
297
298
299
300
301
302
303
304
305
306

307
308


309
310
311
312
313
314
315
316
317
318
319
320
321



322
323
324
325
326
327
328
198
199
200
201
202
203
204


205
206
207
208
209
210
211
212
213
214


215
216
217
218


219
220
221
222

223
224
225


226
227
228
229
230


231
232
233
234


235
236
237
238

239
240
241
242
243
244

245
246
247


248
249
250
251
252
253
254
255
256
257
258
259
260
261


262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283


284
285
286
287

288
289
290

291
292
293
294

295
296
297

298
299
300
301
302
303

304
305
306
307

308
309


310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326

327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351







-
-
+
+








-
-
+
+


-
-
+
+


-
+


-
-
+
+



-
-
+
+


-
-
+
+


-
+





-
+


-
-
+
+









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





-
-
+
+


-
+


-
+



-
+


-
+





-
+



-
+

-
-
+
+













+

-
+
+













+
+
+







        this.lFlexion.push( [sFlexion, sLemma, sTag] );
    },

    update: function () {
        try {
            this.clear();
            let sGenderTag = "";
            let sWord = document.getElementById("word").value.trim();
            if (sWord.length > 0) {
            let sLemma = document.getElementById("lemma").value.trim();
            if (sLemma.length > 0) {
                switch (this.cMainTag) {
                    case "N":
                        if (!this.getRadioValue("POS") || !this.getRadioValue("genre")) {
                            break;
                        }
                        let sTag = this.getRadioValue("POS") + this.getRadioValue("genre");
                        switch (this.getRadioValue("pluriel")) {
                            case "s":
                                this.addFlexion(sWord, sWord, sTag+":s");
                                this.addFlexion(sWord+"s", sWord, sTag+":p");
                                this.addFlexion(sLemma, sLemma, sTag+":s");
                                this.addFlexion(sLemma+"s", sLemma, sTag+":p");
                                break;
                            case "x":
                                this.addFlexion(sWord, sWord, sTag+":s");
                                this.addFlexion(sWord+"x", sWord, sTag+":p");
                                this.addFlexion(sLemma, sLemma, sTag+":s");
                                this.addFlexion(sLemma+"x", sLemma, sTag+":p");
                                break;
                            case "i":
                                this.addFlexion(sWord, sWord, sTag+":i");
                                this.addFlexion(sLemma, sLemma, sTag+":i");
                                break;
                        }
                        let sWord2 = document.getElementById("word2").value.trim();
                        if (sWord2.length > 0  &&  this.getRadioValue("POS2")  &&  this.getRadioValue("genre2")) {
                        let sLemma2 = document.getElementById("lemma2").value.trim();
                        if (sLemma2.length > 0  &&  this.getRadioValue("POS2")  &&  this.getRadioValue("genre2")) {
                            let sTag2 = this.getRadioValue("POS2") + this.getRadioValue("genre2");
                            switch (this.getRadioValue("pluriel2")) {
                                case "s":
                                    this.addFlexion(sWord2, sWord, sTag2+":s");
                                    this.addFlexion(sWord2+"s", sWord, sTag2+":p");
                                    this.addFlexion(sLemma2, sLemma, sTag2+":s");
                                    this.addFlexion(sLemma2+"s", sLemma, sTag2+":p");
                                    break;
                                case "x":
                                    this.addFlexion(sWord2, sWord, sTag2+":s");
                                    this.addFlexion(sWord2+"x", sWord, sTag2+":p");
                                    this.addFlexion(sLemma2, sLemma, sTag2+":s");
                                    this.addFlexion(sLemma2+"x", sLemma, sTag2+":p");
                                    break;
                                case "i":
                                    this.addFlexion(sWord2, sWord, sTag2+":i");
                                    this.addFlexion(sLemma2, sLemma, sTag2+":i");
                                    break;
                            }
                        }
                        break;
                    case "V": {
                        if (!sWord.endsWith("er") && !sWord.endsWith("ir")) {
                        if (!sLemma.endsWith("er") && !sLemma.endsWith("ir")) {
                            break;
                        }
                        sWord = sWord.toLowerCase();
                        let c_g = (sWord.endsWith("er")) ? "1" : "2";
                        sLemma = sLemma.toLowerCase();
                        let c_g = (sLemma.endsWith("er")) ? "1" : "2";
                        let c_i = (document.getElementById("up_v_i").checked) ? "i" : "_";
                        let c_t = (document.getElementById("up_v_t").checked) ? "t" : "_";
                        let c_n = (document.getElementById("up_v_n").checked) ? "n" : "_";
                        let c_p = (document.getElementById("up_v_p").checked) ? "p" : "_";
                        let c_m = (document.getElementById("up_v_m").checked) ? "m" : "_";
                        let c_ae = (document.getElementById("up_v_ae").checked) ? "e" : "_";
                        let c_aa = (document.getElementById("up_v_aa").checked) ? "a" : "_";
                        let sVerbTag = c_i + c_t + c_n + c_p + c_m + c_ae + c_aa;
                        if (!sVerbTag.endsWith("__") && !sVerbTag.startsWith("____")) {
                            let sVerbPattern = document.getElementById("conj_rules_like").value.trim();
                            if (sVerbPattern.length == 0) {
                                // tables de conjugaison du 1er et du 2e groupe
                            for (let [nCut, sAdd, sFlexTags] of this._getConjRule(sWord)) {
                                this.addFlexion(sWord.slice(0,-nCut)+sAdd, sWord, ":V" + c_g + "_" + sVerbTag+sFlexTags);
                                for (let [nCut, sAdd, sFlexTags, sPattern] of this._getConjRule(sLemma)) {
                                    if (!sPattern || RegExp(sPattern).test(sLemma)) {
                                        this.addFlexion(sLemma.slice(0,-nCut)+sAdd, sLemma, ":V" + c_g + "_" + sVerbTag + sFlexTags);
                                    }
                                }
                            } else {
                                // utilisation du conjugueur
                                let oVerb = new Verb(sLemma, sVerbPattern);
                                for (let [sTag1, dFlex] of oVerb.dConj.entries()) {
                                    if (sTag1 !== ":Q") {
                                        for (let [sTag2, sConj] of dFlex.entries()) {
                                            if (sTag2.startsWith(":") && sConj !== "") {
                                                this.addFlexion(sConj, sLemma, ":V" + c_g + "_" + sVerbTag + sTag1 + sTag2);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    }
                    case "W":
                        sWord = sWord.toLowerCase();
                        this.addFlexion(sWord, sWord, ":W");
                        sLemma = sLemma.toLowerCase();
                        this.addFlexion(sLemma, sLemma, ":W");
                        break;
                    case "M1":
                        sWord = sWord.slice(0,1).toUpperCase() + sWord.slice(1);
                        sLemma = sLemma.slice(0,1).toUpperCase() + sLemma.slice(1);
                        sGenderTag = this.getRadioValue("genre_m1");
                        if (sGenderTag) {
                            this.addFlexion(sWord, sWord, ":M1"+sGenderTag+":i");
                            this.addFlexion(sLemma, sLemma, ":M1"+sGenderTag+":i");
                        }
                        break;
                    case "M2":
                        sWord = sWord.slice(0,1).toUpperCase() + sWord.slice(1);
                        sLemma = sLemma.slice(0,1).toUpperCase() + sLemma.slice(1);
                        sGenderTag = this.getRadioValue("genre_m2");
                        if (sGenderTag) {
                            this.addFlexion(sWord, sWord, ":M2"+sGenderTag+":i");
                            this.addFlexion(sLemma, sLemma, ":M2"+sGenderTag+":i");
                        }
                        break;
                    case "MP":
                        sGenderTag = this.getRadioValue("genre_mp");
                        if (sGenderTag) {
                            this.addFlexion(sWord, sWord, ":MP"+sGenderTag+":i");
                            this.addFlexion(sLemma, sLemma, ":MP"+sGenderTag+":i");
                        }
                        break;
                    case "X":
                        let sLemma = document.getElementById("lemma").value.trim();
                        let sFlexion = document.getElementById("flexion").value.trim();
                        let sTags = document.getElementById("tags").value.trim();
                        if (sLemma.length > 0 && sTags.startsWith(":")) {
                            this.addFlexion(sWord, sLemma, sTags);
                        if (sFlexion.length > 0 && sTags.startsWith(":")) {
                            this.addFlexion(sFlexion, sLemma, sTags);
                        }
                        break;
                }
            }
            this.show();
        }
        catch (e) {
            showError(e);
        }
    },

    _getConjRule: function (sVerb) {
        if (sVerb.endsWith("ir")) {
            // deuxième groupe
            return oConj["V2"];
        } else {
        } else if (sVerb.endsWith("er")) {
            // premier groupe
            if (sVerb.slice(-5) in oConj["V1"]) {
                return oConj["V1"][sVerb.slice(-5)];
            }
            if (sVerb.slice(-4) in oConj["V1"]) {
                if (sVerb.endsWith("eler") || sVerb.endsWith("eter")) {
                    return oConj["V1"][sVerb.slice(-4)]["1"];
                }
                return oConj["V1"][sVerb.slice(-4)];
            }
            if (sVerb.slice(-3) in oConj["V1"]) {
                return oConj["V1"][sVerb.slice(-3)];
            }
            return oConj["V1"]["er"];
        } else {
            // troisième groupe
            return [ [0, "", ":Y/*", false] ];
        }
    },

    getRadioValue: function (sName) {
        if (document.querySelector('input[name="' + sName + '"]:checked')) {
            return document.querySelector('input[name="' + sName + '"]:checked').value;
        }
342
343
344
345
346
347
348
349

350
351
352
353
354
355
356
365
366
367
368
369
370
371

372
373
374
375
376
377
378
379







-
+







        }
    },

    addToLexicon: function () {
        try {
            oLexicon.addFlexions(this.lFlexion);
            oLexicon.save();
            document.getElementById("word").value = "";
            document.getElementById("lemma").value = "";
            oPage.showSection("section_vide");
            oPage.hideEditor();
            oPage.hideActions();
            oPage.clear();
            this.clear();
        }
        catch (e) {