177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
s += `#${dToken["i"]}\t${dToken["nStart"]}:${dToken["nEnd"]}\t${dToken["sValue"]}\t${dToken["sType"]}`;
if (dToken.hasOwnProperty("lMorph")) {
s += "\t" + dToken["lMorph"].toString();
}
if (dToken.hasOwnProperty("aTags")) {
s += "\t" + dToken["aTags"].toString();
}
s += "\n";
}
return s;
}
parse (sCountry="${country_default}", bDebug=false, dOptions=null, bContext=false, bFullInfo=false) {
// analyses <sText> and returns an iterable of errors or (with option <bFullInfo>) a list of sentences with tokens and errors
|
>
>
>
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
s += `#${dToken["i"]}\t${dToken["nStart"]}:${dToken["nEnd"]}\t${dToken["sValue"]}\t${dToken["sType"]}`;
if (dToken.hasOwnProperty("lMorph")) {
s += "\t" + dToken["lMorph"].toString();
}
if (dToken.hasOwnProperty("aTags")) {
s += "\t" + dToken["aTags"].toString();
}
if (dToken.hasOwnProperty("nMultiStartTo")) {
s += "\t>>" + dToken["nMultiStartTo"].toString();
}
s += "\n";
}
return s;
}
parse (sCountry="${country_default}", bDebug=false, dOptions=null, bContext=false, bFullInfo=false) {
// analyses <sText> and returns an iterable of errors or (with option <bFullInfo>) a list of sentences with tokens and errors
|
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
}
// check if there is rules to check for each pointer
for (let oPointer of lPointers) {
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;
|
|
|
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
|
}
// check if there is rules to check for each pointer
for (let oPointer of lPointers) {
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;
|
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
|
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": (sAction) ? sAction.split("|") : [":HM"]
}
this.lTokens[nTokenStart]["nMultiStartTo"] = nTokenEnd;
this.lTokens[nTokenEnd]["nMultiEndFrom"] = nTokenStart;
this.lTokens[nTokenStart]["oMultiToken"] = oMultiToken;
this.lTokens[nTokenEnd]["oMultiToken"] = oMultiToken;
}
else {
console.log("# error: unknown action at " + sLineId);
}
}
else if (cActionType == ">") {
if (bDebug) {
|
|
|
|
>
>
>
|
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
796
797
798
799
|
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": (sAction) ? sAction.split("|") : [":HM"]
}
this.lTokens[nTokenStart]["nMultiStartTo"] = this.lTokens[nTokenEnd]["i"];
this.lTokens[nTokenEnd]["nMultiEndFrom"] = this.lTokens[nTokenStart]["i"];
this.lTokens[nTokenStart]["oMultiToken"] = oMultiToken;
this.lTokens[nTokenEnd]["oMultiToken"] = oMultiToken;
if (bDebug) {
console.log(`" MULTI-TOKEN: ${sAction} [${this.lTokens[nTokenStart]["sValue"]}:${this.lTokens[nTokenEnd]["sValue"]}]`);
}
}
else {
console.log("# error: unknown action at " + sLineId);
}
}
else if (cActionType == ">") {
if (bDebug) {
|