Index: gc_core/js/lang_core/gc_engine.js ================================================================== --- gc_core/js/lang_core/gc_engine.js +++ gc_core/js/lang_core/gc_engine.js @@ -548,10 +548,45 @@ } } } } } + // regex multi morph arcs + if (oNode.hasOwnProperty("")) { + if (oToken.hasOwnProperty("nMultiStartTo")) { + let lMorph = oToken["oMultiToken"]["lMorph"]; + for (let sRegex in oNode[""]) { + if (!sRegex.includes("¬")) { + // no anti-pattern + if (lMorph.some(sMorph => (sMorph.search(sRegex) !== -1))) { + yield ["&", sRegex, oNode[""][sRegex]]; + bTokenFound = true; + } + } else { + // there is an anti-pattern + let [sPattern, sNegPattern] = sRegex.split("¬", 2); + if (sNegPattern == "*") { + // all morphologies must match with + if (sPattern) { + if (lMorph.every(sMorph => (sMorph.search(sPattern) !== -1))) { + yield ["&", sRegex, oNode[""][sRegex]]; + bTokenFound = true; + } + } + } else { + if (sNegPattern && lMorph.some(sMorph => (sMorph.search(sNegPattern) !== -1))) { + continue; + } + if (!sPattern || lMorph.some(sMorph => (sMorph.search(sPattern) !== -1))) { + yield ["&", sRegex, oNode[""][sRegex]]; + bTokenFound = true; + } + } + } + } + } + } } // token tags if (oToken.hasOwnProperty("aTags") && oNode.hasOwnProperty("")) { for (let sTag of oToken["aTags"]) { if (oNode[""].hasOwnProperty(sTag)) { @@ -616,11 +651,11 @@ continue; } if (bDebug) { console.log(" MATCH: " + cNodeType + sMatch); } - let nMultiEnd = (cNodeType != "&") ? -1 : dToken["nMultiStartTo"]; + let nMultiEnd = (cNodeType != "&") ? -1 : oToken["nMultiStartTo"]; lNextPointers.push({ "iToken1": oPointer["iToken1"], "iNode": iNode, "nMultiEnd": nMultiEnd }); } } lPointers = lNextPointers; // check arcs of first nodes @@ -629,11 +664,11 @@ continue; } if (bDebug) { console.log(" MATCH: " + cNodeType + sMatch); } - let nMultiEnd = (cNodeType != "&") ? -1 : dToken["nMultiStartTo"]; + let nMultiEnd = (cNodeType != "&") ? -1 : oToken["nMultiStartTo"]; lPointers.push({ "iToken1": iToken, "iNode": iNode, "nMultiEnd": nMultiEnd }); } // check if there is rules to check for each pointer for (let oPointer of lPointers) { if (oPointer["nMultiEnd"] != -1) {