Grammalecte  Check-in [e22e75159b]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[njs] cli possibility to change main and personal dictionary
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nodejs
Files: files | file ages | folders
SHA3-256:e22e75159b3eb2f38e873dc40a5c096d8f6380e51bd3100e352cf16d9b442ba5
User & Date: IllusionPerdu 2018-10-21 22:10:35
Context
2018-10-22
11:15
[njs] Move check for loading dictionary in api check-in: c03dede353 user: IllusionPerdu tags: nodejs
2018-10-21
22:10
[njs] cli possibility to change main and personal dictionary check-in: e22e75159b user: IllusionPerdu tags: nodejs
21:45
[njs] core add Set Dictionary for main and personal check-in: 8959d8c2be user: IllusionPerdu tags: nodejs
Changes

Changes to gc_lang/fr/nodejs/cli/bin/gramma-cli.js.

12
13
14
15
16
17
18


19
20
21
22
23
24
25
...
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
...
411
412
413
414
415
416
417
















418
419
420
421
422
423
424
425
426
427
428
Doc :
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
https://stackoverflow.com/questions/41058569/what-is-the-difference-between-const-and-const-in-javascript
*/

const argCmd = require("../lib/minimist.js")(process.argv.slice(2));
const { performance } = require("perf_hooks");



//Initialisation des messages
const msgStart = "\x1b[31mBienvenue sur Grammalecte pour NodeJS!!!\x1b[0m\n";
const msgPrompt = "\x1b[36mGrammaJS\x1b[33m>\x1b[0m ";
const msgSuite = "\x1b[33m…\x1b[0m ";
const msgEnd = "\x1b[31m\x1b[5m\x1b[5mBye bye!\x1b[0m";

................................................................................
function toTitle(aStr) {
    return aStr.charAt(0).toUpperCase() + aStr.slice(1);
}

function repToText(oRep) {
    //console.log(oRep);
    let repText = "";
    for (const action of ["json", "perf", "gceoption", "tfoption", "gcerule"]) {
        if (action in oRep) {
            repText += toTitle(action) + " " + oRep[action];
        }
    }

    for (const action of ["morph", "lemma"]) {
        if (action in oRep) {
................................................................................

    for (const action of ["json", "perf"]) {
        if (getArg(aArg, [action])) {
            repPreference[action] = getArgVal(aArg, [action]);
            repAction[action] = repPreference[action] ? "ON" : "OFF";
        }
    }

















    for (const action of ["gceoption", "tfoption", "gcerule"]) {
        if (getArg(aArg, [action])) {
            let sFonction = (action == "gceoption") ? "GceOption" : (action == "tfoption") ? "TfOption" : "GceIgnoreRule";
            let sOpt = sText.split(" ");
            if (sOpt[0] == "reset") {
                oGrammarChecker["reset" + sFonction + "s"]();
                repAction[action] = "reset";
            } else {
                for (const optAction of sOpt) {
                    let bOptVal = optAction[0] == "+" ? true : false;







>
>







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
...
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
Doc :
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
https://stackoverflow.com/questions/41058569/what-is-the-difference-between-const-and-const-in-javascript
*/

const argCmd = require("../lib/minimist.js")(process.argv.slice(2));
const { performance } = require("perf_hooks");
const path = require("path");
const fs = require("fs");

//Initialisation des messages
const msgStart = "\x1b[31mBienvenue sur Grammalecte pour NodeJS!!!\x1b[0m\n";
const msgPrompt = "\x1b[36mGrammaJS\x1b[33m>\x1b[0m ";
const msgSuite = "\x1b[33m…\x1b[0m ";
const msgEnd = "\x1b[31m\x1b[5m\x1b[5mBye bye!\x1b[0m";

................................................................................
function toTitle(aStr) {
    return aStr.charAt(0).toUpperCase() + aStr.slice(1);
}

function repToText(oRep) {
    //console.log(oRep);
    let repText = "";
    for (const action of ["json", "perf", "gceoption", "tfoption", "gcerule", "dicomain", "dicoperso"]) {
        if (action in oRep) {
            repText += toTitle(action) + " " + oRep[action];
        }
    }

    for (const action of ["morph", "lemma"]) {
        if (action in oRep) {
................................................................................

    for (const action of ["json", "perf"]) {
        if (getArg(aArg, [action])) {
            repPreference[action] = getArgVal(aArg, [action]);
            repAction[action] = repPreference[action] ? "ON" : "OFF";
        }
    }

    if (getArg(aArg, ["dicomain"])) {
        let filename = sText.endsWith(".json") ? sText : sText + ".json";
        repAction["dicomain"] = "Chargement du dictionnaire principal " + (oGrammarChecker.setMainDictionary(filename) ? "OK" : "Pas OK");
    }

    if (getArg(aArg, ["dicoperso"])) {
        let pathnormalized = path.normalize(sText);
        if (fs.existsSync(pathnormalized)) {
            let filename = path.basename(pathnormalized);
            let dirname = path.dirname(pathnormalized);
            repAction["dicoperso"] = "Chargement du dictionnaire personnel " + (oGrammarChecker.setPersonalDictionary(filename, dirname) ? "OK" : "Pas OK");
        } else {
            repAction["dicoperso"] = "Le fichier de dictionnaire n'existe pas.";
        }
    }

    for (const action of ["gceoption", "tfoption", "gcerule"]) {
        if (getArg(aArg, [action])) {
            let sFonction = action == "gceoption" ? "GceOption" : action == "tfoption" ? "TfOption" : "GceIgnoreRule";
            let sOpt = sText.split(" ");
            if (sOpt[0] == "reset") {
                oGrammarChecker["reset" + sFonction + "s"]();
                repAction[action] = "reset";
            } else {
                for (const optAction of sOpt) {
                    let bOptVal = optAction[0] == "+" ? true : false;