595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
|
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
|
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
+
+
+
+
+
+
+
|
for (let [iToken, oToken] of this.lTokens.entries()) {
if (bDebug) {
console.log("TOKEN: " + oToken["sValue"]);
}
// check arcs for each existing pointer
let lNextPointer = [];
for (let oPointer of lPointer) {
if (oPointer["nMultiEnd"] != -1) {
if (oToken["i"] <= oPointer["nMultiEnd"]) {
lNextPointer.push(oPointer);
}
if (oToken["i"] != oPointer["nMultiEnd"]) {
continue;
}
}
for (let [cActionType, sMatch, iNode] of this._getMatches(oGraph, oToken, oGraph[oPointer["iNode"]])) {
if (cActionType === null) {
lNextPointer.push(oPointer);
continue;
}
if (bDebug) {
console.log(" MATCH: " + cActionType + sMatch);
}
let nMultiEnd = (cActionType != "&") ? -1 : dToken["nMultiStartTo"];
lNextPointer.push({ "iToken1": oPointer["iToken1"], "iNode": iNode });
lNextPointer.push({ "iToken1": oPointer["iToken1"], "iNode": iNode, "nMultiEnd": nMultiEnd });
}
}
lPointer = lNextPointer;
// check arcs of first nodes
for (let [cActionType, sMatch, iNode] of this._getMatches(oGraph, oToken, oGraph[0])) {
if (cActionType === null) {
continue;
}
if (bDebug) {
console.log(" MATCH: " + cActionType + sMatch);
}
let nMultiEnd = (cActionType != "&") ? -1 : dToken["nMultiStartTo"];
lPointer.push({ "iToken1": iToken, "iNode": iNode });
lPointer.push({ "iToken1": iToken, "iNode": iNode, "nMultiEnd": nMultiEnd });
}
// check if there is rules to check for each pointer
for (let oPointer of lPointer) {
if (oPointer["nMultiEnd"] != -1) {
if (oToken["i"] < oPointer["nMultiEnd"]) {
continue;
}
if (oToken["i"] == oPointer["nMultiEnd"]) {
oPointer["nMultiEnd"] = -1;
}
}
if (oGraph[oPointer["iNode"]].hasOwnProperty("<rules>")) {
let bChange = this._executeActions(oGraph, oGraph[oPointer["iNode"]]["<rules>"], oPointer["iToken1"]-1, iToken, dOptions, sCountry, bShowRuleId, bDebug, bContext);
if (bChange) {
bTagAndRewrite = true;
}
}
}
|
655
656
657
658
659
660
661
662
663
664
665
666
667
668
|
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
|
+
|
}
let [_, sOption, sFuncCond, cActionType, sWhat, ...eAct] = gc_rules_graph.dRule[sRuleId];
// Suggestion [ option, condition, "-", replacement/suggestion/action, iTokenStart, iTokenEnd, cStartLimit, cEndLimit, bCaseSvty, nPriority, sMessage, iURL ]
// TextProcessor [ option, condition, "~", replacement/suggestion/action, iTokenStart, iTokenEnd, bCaseSvty ]
// Disambiguator [ option, condition, "=", replacement/suggestion/action ]
// Tag [ option, condition, "/", replacement/suggestion/action, iTokenStart, iTokenEnd ]
// Immunity [ option, condition, "!", "", iTokenStart, iTokenEnd ]
// Immunity [ option, condition, "&", "", iTokenStart, iTokenEnd ]
// Test [ option, condition, ">", "" ]
if (!sOption || dOptions.gl_get(sOption, false)) {
bCondMemo = !sFuncCond || gc_functions[sFuncCond](this.lTokens, nTokenOffset, nLastToken, sCountry, bCondMemo, this.dTags, this.sSentence, this.sSentence0);
if (bCondMemo) {
if (cActionType == "-") {
// grammar error
let [iTokenStart, iTokenEnd, cStartLimit, cEndLimit, bCaseSvty, nPriority, sMessage, iURL] = eAct;
|
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
|
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
this.lTokens[i]["sImmunity"] = sImmunity;
let nErrorStart = this.nOffsetWithinParagraph + this.lTokens[i]["nStart"];
if (this.dError.has(nErrorStart)) {
this.dError.delete(nErrorStart);
}
}
}
}
else if (cActionType == "#") {
// multi-tokens
let nTokenStart = (eAct[0] > 0) ? nTokenOffset + eAct[0] : nLastToken + eAct[0];
let nTokenEnd = (eAct[1] > 0) ? nTokenOffset + eAct[1] : nLastToken + eAct[1];
let oMultiToken = {
"nTokenStart": nTokenStart,
"nTokenEnd": nTokenEnd,
"lTokens": this.lTokens.slice(nTokenStart, nTokenEnd+1),
"lMorph": (sWhat) ? sWhat.split("|") : [":HM"]
}
this.lTokens[nTokenStart]["nMultiStartTo"] = nTokenEnd
this.lTokens[nTokenEnd]["nMultiEndFrom"] = nTokenStart
this.lTokens[nTokenStart]["dMultiToken"] = dMultiToken
this.lTokens[nTokenEnd]["dMultiToken"] = dMultiToken
}
} else {
else {
console.log("# error: unknown action at " + sLineId);
}
}
else if (cActionType == ">") {
if (bDebug) {
console.log(" COND_BREAK");
}
|