︙ | | |
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
-
+
|
},
_zEndOfSentence: new RegExp ('([.?!:;…][ .?!… »”")]*|.$)', "g"),
_zBeginOfParagraph: new RegExp ("^[- –—.,;?!…]*", "ig"),
_zEndOfParagraph: new RegExp ("[- .,;?!…–—]*$", "ig"),
_getSentenceBoundaries: function* (sText) {
let mBeginOfSentence = this._zBeginOfParagraph.exec(sText)
let mBeginOfSentence = this._zBeginOfParagraph.exec(sText);
let iStart = this._zBeginOfParagraph.lastIndex;
let m;
while ((m = this._zEndOfSentence.exec(sText)) !== null) {
yield [iStart, this._zEndOfSentence.lastIndex];
iStart = this._zEndOfSentence.lastIndex;
}
},
|
︙ | | |
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
-
+
|
/*if (bDebug) {
echo(">>>> Rule # " + sLineId + " - Text: " + s + " opt: "+ sOption);
}*/
for (let [sFuncCond, cActionType, sWhat, ...eAct] of lActions) {
// action in lActions: [ condition, action type, replacement/suggestion/action[, iGroup[, message, URL]] ]
try {
//echo(oEvalFunc[sFuncCond]);
bCondMemo = (!sFuncCond || oEvalFunc[sFuncCond](s, sx, m, dDA, sCountry, bCondMemo))
bCondMemo = (!sFuncCond || oEvalFunc[sFuncCond](s, sx, m, dDA, sCountry, bCondMemo));
if (bCondMemo) {
switch (cActionType) {
case "-":
// grammar error
//echo("-> error detected in " + sLineId + "\nzRegex: " + zRegex.source);
nErrorStart = nOffset + m.start[eAct[0]];
if (!dErrs.has(nErrorStart) || nPriority > dPriority.get(nErrorStart)) {
|
︙ | | |
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
-
+
|
} else {
oErr["aSuggestions"] = sRepl.gl_expand(m).split("|");
}
}
// Message
let sMessage = "";
if (sMsg.slice(0,1) === "=") {
sMessage = oEvalFunc[sMsg.slice(1)](s, m)
sMessage = oEvalFunc[sMsg.slice(1)](s, m);
} else {
sMessage = sMsg.gl_expand(m);
}
if (bIdRule) {
sMessage += " ##" + sLineId + " #" + sRuleId;
}
oErr["sMessage"] = sMessage;
|
︙ | | |
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
-
+
|
getDefaultOptions: function () {
return gc_options.getOptions(_sAppContext).gl_shallowCopy();
},
resetOptions: function () {
_dOptions = gc_options.getOptions(_sAppContext).gl_shallowCopy();
}
}
};
//////// Common functions
function option (sOpt) {
// return true if option sOpt is active
return _dOptions.get(sOpt);
|
︙ | | |
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
-
+
|
// returns a list of sWord's stems
if (!sWord) {
return [];
}
if (!_dAnalyses.has(sWord) && !_storeMorphFromFSA(sWord)) {
return [];
}
return [ for (s of _dAnalyses.get(sWord)) s.slice(1, s.indexOf(" ")) ];
return _dAnalyses.get(sWord).map( s => s.slice(1, s.indexOf(" ")) );
}
//// functions to get text outside pattern scope
// warning: check compile_rules.py to understand how it works
|
︙ | | |
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
-
+
|
if (!_dAnalyses.has(sWord) && !_storeMorphFromFSA(sWord)) {
return true;
}
//echo("morph: "+_dAnalyses.get(sWord).toString());
if (_dAnalyses.get(sWord).length === 1) {
return true;
}
let lSelect = [ for (sMorph of _dAnalyses.get(sWord)) if (sMorph.search(sPattern) !== -1) sMorph ];
let lSelect = _dAnalyses.get(sWord).filter( sMorph => sMorph.search(sPattern) === -1 );
//echo("lSelect: "+lSelect.toString());
if (lSelect.length > 0) {
if (lSelect.length != _dAnalyses.get(sWord).length) {
dDA.set(nPos, lSelect);
}
} else if (lDefault) {
dDA.set(nPos, lDefaul);
|
︙ | | |
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
|
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
|
-
+
|
}
if (!_dAnalyses.has(sWord) && !_storeMorphFromFSA(sWord)) {
return true;
}
if (_dAnalyses.get(sWord).length === 1) {
return true;
}
let lSelect = [ for (sMorph of _dAnalyses.get(sWord)) if (sMorph.search(sPattern) === -1) sMorph ];
let lSelect = _dAnalyses.get(sWord).filter( sMorph => sMorph.search(sPattern) === -1 );
//echo("lSelect: "+lSelect.toString());
if (lSelect.length > 0) {
if (lSelect.length != _dAnalyses.get(sWord).length) {
dDA.set(nPos, lSelect);
}
} else if (lDefault) {
dDA.set(nPos, lDefault);
|
︙ | | |