Grammalecte  Check-in [98ddc49275]

Overview
Comment:[tb] remove obsolete files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | tb
Files: files | file ages | folders
SHA3-256: 98ddc4927526e8f6d451739d20f24ad54fd27d8ca7e260360f638e96073f8655
User & Date: olr on 2020-07-10 11:41:01
Other Links: manifest | tags
Context
2020-07-10
12:57
[core] remove obsolete cruft about importation for Thunderbird/Firefox Addon-SDK check-in: c8ed6a6f41 user: olr tags: trunk, core
11:41
[tb] remove obsolete files check-in: 98ddc49275 user: olr tags: trunk, tb
11:04
[fr] version 1.11 check-in: bf4c3139d1 user: olr tags: trunk, fr
Changes

Deleted gc_lang/fr/mailext/content/lex_editor.css version [90aa27d1f6].

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






































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* CSS */

button {
    font-weight: bold;
}

.dialogheader-title {
  margin: 5px;
  padding: 5px 8px;
  border: 1px solid hsl(210, 50%, 80%);
  background-color: hsl(210, 50%, 50%);
  color: hsl(210, 10%, 90%);
  font-size: larger;
  font-weight: bold;
}

/*
    Dictionary
*/
.dictionary {
    font-size: 18px;
    font-weight: bold;
    color: hsl(210, 50%, 50%);
}
.dic_text {
    font-size: 18px;
    color: hsl(210, 50%, 50%);
}
.align_right {
    text-align: right;
}


/*
    Add new words
*/
.section {
    font-size: 16px;
    font-weight: bold;
    color: hsl(210, 50%, 50%);
}

.subsection {
    font-size: 14px;
    font-weight: bold;
    color: hsl(210, 50%, 50%);
}

.option {
    width: 120px;
    font-size: 12px;
}

.m_left {
    margin-left: 20px;
}

.m_left2 {
    margin-left: 40px;
}

.v_usage {
    width: 150px;
}
.v_textbox {
    width: 200px;
}

.other_label {
    width: 80px;
}
.other_textbox {
    width: 250px;
}

#generated_words_table {
    width: 400px;
    height: 600px;
}

.delete_entry {
    color: hsl(0, 100%, 50%);
    font-weight: bold;
}

/*
    Lexicon tab
*/

#lexicon_table {
    width: 600px;
    height: 650px;
}

.listheader {
    padding: 2px 0;
    font-weight: bold;
    background-color: hsl(0, 0%, 95%);
    border-bottom: 1px solid hsl(0, 0%, 50%);
}
.info_label {
    width: 120px;
}
.data {
    width: 90px;
}

/*
    Search tab
*/

#search_table {
    width: 600px;
    height: 650px;
}

.bold {
    font-weight: bold;
}
description {
    width: 200px;
}

/*
    Informations tab
*/

#tags_table {
    width: 600px;
    height: 650px;
    font-family: "Courier new", "Ubuntu Mono", Courier, Consolas, monospace;
}


Deleted gc_lang/fr/mailext/content/lex_editor.js version [e12409ccd5].

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
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
137
138
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
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
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
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558














































































































































































































































































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// JavaScript

"use strict";

const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");


/*
    Common functions
*/

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

function createNode  (sType, oAttr) {
    try {
        let xNode = document.createElement(sType);
        for (let sParam in oAttr) {
            xNode.setAttribute(sParam, oAttr[sParam]);
        }
        return xNode;
    }
    catch (e) {
        showError(e);
    }
}

function enableElement (sElemId) {
    if (document.getElementById(sElemId)) {
        document.getElementById(sElemId).disabled = false;
    } else {
        console.log("HTML node named <" + sElemId + "> not found.")
    }
}

function disableElement (sElemId) {
    if (document.getElementById(sElemId)) {
        document.getElementById(sElemId).disabled = true;
    } else {
        console.log("HTML node named <" + sElemId + "> not found.")
    }
}



class Table {

    constructor (sNodeId, lColumn, lColumnWidth, sProgressBarId, sResultId="") {
        this.sNodeId = sNodeId;
        this.xTable = document.getElementById(sNodeId);
        this.nColumn = lColumn.length;
        this.lColumn = lColumn;
        this.lColumnWidth = lColumnWidth;
        this.xProgressBar = document.getElementById(sProgressBarId);
        this.xNumEntry = sResultId ? document.getElementById(sResultId) : null;
        this.iEntryIndex = 0;
        this.lEntry = [];
        this.nEntry = 0
        this._createHeader();
    }

    _createHeader () {
        let xListheadNode = createNode("richlistitem", { class: "listheader" });
        for (let i=0;  i < this.lColumn.length;  i++) {
            xListheadNode.appendChild(createNode("label", { value: this.lColumn[i], width: this.lColumnWidth[i] }));
        }
        this.xTable.appendChild(xListheadNode);
    }

    clear () {
        while (this.xTable.firstChild) {
            this.xTable.removeChild(this.xTable.firstChild);
        }
        this.iEntryIndex = 0;
        this._createHeader();
    }

    fill (lFlex) {
        this.clear();
        if (lFlex.length > 0) {
            this.xProgressBar.max = lFlex.length;
            this.xProgressBar.value = 1;
            for (let lData of lFlex) {
                this._addRow(lData);
                this.xProgressBar.value += 1;
            }
            this.xProgressBar.value = this.xProgressBar.max;
            window.setTimeout(() => { this.xProgressBar.value = 0; }, 3000);
        }
        this.lEntry = lFlex;
        this.nEntry = lFlex.length;
        this.showEntryNumber();
    }

    addEntries (lFlex) {
        this.lEntry.push(...lFlex);
        for (let lData of lFlex) {
            this._addRow(lData);
        }
        this.nEntry += lFlex.length;
        this.showEntryNumber();
    }

    showEntryNumber () {
        if (this.xNumEntry) {
            this.xNumEntry.value = this.nEntry;
        }
    }

    _addRow (lData) {
        let xRowNode = createNode("richlistitem", { id: this.sNodeId + "_item_" + this.iEntryIndex, value: this.iEntryIndex });
        for (let i=0;  i < lData.length;  i++) {
            xRowNode.appendChild(createNode("label", { class: "listcell", value: lData[i], width: this.lColumnWidth[i] }));
        }
        this.xTable.appendChild(xRowNode);
        this.iEntryIndex += 1;
    }

    deleteSelection () {
        for (let xItem of this.xTable.selectedItems) {
            this.lEntry[parseInt(xItem.value)] = null;
            xItem.style.display = "none";
            this.nEntry -= 1;
        }
        this.showEntryNumber();
    }

    getEntries () {
        return this.lEntry.filter((e) => e !== null);
    }
}


const oGenerator = {

    sLemma: "",

    cMainTag: "",

    lFlexion: [],

    listen: function () {
        document.getElementById("lemma").addEventListener("keyup", () => { this.update(); }, false);
        // nom commun
        document.getElementById("tag_N").addEventListener("click", () => { this.update("N"); }, false);
        document.getElementById("nom_adj").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("nom").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("adj").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("N_epi").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("N_mas").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("N_fem").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("N_s").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("N_x").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("N_inv").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("lemma2").addEventListener("keyup", () => { this.update(); }, false);
        // nom propre
        document.getElementById("tag_M").addEventListener("click", () => { this.update("M"); }, false);
        document.getElementById("M1").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("M2").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("MP").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("M_epi").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("M_mas").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("M_fem").addEventListener("click", () => { this.update(); }, false);
        // verbe
        document.getElementById("tag_V").addEventListener("click", () => { this.update("V"); }, false);
        document.getElementById("v_i").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("v_t").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("v_n").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("v_p").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("v_m").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("v_ae").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("v_aa").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("v_ppas").addEventListener("click", () => { this.update(); }, false);
        document.getElementById("verbe_modele").addEventListener("keyup", () => { this.update(); }, false);
        // adverbe
        document.getElementById("tag_W").addEventListener("click", () => { this.update("W"); }, false);
        // autre
        document.getElementById("tag_X").addEventListener("click", () => { this.update("X"); }, false);
        document.getElementById("flexion").addEventListener("keyup", () => { this.update(); }, false);
        document.getElementById("tags").addEventListener("keyup", () => { this.update(); }, false);
        // ajout
        document.getElementById("add_to_lexicon").addEventListener("click", () => { this.addToLexicon(); }, false);
        document.getElementById("delete_selection").addEventListener("click", () => { oGenWordsTable.deleteSelection(); }, false);
    },

    clear: function () {
        try {
            // nom commun
            document.getElementById("tag_N").checked = false;
            document.getElementById("nom_adj").checked = false;
            document.getElementById("nom").checked = false;
            document.getElementById("adj").checked = false;
            document.getElementById("N_epi").checked = false;
            document.getElementById("N_mas").checked = false;
            document.getElementById("N_fem").checked = false;
            document.getElementById("N_s").checked = false;
            document.getElementById("N_x").checked = false;
            document.getElementById("N_inv").checked = false;
            document.getElementById("lemma2").value = "";
            // nom propre
            document.getElementById("tag_M").checked = false;
            document.getElementById("M1").checked = false;
            document.getElementById("M2").checked = false;
            document.getElementById("MP").checked = false;
            document.getElementById("M_epi").checked = false;
            document.getElementById("M_mas").checked = false;
            document.getElementById("M_fem").checked = false;
            // verbe
            document.getElementById("tag_V").checked = false;
            document.getElementById("v_i").checked = false;
            document.getElementById("v_t").checked = false;
            document.getElementById("v_n").checked = false;
            document.getElementById("v_p").checked = false;
            document.getElementById("v_m").checked = false;
            document.getElementById("v_ae").checked = false;
            document.getElementById("v_aa").checked = false;
            document.getElementById("v_ppas").checked = false;
            document.getElementById("verbe_modele").value = "";
            // adverbe
            document.getElementById("tag_W").checked = false;
            // autre
            document.getElementById("tag_X").checked = false;
            document.getElementById("flexion").value = "";
            document.getElementById("tags").value = "";
        }
        catch (e) {
            showError(e);
        }
    },

    lTag: ["N", "M", "V", "W", "X"],

    setMainTag: function (cTag) {
        this.cMainTag = cTag;
        for (let c of this.lTag) {
            if (c !== cTag) {
                document.getElementById("tag_"+c).checked = false;
            }
        }
    },

    update: function (cTag=null) {
        if (cTag !== null) {
            this.setMainTag(cTag);
        }
        try {
            this.lFlexion = [];
            this.sLemma = document.getElementById("lemma").value.trim();
            if (this.sLemma.length > 0) {
                switch (this.cMainTag) {
                    case "N":
                        if (!this.getRadioValue("pos_nom_commun") || !this.getRadioValue("genre_nom_commun")) {
                            break;
                        }
                        let sTag = this.getRadioValue("pos_nom_commun") + this.getRadioValue("genre_nom_commun");
                        switch (this.getRadioValue("pluriel_nom_commun")) {
                            case "s":
                                this.lFlexion.push([this.sLemma, sTag+":s/*"]);
                                this.lFlexion.push([this.sLemma+"s", sTag+":p/*"]);
                                break;
                            case "x":
                                this.lFlexion.push([this.sLemma, sTag+":s/*"]);
                                this.lFlexion.push([this.sLemma+"x", sTag+":p/*"]);
                                break;
                            case "i":
                                this.lFlexion.push([this.sLemma, sTag+":i/*"]);
                                break;
                        }
                        let sLemma2 = document.getElementById("lemma2").value.trim();
                        if (sLemma2.length > 0  &&  this.getRadioValue("pos_nom_commun2")  &&  this.getRadioValue("genre_nom_commun2")) {
                            let sTag2 = this.getRadioValue("pos_nom_commun2") + this.getRadioValue("genre_nom_commun2");
                            switch (this.getRadioValue("pluriel_nom_commun2")) {
                                case "s":
                                    this.lFlexion.push([sLemma2, sTag2+":s/*"]);
                                    this.lFlexion.push([sLemma2+"s", sTag2+":p/*"]);
                                    break;
                                case "x":
                                    this.lFlexion.push([sLemma2, sTag2+":s/*"]);
                                    this.lFlexion.push([sLemma2+"x", sTag2+":p/*"]);
                                    break;
                                case "i":
                                    this.lFlexion.push([sLemma2, sTag2+":i/*"]);
                                    break;
                            }
                        }
                        break;
                    case "V": {
                        if (!this.sLemma.endsWith("er") && !this.sLemma.endsWith("ir") && !this.sLemma.endsWith("re")) {
                            break;
                        }
                        this.sLemma = this.sLemma.toLowerCase();
                        let cGroup = "";
                        let c_i = (document.getElementById("v_i").checked) ? "i" : "_";
                        let c_t = (document.getElementById("v_t").checked) ? "t" : "_";
                        let c_n = (document.getElementById("v_n").checked) ? "n" : "_";
                        let c_p = (document.getElementById("v_p").checked) ? "p" : "_";
                        let c_m = (document.getElementById("v_m").checked) ? "m" : "_";
                        let c_ae = (document.getElementById("v_ae").checked) ? "e" : "_";
                        let c_aa = (document.getElementById("v_aa").checked) ? "a" : "_";
                        let sVerbTag = c_i + c_t + c_n + c_p + c_m + c_ae + c_aa;
                        if (sVerbTag.includes("p") && !sVerbTag.startsWith("___p_")) {
                            sVerbTag = sVerbTag.replace("p", "q");
                        }
                        if (!sVerbTag.endsWith("__") && !sVerbTag.startsWith("____")) {
                            let sVerbPattern = document.getElementById("verbe_modele").value.trim();
                            if (sVerbPattern.length == 0) {
                                // utilisation du générateur de conjugaison
                                let bVarPpas = !document.getElementById("v_ppas").checked;
                                for (let [sFlexion, sFlexTags] of conj_generator.conjugate(this.sLemma, sVerbTag, bVarPpas)) {
                                    this.lFlexion.push([sFlexion, sFlexTags]);
                                }
                            } else {
                                // copie du motif d’un autre verbe : utilisation du conjugueur
                                if (conj.isVerb(sVerbPattern)) {
                                    let oVerb = new Verb(this.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.lFlexion.push([sConj, ":V" + oVerb.cGroup + "_" + sVerbTag + sTag1 + sTag2]);
                                                }
                                            }
                                        } else {
                                            // participes passés
                                            if (dFlex.get(":Q3") !== "") {
                                                if (dFlex.get(":Q2") !== "") {
                                                    this.lFlexion.push([dFlex.get(":Q1"), ":V" + oVerb.cGroup + "_" + sVerbTag + ":Q:A:m:s/*"]);
                                                    this.lFlexion.push([dFlex.get(":Q2"), ":V" + oVerb.cGroup + "_" + sVerbTag + ":Q:A:m:p/*"]);
                                                } else {
                                                    this.lFlexion.push([dFlex.get(":Q1"), ":V" + oVerb.cGroup + "_" + sVerbTag + ":Q:A:m:i/*"]);
                                                }
                                                this.lFlexion.push([dFlex.get(":Q3"), ":V" + oVerb.cGroup + "_" + sVerbTag + ":Q:A:f:s/*"]);
                                                this.lFlexion.push([dFlex.get(":Q4"), ":V" + oVerb.cGroup + "_" + sVerbTag + ":Q:A:f:p/*"]);
                                            } else {
                                                this.lFlexion.push([dFlex.get(":Q1"), ":V" + oVerb.cGroup + "_" + sVerbTag + ":Q:e:i/*"]);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    }
                    case "W":
                        this.sLemma = this.sLemma.toLowerCase();
                        this.lFlexion.push([this.sLemma, ":W/*"]);
                        break;
                    case "M":
                        this.sLemma = this.sLemma.slice(0,1).toUpperCase() + this.sLemma.slice(1);
                        let sPOSTag = this.getRadioValue("pos_nom_propre");
                        let sGenderTag = this.getRadioValue("genre_nom_propre");
                        if (sGenderTag) {
                            this.lFlexion.push([this.sLemma, sPOSTag+sGenderTag+":i/*"]);
                        }
                        break;
                    case "X":
                        let sFlexion = document.getElementById("flexion").value.trim();
                        let sTags = document.getElementById("tags").value.trim();
                        if (sFlexion.length > 0 && sTags.startsWith(":")) {
                            this.lFlexion.push([sFlexion, sTags]);
                        }
                        break;
                }
            }
            oGenWordsTable.fill(this.lFlexion);
        }
        catch (e) {
            showError(e);
        }
    },

    getRadioValue: function (sName) {
        if (document.getElementById(sName)) {
            for (let xNode of document.getElementById(sName).children) {
                if (xNode.selected) {
                    return xNode.value;
                }
            }
        }
        return null;
    },

    createFlexLemmaTagArray: function () {
        let lEntry = [];
        for (let [sFlex, sTags] of oGenWordsTable.getEntries()) {
            lEntry.push([sFlex, this.sLemma, sTags]);
        }
        return lEntry;
    },

    addToLexicon: function () {
        try {
            oLexiconTable.addEntries(this.createFlexLemmaTagArray());
            oGenWordsTable.clear();
            document.getElementById("lemma").value = "";
            document.getElementById("lemma").focus();
            enableElement("save_button");
            this.clear();
            this.cMainTag = "";
        }
        catch (e) {
            showError(e);
        }
    }
}


const oBinaryDict = {

    oIBDAWG: null,

    load: async function () {
        let sJSON = await oFileHandler.loadFile("fr.personal.json");
        this._load(sJSON);
    },

    _load: function (sJSON, bSave=false) {
        //console.log("_load");
        if (sJSON) {
            try {
                let oJSON = JSON.parse(sJSON);
                this.oIBDAWG = new IBDAWG(oJSON);
            }
            catch (e) {
                this.setDictData(0, "#Erreur. Voir la console.");
                console.error(e);
                return;
            }
            if (bSave) {
                oFileHandler.saveFile("fr.personal.json", sJSON);
            }
            let lEntry = [];
            for (let aRes of this.oIBDAWG.select()) {
                lEntry.push(aRes);
            }
            oLexiconTable.fill(lEntry);
            this.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate);
            enableElement("export_button");
        } else {
            this.setDictData(0, "[néant]");
            disableElement("export_button");
        }
    },

    import: function () {
        oFileHandler.loadAs(this._import.bind(this));
    },

    _import: function (sJSON) {
        this._load(sJSON, true);
    },

    setDictData: function (nEntries, sDate) {
        document.getElementById("dic_num_entries").value = nEntries;
        document.getElementById("dic_save_date").value = sDate;
    },

    listen: function () {
        document.getElementById("delete_button").addEventListener("click", () => { oLexiconTable.deleteSelection(); }, false);
        document.getElementById("save_button").addEventListener("click", () => { this.build(); }, false);
        document.getElementById("export_button").addEventListener("click", () => { this.export(); }, false);
        document.getElementById("import_button").addEventListener("click", () => { this.import(); }, false);
    },

    build: function () {
        let xProgressNode = document.getElementById("wait_progress");
        let lEntry = oLexiconTable.getEntries();
        if (lEntry.length > 0) {
            let oDAWG = new DAWG(lEntry, "S", "fr", "Français", "fr.personal", "Dictionnaire personnel", xProgressNode);
            let oJSON = oDAWG.createBinaryJSON(1);
            oFileHandler.saveFile("fr.personal.json", JSON.stringify(oJSON));
            this.oIBDAWG = new IBDAWG(oJSON);
            this.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate);
            //browser.runtime.sendMessage({ sCommand: "setDictionary", oParam: {sType: "personal", oDict: oJSON}, oInfo: {} });
            enableElement("export_button");
        } else {
            oFileHandler.deleteFile("fr.personal.json");
            this.setDictData(0, "[néant]");
            disableElement("export_button");
        }
    },

    export: function () {
        let sJSON = JSON.stringify(this.oIBDAWG.getJSON());
        oFileHandler.saveAs(sJSON);
    }
}


const oSearch = {

    oSpellChecker: null,

    load: function () {
        this.oSpellChecker = new SpellChecker("fr", "", "fr-allvars.json");
    },

    listen: function () {
        document.getElementById("search_similar_button").addEventListener("click", () => { this.searchSimilar(); }, false);
        document.getElementById("search_regex_button").addEventListener("click", () => { this.searchRegex() }, false);
    },

    searchSimilar: function () {
        oSearchTable.clear();
        let sWord = document.getElementById("search_similar").value;
        if (sWord !== "") {
            let lResult = this.oSpellChecker.getSimilarEntries(sWord, 20);
            oSearchTable.fill(lResult);
        }
    },

    searchRegex: function () {
        let sFlexPattern = document.getElementById("search_flexion_pattern").value.trim();
        let sTagsPattern = document.getElementById("search_tags_pattern").value.trim();
        let lEntry = [];
        let i = 0;
        for (let aRes of this.oSpellChecker.select(sFlexPattern, sTagsPattern)) {
            lEntry.push(aRes);
            i++;
            if (i >= 2000) {
                break;
            }
        }
        oSearchTable.fill(lEntry);
    }
}


const oTagsInfo = {
    load: function () {
        let lEntry = [];
        for (let [sTag, [_, sLabel]] of _dTag) {
            lEntry.push([sTag, sLabel.trim()]);
        }
        oTagsTable.fill(lEntry);
    }
}


const oGenWordsTable = new Table("generated_words_table", ["Flexions", "Étiquettes"], ["125px", "225px"], "progress_new_words");
const oLexiconTable = new Table("lexicon_table", ["Flexions", "Lemmes", "Étiquettes"], ["190px", "150px", "200px"], "progress_lexicon", "num_entries");
const oSearchTable = new Table("search_table", ["Flexions", "Lemmes", "Étiquettes"], ["190px", "150px", "200px"], "progress_search", "search_num_entries");
const oTagsTable = new Table("tags_table", ["Étiquette", "Signification"], ["75px", "475px"], "progress_lexicon");

conj.init(helpers.loadFile("resource://grammalecte/fr/conj_data.json"));


oTagsInfo.load();
oSearch.load();
oBinaryDict.load();
oBinaryDict.listen();
oGenerator.listen();
oSearch.listen();

Deleted gc_lang/fr/mailext/content/lex_editor.xul version [62ec884266].

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















































































































































































































































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://grammarchecker/content/lex_editor.css" type="text/css"?>

<!DOCTYPE dialog SYSTEM "chrome://grammarchecker/locale/lex_editor.dtd">

<dialog
  id="grammalecte-lexicon-editor-window"
  title="&window.title;"
  orient="vertical"
  buttons="cancel"
  buttonlabelcancel="&button.cancel.label;"
  ondialogcancel="return;"
  width="500"
  onload="document.getElementById('grammalecte-lexicon-editor-window').centerWindowOnScreen();"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <!-- Other elements go here -->
  <hbox>
    <label class="dictionary" value="Dictionnaire personnel" />
    <spacer flex="1" />
    <label class="dic_text align_right" value="Enregistré le :" />
    <label id="dic_save_date" class="dic_text" value="[néant]" />
    <spacer flex="1" />
    <label id="dic_num_entries" class="dic_text align_right" value="0" />
    <label class="dic_text" value="entrées" />
    <spacer flex="1" />
    <button id="import_button" label="Importer" />
    <button id="export_button" label="Exporter" />
  </hbox>

  <tabbox id="tabs" selectedIndex="0">
    <tabs>
      <tab label="&tab.editor.label;"/>
      <tab label="&tab.lexicon.label;"/>
      <tab label="&tab.search.label;"/>
      <tab label="&tab.info.label;"/>
    </tabs>

    <tabpanels>

      <!-- NEW WORD -->
      <tabpanel orient="vertical">

        <hbox>

          <vbox>
            <div class="dialogheader-title">&dialogheader.newword.label;</div>
            <textbox id="lemma" value="" />

            <checkbox id="tag_N" class="subsection" label="Nom et adjectif" />
            <hbox class="m_left">
              <radiogroup id="pos_nom_commun" orient="vertical">
                <radio id="nom_adj" class="option" label="Nom et adjectif" value=":N:A" />
                <radio id="nom" class="option" label="Nom" value=":N" />
                <radio id="adj" class="option" label="Adjectif" value=":A" />
              </radiogroup>
              <radiogroup id="genre_nom_commun" orient="vertical">
                <radio id="N_epi" class="option" label="épicène" value=":e" />
                <radio id="N_mas" class="option" label="masculin" value=":m" />
                <radio id="N_fem" class="option" label="féminin" value=":f" />
              </radiogroup>
              <radiogroup id="pluriel_nom_commun" orient="vertical">
                <radio id="N_s" class="option" label="pluriel en ·s" value="s" />
                <radio id="N_x" class="option" label="pluriel en ·x" value="x" />
                <radio id="N_inv" class="option" label="invariable" value="i" />
              </radiogroup>
            </hbox>
            <vbox class="m_left2">
              <label class="subsection" value="[optionnel] Autre forme (masculine, féminine, variante…)" />
              <textbox id="lemma2" value="" />
              <hbox>
                <radiogroup id="pos_nom_commun2" orient="vertical">
                  <radio id="nom_adj2" class="option" label="Nom et adjectif" value=":N:A" />
                  <radio id="nom2" class="option" label="Nom" value=":N" />
                  <radio id="adj2" class="option" label="Adjectif" value=":A" />
                </radiogroup>
                <radiogroup id="genre_nom_commun2" orient="vertical">
                  <radio id="N_epi2" class="option" label="épicène" value=":e" />
                  <radio id="N_mas2" class="option" label="masculin" value=":m" />
                  <radio id="N_fem2" class="option" label="féminin" value=":f" />
                </radiogroup>
                <radiogroup id="pluriel_nom_commun2" orient="vertical">
                  <radio id="N_s2" class="option" label="pluriel en ·s" value="s" />
                  <radio id="N_x2" class="option" label="pluriel en ·x" value="x" />
                  <radio id="N_inv2" class="option" label="invariable" value="inv" />
                </radiogroup>
              </hbox>
            </vbox>

            <checkbox id="tag_M" class="subsection" label="Nom propre" />
            <hbox class="m_left">
              <radiogroup id="pos_nom_propre" orient="vertical">
                <radio id="M1" class="option" label="Prénom" value=":M1" />
                <radio id="M2" class="option" label="Patronyme" value=":M2" />
                <radio id="MP" class="option" label="Autre" value=":MP" />
              </radiogroup>
              <radiogroup id="genre_nom_propre" orient="vertical">
                <radio id="M_epi" class="option" label="épicène" value=":e" />
                <radio id="M_mas" class="option" label="masculin" value=":m" />
                <radio id="M_fem" class="option" label="féminin" value=":f" />
              </radiogroup>
            </hbox>

            <checkbox id="tag_V" class="subsection" label="Verbe" />
            <hbox class="m_left">
              <vbox>
                <checkbox id="v_i" class="v_usage" label="intransitif" />
                <checkbox id="v_t" class="v_usage" label="transitif" />
                <checkbox id="v_n" class="v_usage" label="transitif indirect" />
                <checkbox id="v_p" class="v_usage" label="pronominal" />
                <checkbox id="v_m" class="v_usage" label="impersonnel" />
              </vbox>
              <vbox>
                <label value="Auxilaire avec le passé composé" />
                <checkbox id="v_ae" class="v_usage" label="être" />
                <checkbox id="v_aa" class="v_usage" label="avoir" />
                <label value="" />
                <checkbox id="v_ppas" class="v_usage" label="Participe passé invariable" />
              </vbox>
            </hbox>
            <hbox class="m_left">
              <label class="subsection" value="Verbe modèle [optionnel]" />
              <textbox id="verbe_modele" class="v_textbox" value="" />
            </hbox>

            <checkbox id="tag_W" class="subsection" label="Adverbe" />

            <checkbox id="tag_X" class="subsection" label="Autre" />
            <vbox class="m_left">
              <hbox>
                <label class="subsection other_label" value="Flexion" />
                <textbox id="flexion" class="other_textbox" value="" />
              </hbox>
              <hbox>
                <label class="subsection other_label" value="Étiquettes" />
                <textbox id="tags" class="other_textbox" value="" />
              </hbox>
            </vbox>
          </vbox>

          <vbox>
            <div class="dialogheader-title">&dialogheader.generated_words.label;</div>
            <richlistbox id="generated_words_table" seltype="multiple">
              <!--
              <listhead>
                <listheader label="Flexions"/>
                <listheader label="Étiquettes"/>
              </listhead>

              <listcols>
                <listcol flex="1"/>
                <listcol flex="1"/>
              </listcols>

              <listitem>
                <listcell label="George"/>
                <listcell label="House"/>
              </listitem>
              -->
            </richlistbox>
            <progressmeter id="progress_new_words" value="0"/>
            <!--<html:progress id="progress_new_words" max="100" value="0">-->
            <hbox>
              <button id="delete_selection" label="Effacer la sélection" />
              <spacer flex="1" />
              <button id="add_to_lexicon" label="Ajouter au lexique" />
            </hbox>
          </vbox>
        </hbox>
      </tabpanel>

      <!-- LEXICON -->
      <tabpanel orient="vertical">
        <div class="dialogheader-title">&dialogheader.lexicon.label;</div>
        <hbox>
          <vbox>
            <hbox>
              <label class="info_label" value="Nombre d’entrées : " />
              <label id="num_entries" class="data" value="0" />
            </hbox>
            <spacer flex="1" />
            <button id="delete_button" label="Supprimer la sélection" />
            <spacer flex="20" />
            <progressmeter id="progress_lexicon" value="0"/>
            <!--<html:progress id="progress_lexicon" max="100" value="0">-->
            <button id="save_button" label="Enregistrer" />
          </vbox>

          <vbox>
            <richlistbox id="lexicon_table" seltype="multiple">
              <!--
              <listhead>
                <listheader label="Flexions"/>
                <listheader label="Lemmes"/>
                <listheader label="Étiquettes"/>
              </listhead>

              <listcols>
                <listcol flex="4"/>
                <listcol flex="3"/>
                <listcol flex="4"/>
              </listcols>

              <listitem>
                <listcell label="George"/>
                <listcell label="House Painter"/>
                <listcell label="House"/>
              </listitem>
              -->
            </richlistbox>
          </vbox>
        </hbox>
      </tabpanel>

      <tabpanel orient="vertical">
        <hbox>
          <vbox>
            <div class="dialogheader-title">&dialogheader.search.similar.label;</div>
            <hbox>
              <textbox id="search_similar" value="" />
              <button id="search_similar_button" label="Chercher" />
            </hbox>

            <spacer flex="1" />

            <div class="dialogheader-title">&dialogheader.search.regex.label;</div>
            <hbox>
              <label value="Flexion" />
              <spacer flex="1" />
              <textbox id="search_flexion_pattern" value="" />
            </hbox>
            <hbox>
              <label value="Étiquettes" />
              <spacer flex="1" />
              <textbox id="search_tags_pattern" value="" />
            </hbox>
            <button id="search_regex_button" label="Chercher" />
            <label value="" />
            <description>La recherche par expressions régulières peut générer un nombre gigantesque de résultats. Seules les 2000 premières occurrences trouvées seront affichées. La recherche peut être longue, parce tout le graphe de mots, qui contient 500 000 flexions, sera parcouru si besoin.</description>

            <spacer flex="1" />

            <progressmeter id="progress_search" value="0"/>
            <!--<html:progress id="progress_search" max="100" value="0">-->
            <hbox>
              <spacer flex="1" />
              <label id="search_num_entries" class="align_right" value="0" />
              <label value="entrées" />
            </hbox>
          </vbox>
          <vbox>
            <div class="dialogheader-title">&dialogheader.search.result.label;</div>
            <richlistbox id="search_table">
              <!--
              <listhead>
                <listheader label="Flexions"/>
                <listheader label="Lemmes"/>
                <listheader label="Étiquettes"/>
              </listhead>

              <listcols>
                <listcol flex="4"/>
                <listcol flex="3"/>
                <listcol flex="4"/>
              </listcols>

              <listitem>
                <listcell label="George"/>
                <listcell label="House Painter"/>
                <listcell label="House"/>
              </listitem>
              -->
            </richlistbox>
          </vbox>
        </hbox>
      </tabpanel>

      <tabpanel orient="vertical">
        <hbox>
          <vbox>
            <div class="dialogheader-title">&dialogheader.info.label;</div>
            <label class="bold" value="Enregistrement" />
            <description>Les modifications apportées au lexique ne sont enregistrées dans le dictionnaire qu’au moment où vous cliquez sur ‹Enregistrer› dans l’onglet ‹Lexique›.</description>
            <spacer flex="1" />
            <label class="bold" value="Doublons" />
            <description>Il est inutile de purger votre lexique des doublons éventuels. Les doublons sont automatiquement supprimés lors de la création du dictionnaire.</description>
            <spacer flex="1" />
            <label class="bold" value="Compilation du dictionnaire" />
            <description>Le dictionnaire est compilé comme un graphe de mots sous la forme d’une chaîne binaire dans un fichier JSON. Cette opération peut prendre du temps et consommer beaucoup de mémoire si votre lexique contient plusieurs dizaines de milliers d’entrées.</description>
            <spacer flex="1" />
            <label class="bold" value="Avertissement" />
            <description>Il est déconseillé d’utiliser la catégorie ‹Autre› pour générer autre chose que des noms, des adjectifs, des noms propres, des verbes et des adverbes. Il n’y a aucune garantie que les étiquettes pour les autres catégories, notamment les mots grammaticaux, ne changeront pas.</description>
          </vbox>
          <vbox>
            <div class="dialogheader-title">&dialogheader.tags.label;</div>
            <richlistbox id="tags_table">
              <!--
              <listhead>
                <listheader label="Étiquettes"/>
                <listheader label="Signification"/>
              </listhead>

              <listcols>
                <listcol flex="1"/>
                <listcol flex="10"/>
              </listcols>

              <listitem>
                <listcell label="House Painter"/>
                <listcell label="House"/>
              </listitem>
              -->
            </richlistbox>
          </vbox>
        </hbox>
      </tabpanel>

    </tabpanels>

  </tabbox>

  <script type="application/x-javascript" src="resource://grammalecte/graphspell/helpers.js" />
  <script type="application/x-javascript" src="resource://grammalecte/graphspell/str_transform.js" />
  <script type="application/x-javascript" src="resource://grammalecte/graphspell/char_player.js" />
  <script type="application/x-javascript" src="resource://grammalecte/graphspell/dawg.js" />
  <script type="application/x-javascript" src="resource://grammalecte/graphspell/ibdawg.js" />
  <script type="application/x-javascript" src="resource://grammalecte/graphspell/spellchecker.js" />
  <script type="application/x-javascript" src="resource://grammalecte/fr/conj.js" />
  <script type="application/x-javascript" src="resource://grammalecte/fr/conj_generator.js" />
  <script type="application/x-javascript" src="resource://grammalecte/fr/lexicographe.js" />
  <script type="application/x-javascript" src="file_handler.js" />
  <script type="application/x-javascript" src="lex_editor.js" />

</dialog>