Grammalecte  Diff

Differences From Artifact [54d7c2964f]:

To Artifact [c528c957f0]:


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; }, 2000);
        }
        this.lEntry = lFlex;
        this.nEntry = lFlex.length;
        this.showEntryNumber();
    }

    addEntries (lFlex) {







|







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

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
        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 () {

        let sSimilar = document.getElementById("search_similar").value;














    },

    searchRegex: function () {
        let sFlexPattern = document.getElementById("search_flexion_pattern").value;
        let sTagsPattern = document.getElementById("search_tags_pattern").value;










    }
}


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], [10, 7, 10], "progress_search");
const oTagsTable = new Table("tags_table", ["Étiquette", "Signification"], [1, 10], "progress_lexicon");

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


oTagsInfo.load();

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







>
>
>
>
>
>







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



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

















|






>




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();