Grammalecte  Check-in [b7574fbc3d]

Overview
Comment:[fx] lexicon editor: update > informations
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | multid
Files: files | file ages | folders
SHA3-256: b7574fbc3dd770ad2d061d80896bfebeb98c6b8456627df00f0ea5194c1008eb
User & Date: olr on 2018-03-22 11:08:43
Other Links: branch diff | manifest | tags
Context
2018-03-23
12:38
[graphspell] spellchecker: select returns an array instead of a string, + getSimilarEntries check-in: 1fb5cf9076 user: olr tags: graphspell, multid
2018-03-22
11:08
[fx] lexicon editor: update > informations check-in: b7574fbc3d user: olr tags: fx, multid
2018-03-21
22:29
[fx] lexicon editor: object for tabulations/pages check-in: 17064cfc52 user: olr tags: fx, multid
Changes

Modified gc_lang/fr/webext/panel/lex_editor.css from [fb81dc32de] to [83dba8cfa5].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

body {
    background: hsl(0, 0%, 100%) url(../img/lines.png);
    font: normal 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
    color: #505050;
}


.inbox {
    width: 800px;
    margin: 20px auto 10px auto;
    padding: 10px 30px 30px 30px;
    background: hsl(0, 0%, 100%);
    border: 2px solid #F0F0F0;
    border-radius: 20px;







<







21
22
23
24
25
26
27

28
29
30
31
32
33
34

body {
    background: hsl(0, 0%, 100%) url(../img/lines.png);
    font: normal 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
    color: #505050;
}


.inbox {
    width: 800px;
    margin: 20px auto 10px auto;
    padding: 10px 30px 30px 30px;
    background: hsl(0, 0%, 100%);
    border: 2px solid #F0F0F0;
    border-radius: 20px;
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
    font: bold 20px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
}
h3 {
    margin: 3px 0 2px 0;
    color: hsl(210, 50%, 50%);
    font: bold 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
}

#buttons {
    padding: 2px;


    justify-content: center;
}

#lexicon_button {
    background-color: hsl(210, 80%, 90%);

    color: hsl(210, 80%, 30%);


    font-weight: bold;
}




.main_button {
    margin: 0 5px;
    width: 100px;
    padding: 10px 20px;
    background-color: hsl(210, 10%, 95%);
    border-radius: 5px;
    text-align: center;
    cursor: pointer;
}







.big_block {
    margin: 10px 0;
    padding: 10px;
    background-color: hsl(210, 20%, 96%);
    border-radius: 5px;
}








|
|
>
>
|

>
|
<
>
|
>
>
|
|
>
>
>
>









>
>
>
>
>
>







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
    font: bold 20px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
}
h3 {
    margin: 3px 0 2px 0;
    color: hsl(210, 50%, 50%);
    font: bold 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
}

details {
    font-size: 11px;
    font-variant: small-caps;
    color: hsl(210, 50%, 50%);
    cursor: pointer;
}
details > * {
    font-size: 12px;

    font-variant: normal;
    color: hsl(210, 0%, 0%);
    cursor: auto;
}


#buttons {
    padding: 10px 0;
    justify-content: center;
}
.main_button {
    margin: 0 5px;
    width: 100px;
    padding: 10px 20px;
    background-color: hsl(210, 10%, 95%);
    border-radius: 5px;
    text-align: center;
    cursor: pointer;
}
#lexicon_button {
    background-color: hsl(210, 80%, 90%);
    color: hsl(210, 80%, 30%);
    font-weight: bold;
}


.big_block {
    margin: 10px 0;
    padding: 10px;
    background-color: hsl(210, 20%, 96%);
    border-radius: 5px;
}
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
    color: hsl(0, 0%, 20%);
}
input[placeholder] {
    color: hsl(0, 0%, 50%);
}




#buttonline {
    margin-top: 5px;
    text-align: right;
}

#add_to_lexicon {
    display: none;







<
<







197
198
199
200
201
202
203


204
205
206
207
208
209
210
    color: hsl(0, 0%, 20%);
}
input[placeholder] {
    color: hsl(0, 0%, 50%);
}




#buttonline {
    margin-top: 5px;
    text-align: right;
}

#add_to_lexicon {
    display: none;
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
    display: none;
}

#info_page {
    display: none;
}

.button_block {
    margin: 5px 0px;

    background-color: hsl(210, 10%, 90%);
    border-radius: 5px;
    padding: 15px;
}



#save_button, #export_button, #import_button {
    display: none;
    float: right;
    padding: 2px 10px;
    background-color: hsl(150, 50%, 50%);
    color: hsl(150, 0%, 100%);
    border-radius: 3px;
    cursor: pointer;
}
#export_button, #import_button {
    display: block;
    margin-left: 5px;
    background-color: hsl(210, 50%, 50%);
    color: hsl(210, 0%, 100%);
}
#import_button {
    display: none;
}

#wait_progress {
    width: 100%;
    height: 4px;
}





table {
    border: 1px solid hsl(210, 10%, 50%);
    width: 100%;
}
th {
    padding: 5px 10px;
    border-left: 1px solid hsl(210, 10%, 90%);
    text-align: left;
}
td {
    padding: 0 10px;
}

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


details {
    font-size: 11px;
    font-variant: small-caps;
    color: hsl(210, 50%, 50%);
    cursor: pointer;
}
details > * {
    font-size: 12px;
    font-variant: normal;
    color: hsl(210, 0%, 0%);
    cursor: auto;
}







|
|
>
|
<
<
|
>
>
>


















<





>
>
>
>












<







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






    display: none;
}

#info_page {
    display: none;
}

#tags_table {
    width: 500px;
}




/*
    Dictionary
*/
#save_button, #export_button, #import_button {
    display: none;
    float: right;
    padding: 2px 10px;
    background-color: hsl(150, 50%, 50%);
    color: hsl(150, 0%, 100%);
    border-radius: 3px;
    cursor: pointer;
}
#export_button, #import_button {
    display: block;
    margin-left: 5px;
    background-color: hsl(210, 50%, 50%);
    color: hsl(210, 0%, 100%);
}
#import_button {
    display: none;
}

#wait_progress {
    width: 100%;
    height: 4px;
}


/*
    Table
*/
table {
    border: 1px solid hsl(210, 10%, 50%);
    width: 100%;
}
th {
    padding: 5px 10px;
    border-left: 1px solid hsl(210, 10%, 90%);
    text-align: left;
}
td {
    padding: 0 10px;
}

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














Modified gc_lang/fr/webext/panel/lex_editor.html from [56b8fded37] to [3da6084053].

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
        <table id="lexicon_table">
              
        </table>
      </div> <!-- #lexicon_page -->


      <div id="search_page">


        <h2>Recherche</h2>









        <table id="search_table">
              
        </table>


      </div> <!-- #search_page -->


      <div id="info_page">


        <h2>Informations</h2>


















        <table id="info_table">
              
        </table>


      </div> <!-- #info_page -->

    </div>


    <script src="../grammalecte/graphspell/helpers.js"></script>
    <script src="../grammalecte/graphspell/str_transform.js"></script>
    <script src="../grammalecte/graphspell/dawg.js"></script>
    <script src="../grammalecte/graphspell/ibdawg.js"></script>
    <script src="../grammalecte/fr/conj.js"></script>
    <script src="../grammalecte/fr/conj_generator.js"></script>

    <script src="lex_editor.js"></script>
  </body>
  
</html>







>
>
|
>
>
>
>
>
>
>
>
>
|
|
|
>
>




>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

|
>
>











>




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
        <table id="lexicon_table">
              
        </table>
      </div> <!-- #lexicon_page -->


      <div id="search_page">
        <div class="columns">
          <div>
            <h2>Recherche</h2>

            <h3>Graphies similaires</h3>

            <h3>Expressions régulières</h3>

          </div>

          <div>
            <h2>Résultats</h2>
            <table id="search_table">
                  
            </table>
          </div>
        </div>
      </div> <!-- #search_page -->


      <div id="info_page">
        <div class="columns">
          <div style="margin-right: 20px;">
            <h2>Informations</h2>
            <dialogheader title="&dialogheader.info.label;" description="" />
            <h3>Enregistrement</h3>
            <p>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›.</p>
            <p> </p>

            <h3>Doublons</h3>
            <p>Il est inutile de purger votre lexique des doublons éventuels. Les doublons sont automatiquement supprimés lors de la création du dictionnaire.</p>
            <p> </p>

            <h3>Compilation du dictionnaire</h3>
            <p>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.</p>
            <p> </p>

            <h3>Étiquettes rares</h3>
            <p>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.</p>
          </div>

          <div>
            <table id="tags_table">
              
            </table>
          </div>
        </div>
      </div> <!-- #info_page -->

    </div>


    <script src="../grammalecte/graphspell/helpers.js"></script>
    <script src="../grammalecte/graphspell/str_transform.js"></script>
    <script src="../grammalecte/graphspell/dawg.js"></script>
    <script src="../grammalecte/graphspell/ibdawg.js"></script>
    <script src="../grammalecte/fr/conj.js"></script>
    <script src="../grammalecte/fr/conj_generator.js"></script>
    <script src="../grammalecte/fr/lexicographe.js"></script>
    <script src="lex_editor.js"></script>
  </body>
  
</html>

Modified gc_lang/fr/webext/panel/lex_editor.js from [172790a753] to [848f24fd10].

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
        document.getElementById("info_button").addEventListener("click", () => { this.showPage("info_page"); }, false);
    }
}


class Table {

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

        this._createHeader();
        this.listen();
    }

    _createHeader () {
        let xRowNode = createNode("tr");

        xRowNode.appendChild(createNode("th", { textContent: "·", width: "12px" }));
        //xRowNode.appendChild(createNode("th", { textContent: "#" }));

        for (let sColumn of this.lColumn) {
            xRowNode.appendChild(createNode("th", { textContent: sColumn }));
        }
        this.xTable.appendChild(xRowNode);
    }

    clear () {







|








|
>






>
|
<
>







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
        document.getElementById("info_button").addEventListener("click", () => { this.showPage("info_page"); }, false);
    }
}


class Table {

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

    _createHeader () {
        let xRowNode = createNode("tr");
        if (this.bDeleteButtons) {
            xRowNode.appendChild(createNode("th", { textContent: "·", width: "12px" }));

        }
        for (let sColumn of this.lColumn) {
            xRowNode.appendChild(createNode("th", { textContent: sColumn }));
        }
        this.xTable.appendChild(xRowNode);
    }

    clear () {
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
        if (this.xNumEntry) {
            this.xNumEntry.textContent = this.nEntry;
        }
    }

    _addRow (lData) {
        let xRowNode = createNode("tr", { id: this.sNodeId + "_row_" + this.iEntryIndex });

        xRowNode.appendChild(createNode("td", { textContent: "×", className: "delete_entry", title: "Effacer cette entrée" }, { id_entry: this.iEntryIndex }));
        //xRowNode.appendChild(createNode("td", { textContent: this.iEntryIndex }));

        for (let data of lData) {
            xRowNode.appendChild(createNode("td", { textContent: data }));
        }
        this.xTable.appendChild(xRowNode);
        this.iEntryIndex += 1;
    }

    listen () {

        this.xTable.addEventListener("click", (xEvent) => { this.onTableClick(xEvent); }, false);

    }

    onTableClick (xEvent) {
        try {
            let xElem = xEvent.target;
            if (xElem.className) {
                if (xElem.className == "delete_entry") {







>
|
<
>








>
|
>







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
        if (this.xNumEntry) {
            this.xNumEntry.textContent = this.nEntry;
        }
    }

    _addRow (lData) {
        let xRowNode = createNode("tr", { id: this.sNodeId + "_row_" + this.iEntryIndex });
        if (this.bDeleteButtons) {
            xRowNode.appendChild(createNode("td", { textContent: "×", className: "delete_entry", title: "Effacer cette entrée" }, { id_entry: this.iEntryIndex }));

        }
        for (let data of lData) {
            xRowNode.appendChild(createNode("td", { textContent: data }));
        }
        this.xTable.appendChild(xRowNode);
        this.iEntryIndex += 1;
    }

    listen () {
        if (this.bDeleteButtons) {
            this.xTable.addEventListener("click", (xEvent) => { this.onTableClick(xEvent); }, false);
        }
    }

    onTableClick (xEvent) {
        try {
            let xElem = xEvent.target;
            if (xElem.className) {
                if (xElem.className == "delete_entry") {
548
549
550
551
552
553
554

555


























































556



557



558
559
560
561

        let xBlob = new Blob([ JSON.stringify(this.oIBDAWG.getJSON()) ], {type: 'application/json'}); 
        let sURL = URL.createObjectURL(xBlob);
        browser.downloads.download({ filename: "fr.personal.json", url: sURL, saveAs: true });
    }
}



const oLexiconTable = new Table("lexicon_table", ["Flexions", "Lemmes", "Étiquettes"], "wait_progress", "num_entries");


























































const oGenWordsTable = new Table("generated_words_table", ["Flexions", "Étiquettes"], "wait_progress");







oBinaryDict.load();
oBinaryDict.listen();
oGenerator.listen();
oTabulations.listen();








>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>

>
>
>




>
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
        let xBlob = new Blob([ JSON.stringify(this.oIBDAWG.getJSON()) ], {type: 'application/json'}); 
        let sURL = URL.createObjectURL(xBlob);
        browser.downloads.download({ filename: "fr.personal.json", url: sURL, saveAs: true });
    }
}


const oSearch = {

    oSpellChecker: null,

    load: function () {
        this.oSpellChecker = new SpellChecker("fr", "", "fr.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 lSimilarWords = [];
            for (let l of this.oSpellChecker.suggest(sWord, 20)) {
                lSimilarWords.push(...l);
            }
            let lResult = [];
            for (let sSimilar of lSimilarWords) {
                for (let sMorph of this.oSpellChecker.getMorph(sSimilar)) {
                    let nCut = sMorph.indexOf(" ");
                    lResult.push( [sSimilar, sMorph.slice(1, nCut), sMorph.slice(nCut+1)] );
                }
            }
            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 s of this.oSpellChecker.select(sFlexPattern, sTagsPattern)) {
            lEntry.push(s.split("\t"));
            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"], "wait_progress");
const oLexiconTable = new Table("lexicon_table", ["Flexions", "Lemmes", "Étiquettes"], "wait_progress", "num_entries");
//const oSearchTable = new Table("search_table", ["Flexions", "Lemmes", "Étiquettes"], "wait_progress", "search_num_entries");
const oTagsTable = new Table("tags_table", ["Étiquette", "Signification"], "wait_progress", "", false);


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