Grammalecte  Check-in [cf1d146f81]

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: cf1d146f81eb22868d1c00352deed1480caa029b8e4badb65b89dd060ca9251d
User & Date: olr on 2018-09-11 12:44:47
Other Links: branch diff | manifest | tags
Context
2018-09-11
12:45
[fx] worker: import rules graph check-in: b122bc9187 user: olr tags: fx, rg
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
Changes

Modified gc_core/js/lang_core/gc_engine.js from [c816ea9b43] to [ca317a7cea].

   180    180   
   181    181       asString () {
   182    182           let s = "===== TEXT =====\n"
   183    183           s += "sentence: " + this.sSentence0 + "\n";
   184    184           s += "now:      " + this.sSentence  + "\n";
   185    185           for (let dToken of this.lToken) {
   186    186               s += '#${dToken["i"]}\t${dToken["nStart"]}:{$dToken["nEnd"]}\t${dToken["sValue"]}\t${dToken["sType"]}';
   187         -            if (dToken.has("lMorph")) {
          187  +            if (dToken.hasOwnProperty("lMorph")) {
   188    188                   s += "\t" + dToken["lMorph"].toString();
   189    189               }
   190         -            if (dToken.has("tags")) {
          190  +            if (dToken.hasOwnProperty("tags")) {
   191    191                   s += "\t" + dToken["tags"].toString();
   192    192               }
   193    193               s += "\n";
   194    194           }
   195    195           return s;
   196    196       }
   197    197   
................................................................................
   255    255                       bChange = false;
   256    256                   }
   257    257                   for (let [sGraphName, sLineId] of lRuleGroup) {
   258    258                       if (!dOptions.has(sGraphName) || dOptions.get(sGraphName)) {
   259    259                           if (bDebug) {
   260    260                               console.log("\n>>>> GRAPH: " + sGraphName + " " + sLineId);
   261    261                           }
   262         -                        sText = this.parseGraph(gc_rules_graph.dAllGraph.get(sGraphName), sCountry, dOptions, bDebug, bContext);
          262  +                        sText = this.parseGraph(gc_rules_graph.dAllGraph[sGraphName] , sCountry, dOptions, bDebug, bContext);
   263    263                       }
   264    264                   }
   265    265               }
   266    266               else if (!sOption || option(sOption)) {
   267    267                   for (let [zRegex, bUppercase, sLineId, sRuleId, nPriority, lActions, lGroups, lNegLookBefore] of lRuleGroup) {
   268    268                       if (!_aIgnoredRules.has(sRuleId)) {
   269    269                           while ((m = zRegex.gl_exec2(sText, lGroups, lNegLookBefore)) !== null) {
................................................................................
   291    291                                                   if (bDebug) {
   292    292                                                       console.log("~ " + sText + "  -- " + m[eAct[0]] + "  # " + sLineId);
   293    293                                                   }
   294    294                                                   break;
   295    295                                               case "=":
   296    296                                                   // disambiguation
   297    297                                                   //console.log("-> disambiguation by " + sLineId + "\nzRegex: " + zRegex.source);
   298         -                                                oEvalFunc[sWhat](sText, m, dDA);
          298  +                                                oEvalFunc[sWhat](sText, m, this.dTokenPos);
   299    299                                                   if (bDebug) {
   300    300                                                       console.log("= " + m[0] + "  # " + sLineId + "\nDA: " + dDA.gl_toString());
   301    301                                                   }
   302    302                                                   break;
   303    303                                               case ">":
   304    304                                                   // we do nothing, this test is just a condition to apply all following actions
   305    305                                                   break;
................................................................................
   593    593                                   // grammar error
   594    594                                   let [iTokenStart, iTokenEnd, cStartLimit, cEndLimit, bCaseSvty, nPriority, sMessage, sURL] = eAct;
   595    595                                   let nTokenErrorStart = (iTokenStart > 0) ? nTokenOffset + iTokenStart : nLastToken + iTokenStart;
   596    596                                   if (this.lToken[nTokenErrorStart].hasOwnProperty("bImmune")) {
   597    597                                       let nTokenErrorEnd = (iTokenEnd > 0) ? nTokenOffset + iTokenEnd : nLastToken + iTokenEnd;
   598    598                                       let nErrorStart = this.nOffsetWithinParagraph + ((cStartLimit == "<") ? this.lToken[nTokenErrorStart]["nStart"] : this.lToken[nTokenErrorStart]["nEnd"]);
   599    599                                       let nErrorEnd = this.nOffsetWithinParagraph + ((cEndLimit == ">") ? this.lToken[nTokenErrorEnd]["nEnd"] : this.lToken[nTokenErrorEnd]["nStart"]);
   600         -                                    if (this.dError.has(nErrorStart) || nPriority > this.dErrorPriority.get(nErrorStart, -1)) {
          600  +                                    if (!this.dError.has(nErrorStart) || nPriority > this.dErrorPriority.get(nErrorStart, -1)) {
   601    601                                           this.dError[nErrorStart] = this._createErrorFromTokens(sWhat, nTokenOffset, nLastToken, nTokenErrorStart, nErrorStart, nErrorEnd, sLineId, sRuleId, bCaseSvty, sMessage, sURL, bShowRuleId, sOption, bContext);
   602    602                                           this.dErrorPriority[nErrorStart] = nPriority;
   603    603                                           if (bDebug) {
   604    604                                               console.log("    NEW_ERROR:  {}  {}:  {}".format(sRuleId, sLineId, this.dError[nErrorStart]));
   605    605                                           }
   606    606                                       }
   607    607                                   }
................................................................................
  1048   1048   }
  1049   1049   
  1050   1050   function morph (dTokenPos, aWord, sPattern, sNegPattern, bNoWord=false) {
  1051   1051       // analyse a tuple (position, word), returns true if not sNegPattern in word morphologies and sPattern in word morphologies (disambiguation on)
  1052   1052       if (!aWord) {
  1053   1053           return bNoWord;
  1054   1054       }
  1055         -    let lMorph = (dTokenPos.has(aWord[0])  &&  dTokenPos.get(aWord[0])).has("lMorph") ? dTokenPos.get(aWord[0])["lMorph"] : _oSpellChecker.getMorph(aWord[1]);
         1055  +    let lMorph = (dTokenPos.has(aWord[0])  &&  dTokenPos.get(aWord[0]))["lMorph"] ? dTokenPos.get(aWord[0])["lMorph"] : _oSpellChecker.getMorph(aWord[1]);
  1056   1056       if (lMorph.length === 0) {
  1057   1057           return false;
  1058   1058       }
  1059   1059       if (sNegPattern) {
  1060   1060           // check negative condition
  1061   1061           if (sNegPattern === "*") {
  1062   1062               // all morph must match sPattern