Grammalecte  Check-in [3d1c080fa8]

Overview
Comment:[core][js] ibdawg initialization
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core | webext2
Files: files | file ages | folders
SHA3-256: 3d1c080fa86bed89f530efe7fa63d18beca426ffc2decec640d47b3ac5b50e49
User & Date: olr on 2017-08-03 10:04:50
Other Links: branch diff | manifest | tags
Context
2017-08-03
10:12
[core][js] don’t use const for modules as objects: const don’t allow to be “redefined” even in a condition which wouldn’t allow redefinition check-in: dfc3a68fbf user: olr tags: core, warning, webext2
10:04
[core][js] ibdawg initialization check-in: 3d1c080fa8 user: olr tags: core, webext2
09:10
[core][js] default properties in conj, phonet and mfsp + export all properties of mfsp check-in: ec97664b24 user: olr tags: core, webext2
Changes

Modified gc_core/js/ibdawg.js from [81ed21aafb] to [d79dcb6b99].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33
//// IBDAWG

"use strict";


if (typeof(exports) !== 'undefined') {
    var str_transform = require("resource://grammalecte/str_transform.js");
    var helpers = require("resource://grammalecte/helpers.js");
}


// String
// Don’t remove. Necessary in TB.
${string}



class IBDAWG {
    // INDEXABLE BINARY DIRECT ACYCLIC WORD GRAPH

    constructor (sDicName) {
        try {

            const dict = JSON.parse(helpers.loadFile("resource://grammalecte/_dictionaries/"+sDicName));
            Object.assign(this, dict);
            //const dict = require("resource://grammalecte/"+sLang+"/dictionary.js");
            //Object.assign(this, dict.dictionary);
        }
        catch (e) {
            throw Error("# Error. File not found or not loadable.\n" + e.message + "\n");
        }
        /*
            Properties:
            sName, nVersion, sHeader, lArcVal, nArcVal, byDic, sLang, nChar, nBytesArc, nBytesNodeAddress,





|
















>
|

<
<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25


26
27
28
29
30
31
32
//// IBDAWG

"use strict";


if (typeof(require) !== 'undefined') {
    var str_transform = require("resource://grammalecte/str_transform.js");
    var helpers = require("resource://grammalecte/helpers.js");
}


// String
// Don’t remove. Necessary in TB.
${string}



class IBDAWG {
    // INDEXABLE BINARY DIRECT ACYCLIC WORD GRAPH

    constructor (sDicName) {
        try {
            let sURL = (typeof(browser) !== 'undefined') ? browser.extension.getURL("grammalecte/_dictionaries/"+sDicName) : "resource://grammalecte/_dictionaries/"+sDicName;
            const dict = JSON.parse(helpers.loadFile(sURL));
            Object.assign(this, dict);


        }
        catch (e) {
            throw Error("# Error. File not found or not loadable.\n" + e.message + "\n");
        }
        /*
            Properties:
            sName, nVersion, sHeader, lArcVal, nArcVal, byDic, sLang, nChar, nBytesArc, nBytesNodeAddress,

Modified gc_core/js/lang_core/gc_engine.js from [57156dedce] to [3c4bc79cac].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Grammar checker engine

${string}
${regex}
${map}


if (typeof(exports) !== 'undefined') {
    var ibdawg = require("resource://grammalecte/ibdawg.js");
    var helpers = require("resource://grammalecte/helpers.js");
    var gc_options = require("resource://grammalecte/${lang}/gc_options.js");
    var gc_rules = require("resource://grammalecte/${lang}/gc_rules.js");
    var cregex = require("resource://grammalecte/${lang}/cregex.js");
    var text = require("resource://grammalecte/text.js");
    var echo = require("resource://grammalecte/helpers.js").echo;
}







|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Grammar checker engine

${string}
${regex}
${map}


if (typeof(require) !== 'undefined') {
    var IBDAWG = require("resource://grammalecte/ibdawg.js").IBDAWG;
    var helpers = require("resource://grammalecte/helpers.js");
    var gc_options = require("resource://grammalecte/${lang}/gc_options.js");
    var gc_rules = require("resource://grammalecte/${lang}/gc_rules.js");
    var cregex = require("resource://grammalecte/${lang}/cregex.js");
    var text = require("resource://grammalecte/text.js");
    var echo = require("resource://grammalecte/helpers.js").echo;
}
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
        return gc_rules.lParagraphRules;
    },

    //// Initialization

    load: function (sContext="JavaScript") {
        try {
            _oDict = new ibdawg.IBDAWG("${dic_name}.json");
            _sAppContext = sContext;
            _dOptions = gc_options.getOptions(sContext).gl_shallowCopy();     // duplication necessary, to be able to reset to default
        }
        catch (e) {
            helpers.logerror(e);
        }
    },







|







308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
        return gc_rules.lParagraphRules;
    },

    //// Initialization

    load: function (sContext="JavaScript") {
        try {
            _oDict = new IBDAWG("${dic_name}.json");
            _sAppContext = sContext;
            _dOptions = gc_options.getOptions(sContext).gl_shallowCopy();     // duplication necessary, to be able to reset to default
        }
        catch (e) {
            helpers.logerror(e);
        }
    },

Modified gc_core/js/str_transform.js from [33525a019a] to [9b41fc7a14].

1
2
3
4
5
6
7
8
9
10
11
12
//// STRING TRANSFORMATION

// Note: 48 is the ASCII code for "0"

const str_transform = {
    getStemFromSuffixCode: function (sFlex, sSfxCode) {
        // Suffix only
        if (sSfxCode == "0") {
            return sFlex;
        }
        return sSfxCode[0] == '0' ? sFlex + sSfxCode.slice(1) : sFlex.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1);
    },




|







1
2
3
4
5
6
7
8
9
10
11
12
//// STRING TRANSFORMATION

// Note: 48 is the ASCII code for "0"

var str_transform = {
    getStemFromSuffixCode: function (sFlex, sSfxCode) {
        // Suffix only
        if (sSfxCode == "0") {
            return sFlex;
        }
        return sSfxCode[0] == '0' ? sFlex + sSfxCode.slice(1) : sFlex.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1);
    },

Modified gc_lang/fr/webext/gce_worker.js from [19de02aa0c] to [ac8c2849c5].

26
27
28
29
30
31
32


33


34
35
36
37
38
39
40
41
42
helpers.echo(conj.getConj("devenir", ":E", ":2s"));

helpers.echo(mfsp.getMasForm("emmerdeuse", true));
helpers.echo(mfsp.getMasForm("pointilleuse", false));

helpers.echo(phonet.getSimil("est"));






let oTokenizer = null;
let oDict = null;
let oLxg = null;

function loadGrammarChecker (sGCOptions="", sContext="JavaScript") {
    if (gce === null) {
        try {
            gce = require("resource://grammalecte/fr/gc_engine.js");
            helpers = require("resource://grammalecte/helpers.js");







>
>

>
>

<







26
27
28
29
30
31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
helpers.echo(conj.getConj("devenir", ":E", ":2s"));

helpers.echo(mfsp.getMasForm("emmerdeuse", true));
helpers.echo(mfsp.getMasForm("pointilleuse", false));

helpers.echo(phonet.getSimil("est"));

let oDict = new IBDAWG("French.json");
helpers.echo(oDict.getMorph("merde"));



let oTokenizer = null;

let oLxg = null;

function loadGrammarChecker (sGCOptions="", sContext="JavaScript") {
    if (gce === null) {
        try {
            gce = require("resource://grammalecte/fr/gc_engine.js");
            helpers = require("resource://grammalecte/helpers.js");

Modified gc_lang/fr/webext/manifest.json from [ce6a6e89b7] to [500a80f533].

28
29
30
31
32
33
34


35
36
37
38
39
40
41
    "default_popup": "panel/main.html",
    "default_title": "Grammalecte [fr]",
    "browser_style": false
  },
  "background": {
    "scripts": [
      "grammalecte/helpers.js",


      "grammalecte/text.js",
      "grammalecte/tokenizer.js",
      "grammalecte/fr/conj.js",
      "grammalecte/fr/mfsp.js",
      "grammalecte/fr/phonet.js",
      "gce_worker.js"
    ]







>
>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
    "default_popup": "panel/main.html",
    "default_title": "Grammalecte [fr]",
    "browser_style": false
  },
  "background": {
    "scripts": [
      "grammalecte/helpers.js",
      "grammalecte/str_transform.js",
      "grammalecte/ibdawg.js",
      "grammalecte/text.js",
      "grammalecte/tokenizer.js",
      "grammalecte/fr/conj.js",
      "grammalecte/fr/mfsp.js",
      "grammalecte/fr/phonet.js",
      "gce_worker.js"
    ]