Index: gc_lang/fr/webext/panel/lex_editor.css ================================================================== --- gc_lang/fr/webext/panel/lex_editor.css +++ gc_lang/fr/webext/panel/lex_editor.css @@ -23,11 +23,10 @@ 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%); @@ -49,29 +48,44 @@ 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: 2px; + padding: 10px 0; 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; } +#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%); @@ -185,12 +199,10 @@ input[placeholder] { color: hsl(0, 0%, 50%); } - - #buttonline { margin-top: 5px; text-align: right; } @@ -222,16 +234,18 @@ #info_page { display: none; } -.button_block { - margin: 5px 0px; - background-color: hsl(210, 10%, 90%); - border-radius: 5px; - padding: 15px; +#tags_table { + width: 500px; } + + +/* + Dictionary +*/ #save_button, #export_button, #import_button { display: none; float: right; padding: 2px 10px; background-color: hsl(150, 50%, 50%); @@ -246,16 +260,19 @@ 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 { @@ -264,25 +281,13 @@ 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; -} + Index: gc_lang/fr/webext/panel/lex_editor.html ================================================================== --- gc_lang/fr/webext/panel/lex_editor.html +++ gc_lang/fr/webext/panel/lex_editor.html @@ -248,22 +248,57 @@
-

Recherche

- - -
+
+
+

Recherche

+ +

Graphies similaires

+ +

Expressions régulières

+ +
+ +
+

Résultats

+ + +
+
+
-

Informations

- +
+
+

Informations

+ +

Enregistrement

+

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

+

+ +

Doublons

+

Il est inutile de purger votre lexique des doublons éventuels. Les doublons sont automatiquement supprimés lors de la création du dictionnaire.

+

+ +

Compilation du dictionnaire

+

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.

+

+ +

Étiquettes rares

+

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.

+
+ +
+
-
+ +
+ @@ -271,9 +306,10 @@ + Index: gc_lang/fr/webext/panel/lex_editor.js ================================================================== --- gc_lang/fr/webext/panel/lex_editor.js +++ gc_lang/fr/webext/panel/lex_editor.js @@ -95,28 +95,30 @@ } class Table { - constructor (sNodeId, lColumn, sProgressBarId, sResultId="") { + 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.nEntry = 0; + this.bDeleteButtons = bDeleteButtons; this._createHeader(); this.listen(); } _createHeader () { let xRowNode = createNode("tr"); - xRowNode.appendChild(createNode("th", { textContent: "·", width: "12px" })); - //xRowNode.appendChild(createNode("th", { textContent: "#" })); + 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); } @@ -160,21 +162,24 @@ } } _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 })); + 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 () { - this.xTable.addEventListener("click", (xEvent) => { this.onTableClick(xEvent); }, false); + if (this.bDeleteButtons) { + this.xTable.addEventListener("click", (xEvent) => { this.onTableClick(xEvent); }, false); + } } onTableClick (xEvent) { try { let xElem = xEvent.target; @@ -550,12 +555,78 @@ 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 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();