Grammalecte  Diff

Differences From Artifact [c712d65b9e]:

To Artifact [e250bfaf63]:


31
32
33
34
35
36
37

38
39
40
41
42
43
44
45
46
47
48
49
// commons regexes
const _zEndOfSentence = new RegExp ('([.?!:;…][ .?!… »”")]*|.$)', "g");
const _zBeginOfParagraph = new RegExp ("^[-  –—.,;?!…]*", "ig");
const _zEndOfParagraph = new RegExp ("[-  .,;?!…–—]*$", "ig");

// grammar rules and dictionary
//const _rules = require("./gc_rules.js");

const _rules = require("resource://grammalecte/${lang}/gc_rules.js");
let _dOptions = gc_options.dOpt._shallowCopy();     // duplication necessary, to be able to reset to default
let _aIgnoredRules = new Set();
let _oDict = null;
let _dAnalyses = new Map();                        // cache for data from dictionary


///// Parsing

function parse (sText, sCountry="${country_default}", bDebug=false, bContext=false) {
    // analyses the paragraph sText and returns list of errors
    let dErrors;







>

|


|







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// commons regexes
const _zEndOfSentence = new RegExp ('([.?!:;…][ .?!… »”")]*|.$)', "g");
const _zBeginOfParagraph = new RegExp ("^[-  –—.,;?!…]*", "ig");
const _zEndOfParagraph = new RegExp ("[-  .,;?!…–—]*$", "ig");

// grammar rules and dictionary
//const _rules = require("./gc_rules.js");
let _sContext = "";                                 // what software is running
const _rules = require("resource://grammalecte/${lang}/gc_rules.js");
let _dOptions = null;
let _aIgnoredRules = new Set();
let _oDict = null;
let _dAnalyses = new Map();                         // cache for data from dictionary


///// Parsing

function parse (sText, sCountry="${country_default}", bDebug=false, bContext=false) {
    // analyses the paragraph sText and returns list of errors
    let dErrors;
291
292
293
294
295
296
297
298
299
300


301
302
303
304
305
306
307
        helpers.logerror(e);
    }
}


//////// init

function load () {
    try {
        _oDict = new ibdawg.IBDAWG("${dic_name}.json");


    }
    catch (e) {
        helpers.logerror(e);
    }
}

function setOption (sOpt, bVal) {







|


>
>







292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
        helpers.logerror(e);
    }
}


//////// init

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

function setOption (sOpt, bVal) {
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
}

function getOptions () {
    return _dOptions;
}

function getDefaultOptions () {
    return gc_options.dOpt._shallowCopy();
}

function resetOptions () {
    _dOptions = gc_options.dOpt._shallowCopy();
}

function getDictionary () {
    return _oDict;
}

function _getRules (bParagraph) {







|



|







318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
}

function getOptions () {
    return _dOptions;
}

function getDefaultOptions () {
    return gc_options.getOptions(_sContext)._shallowCopy();
}

function resetOptions () {
    _dOptions = gc_options.getOptions(_sContext)._shallowCopy();
}

function getDictionary () {
    return _oDict;
}

function _getRules (bParagraph) {