Overview
Comment: | [tb] lexicon editor: search similar words / search by regex |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | tb | multid |
Files: | files | file ages | folders |
SHA3-256: |
7735782edd818c2aaf24b521725c4353 |
User & Date: | olr on 2018-03-21 19:37:47 |
Other Links: | branch diff | manifest | tags |
Context
2018-03-21
| ||
20:17 | [fx] hide button <add to lexicon> when nothing to add check-in: 397861e537 user: olr tags: fx, multid | |
19:37 | [tb] lexicon editor: search similar words / search by regex check-in: 7735782edd user: olr tags: tb, multid | |
17:40 | [graphspell][cli] select by flexion and by tags check-in: 4e94d8cfc8 user: olr tags: cli, graphspell, multid | |
Changes
Modified gc_lang/fr/tb/content/lex_editor.js from [54d7c2964f] to [c528c957f0].
︙ | ︙ | |||
91 92 93 94 95 96 97 | 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; | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 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) { |
︙ | ︙ | |||
472 473 474 475 476 477 478 479 480 481 482 483 484 485 | let sJSON = JSON.stringify(this.oIBDAWG.getJSON()); oFileHandler.saveAs(sJSON); } } const oSearch = { listen: function () { document.getElementById("search_similar_button").addEventListener("click", () => { this.searchSimilar(); }, false); document.getElementById("search_regex_button").addEventListener("click", () => { this.searchRegex() }, false); }, searchSimilar: function () { | > > > > > > > | > > > > > > > > > > > > > > | | > > > > > > > > > > | > | 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 | let sJSON = JSON.stringify(this.oIBDAWG.getJSON()); oFileHandler.saveAs(sJSON); } } 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"], [1, 1], "progress_new_words"); const oLexiconTable = new Table("lexicon_table", ["Flexions", "Lemmes", "Étiquettes"], [10, 7, 10], "progress_lexicon", "num_entries"); const oSearchTable = new Table("search_table", ["Flexions", "Lemmes", "Étiquettes"], [10, 7, 10], "progress_search", "search_num_entries"); const oTagsTable = new Table("tags_table", ["Étiquette", "Signification"], [1, 10], "progress_lexicon"); conj.init(helpers.loadFile("resource://grammalecte/fr/conj_data.json")); oTagsInfo.load(); oSearch.load(); oBinaryDict.load(); oBinaryDict.listen(); oGenerator.listen(); oSearch.listen(); |
Modified gc_lang/fr/tb/content/lex_editor.xul from [b4635c5f8e] to [a7d03be6b4].
︙ | ︙ | |||
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | <hbox> <vbox> <dialogheader title="&dialogheader.search.similar.label;" description="" /> <hbox> <textbox id="search_similar" value="" /> <button id="search_similar_button" label="Chercher" /> </hbox> <spacer flex="1" /> <dialogheader title="&dialogheader.search.regex.label;" description="" /> <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="" /> | > > | > > > > > > > > > | 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 | <hbox> <vbox> <dialogheader title="&dialogheader.search.similar.label;" description="" /> <hbox> <textbox id="search_similar" value="" /> <button id="search_similar_button" label="Chercher" /> </hbox> <spacer flex="1" /> <dialogheader title="&dialogheader.search.regex.label;" description="" /> <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 mots, sera parcouru si besoin.</description> <spacer flex="1" /> <progressmeter id="progress_search" value="0"/> <hbox> <spacer flex="1" /> <label id="search_num_entries" class="align_right" value="0" /> <label value="entrées" /> </hbox> </vbox> <vbox> <dialogheader title="Résultat" description="" /> <listbox id="search_table"> <!-- <listhead> <listheader label="Flexions"/> |
︙ | ︙ | |||
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | </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/dawg.js" /> <script type="application/x-javascript" src="resource://grammalecte/graphspell/ibdawg.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> | > > | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | </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> |