Overview
Comment: | [core] gc engine: fix several errors |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core | rg |
Files: | files | file ages | folders |
SHA3-256: |
a80212d0a4446b6c678aa577defc899a |
User & Date: | olr on 2018-09-11 12:09:01 |
Original Comment: | [core] fix several errors |
Other Links: | branch diff | manifest | tags |
Context
2018-09-11
| ||
12:44 | [core] gc engine: fix several errors check-in: cf1d146f81 user: olr tags: core, rg | |
12:09 | [core] gc engine: fix several errors check-in: a80212d0a4 user: olr tags: core, rg | |
12:07 | [build] build tests file check-in: 84725dfa46 user: olr tags: build, rg | |
Changes
Modified gc_core/js/lang_core/gc_engine.js from [ad61c52045] to [c816ea9b43].
︙ | ︙ | |||
193 194 195 196 197 198 199 | s += "\n"; } return s; } parse (sText, sCountry="${country_default}", bDebug=false, dOptions=null, bContext=false) { // analyses the paragraph sText and returns list of errors | | | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | s += "\n"; } return s; } parse (sText, sCountry="${country_default}", bDebug=false, dOptions=null, bContext=false) { // analyses the paragraph sText and returns list of errors let dOpt = dOptions || _dOptions; // parse paragraph try { this.parseText(this.sText, this.sText0, true, 0, sCountry, dOpt, bDebug, bContext); } catch (e) { console.error(e); } |
︙ | ︙ | |||
241 242 243 244 245 246 247 248 249 250 251 252 253 254 | } return Array.from(this.dError.values()); } parseText (sText, sText0, bParagraph, nOffset, sCountry, dOptions, bDebug, bContext) { let bChange = false; let bIdRule = option('idrule'); for (let [sOption, lRuleGroup] of gc_engine.getRules(bParagraph)) { if (sOption == "@@@@") { // graph rules if (!bParagraph && bChange) { this.update(sText, bDebug); bChange = false; | > | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | } return Array.from(this.dError.values()); } parseText (sText, sText0, bParagraph, nOffset, sCountry, dOptions, bDebug, bContext) { let bChange = false; let bIdRule = option('idrule'); let m; for (let [sOption, lRuleGroup] of gc_engine.getRules(bParagraph)) { if (sOption == "@@@@") { // graph rules if (!bParagraph && bChange) { this.update(sText, bDebug); bChange = false; |
︙ | ︙ | |||
262 263 264 265 266 267 268 | } } } else if (!sOption || option(sOption)) { for (let [zRegex, bUppercase, sLineId, sRuleId, nPriority, lActions, lGroups, lNegLookBefore] of lRuleGroup) { if (!_aIgnoredRules.has(sRuleId)) { while ((m = zRegex.gl_exec2(sText, lGroups, lNegLookBefore)) !== null) { | | | | | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | } } } else if (!sOption || option(sOption)) { for (let [zRegex, bUppercase, sLineId, sRuleId, nPriority, lActions, lGroups, lNegLookBefore] of lRuleGroup) { if (!_aIgnoredRules.has(sRuleId)) { while ((m = zRegex.gl_exec2(sText, lGroups, lNegLookBefore)) !== null) { let bCondMemo = null; for (let [sFuncCond, cActionType, sWhat, ...eAct] of lActions) { // action in lActions: [ condition, action type, replacement/suggestion/action[, iGroup[, message, URL]] ] try { bCondMemo = (!sFuncCond || oEvalFunc[sFuncCond](sText, sText0, m, this.dTokenPos, sCountry, bCondMemo)); if (bCondMemo) { switch (cActionType) { case "-": // grammar error //console.log("-> error detected in " + sLineId + "\nzRegex: " + zRegex.source); let nErrorStart = nOffset + m.start[eAct[0]]; if (!this.dError.has(nErrorStart) || nPriority > this.dErrorPriority.get(nErrorStart)) { this.dError.set(nErrorStart, this._createErrorFromRegex(sText, sText0, sWhat, nOffset, m, eAct[0], sLineId, sRuleId, bUppercase, eAct[1], eAct[2], bIdRule, sOption, bContext)); this.dErrorPriority.set(nErrorStart, nPriority); } break; case "~": // text processor |
︙ | ︙ | |||
308 309 310 311 312 313 314 | } else { if (cActionType == ">") { break; } } } catch (e) { | | | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | } else { if (cActionType == ">") { break; } } } catch (e) { console.log(sText); console.log("# line id: " + sLineId + "\n# rule id: " + sRuleId); console.error(e); } } } } } |
︙ | ︙ | |||
332 333 334 335 336 337 338 | } update (sSentence, bDebug=false) { // update <sSentence> and retokenize this.sSentence = sSentence; let lNewToken = Array.from(_oTokenizer.genTokens(sSentence, true)); for (let dToken of lNewToken) { | | | | | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | } update (sSentence, bDebug=false) { // update <sSentence> and retokenize this.sSentence = sSentence; let lNewToken = Array.from(_oTokenizer.genTokens(sSentence, true)); for (let dToken of lNewToken) { if (this.dTokenPos.gl_get(dToken["nStart"], {}).hasOwnProperty("lMorph")) { dToken["lMorph"] = this.dTokenPos.get(dToken["nStart"])["lMorph"]; } if (this.dTokenPos.gl_get(dToken["nStart"], {}).hasOwnProperty("tags")) { dToken["tags"] = this.dTokenPos.get(dToken["nStart"])["tags"]; } } this.lToken = lNewToken; this.dTokenPos.clear(); for (let dToken of this.lToken) { if (dToken["sType"] != "INFO") { this.dTokenPos.set(dToken["nStart"], dToken); |
︙ | ︙ | |||
690 691 692 693 694 695 696 | } } } return bChange; } _createErrorFromRegex (sText, sText0, sSugg, nOffset, m, iGroup, sLineId, sRuleId, bUppercase, sMsg, sURL, bShowRuleId, sOption, bContext) { | | | | 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | } } } return bChange; } _createErrorFromRegex (sText, sText0, sSugg, nOffset, m, iGroup, sLineId, sRuleId, bUppercase, sMsg, sURL, bShowRuleId, sOption, bContext) { let nStart = nOffset + m.start[iGroup]; let nEnd = nOffset + m.end[iGroup]; // suggestions let lSugg = []; if (sSugg.startsWith("=")) { sSugg = oEvalFunc[sSugg.slice(1)](sText, m); lSugg = (sSugg) ? sSugg.split("|") : []; } else if (sSugg == "_") { lSugg = []; |
︙ | ︙ | |||
738 739 740 741 742 743 744 | sMessage += " ## " + sLineId + " # " + sRuleId; } // return this._createError(nStart, nEnd, sLineId, sRuleId, sOption, sMessage, lSugg, sURL, bContext); } _createError (nStart, nEnd, sLineId, sRuleId, sOption, sMessage, lSugg, sURL, bContext) { | | | 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | sMessage += " ## " + sLineId + " # " + sRuleId; } // return this._createError(nStart, nEnd, sLineId, sRuleId, sOption, sMessage, lSugg, sURL, bContext); } _createError (nStart, nEnd, sLineId, sRuleId, sOption, sMessage, lSugg, sURL, bContext) { let oErr = { "nStart": nStart, "nEnd": nEnd, "sLineId": sLineId, "sRuleId": sRuleId, "sType": sOption || "notype", "sMessage": sMessage, "aSuggestions": lSugg, |
︙ | ︙ |