You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by vm...@apache.org on 2019/10/30 10:22:08 UTC
svn commit: r1869157 - in /uima/ruta/trunk/ruta-core/src:
main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
test/java/org/apache/uima/ruta/rule/SidestepInComposedTest.java
Author: vmorari
Date: Wed Oct 30 10:22:08 2019
New Revision: 1869157
URL: http://svn.apache.org/viewvc?rev=1869157&view=rev
Log:
UIMA-6119: corrected wrong anchor assignment for disjunct rule element.
Modified:
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/SidestepInComposedTest.java
Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java?rev=1869157&r1=1869156&r2=1869157&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java Wed Oct 30 10:22:08 2019
@@ -87,8 +87,10 @@ public class ComposedRuleElement extends
List<RuleMatch> startRuleMatches = each.startMatch(extendedMatch, null, composedMatch, this,
stream, crowd);
for (RuleMatch startRuleMatch : startRuleMatches) {
+
ComposedRuleElementMatch startElementMatch = (ComposedRuleElementMatch) startRuleMatch
.getLastMatch(this, true);
+
ruleMatches.put(startRuleMatch, startElementMatch);
}
}
@@ -102,8 +104,16 @@ public class ComposedRuleElement extends
MatchContext context = new MatchContext(null, this, eachRuleMatch, true);
AnnotationFS lastAnnotation = eachRuleMatch.getLastMatchedAnnotation(context, stream);
boolean failed = !eachComposedMatch.matched();
+ RuleElement anchoringRuleElement = getAnchoringRuleElement(stream);
+ RutaRuleElement sideStepOrigin = null;
+
+ anchoringRuleElement = updateAnchorForDisjunctMatch(eachComposedMatch, stream);
+
+ if (anchoringRuleElement instanceof RutaRuleElement && hasAncestor(false)) {
+ sideStepOrigin = (RutaRuleElement) anchoringRuleElement;
+ }
List<RuleMatch> fallbackContinue = fallbackContinue(true, failed, lastAnnotation,
- eachRuleMatch, ruleApply, eachComposedMatch, null, entryPoint, stream, crowd);
+ eachRuleMatch, ruleApply, eachComposedMatch, sideStepOrigin, entryPoint, stream, crowd);
result.addAll(fallbackContinue);
}
} else if (conjunct) {
@@ -161,6 +171,24 @@ public class ComposedRuleElement extends
return result;
}
+ private RuleElement updateAnchorForDisjunctMatch(ComposedRuleElementMatch eachComposedMatch, RutaStream stream) {
+
+ Map<RuleElement, List<RuleElementMatch>> innerMatches = eachComposedMatch.getInnerMatches();
+ RuleElement anchoringRuleElement = getAnchoringRuleElement(stream);
+
+ for (Entry<RuleElement, List<RuleElementMatch>> match : innerMatches.entrySet()) {
+ if (match.getValue() != null) {
+ List<RuleElementMatch> matchRuleElements = match.getValue();
+ for (RuleElementMatch elem : matchRuleElements) {
+ if (elem.conditionsMatched) {
+ anchoringRuleElement = match.getKey();
+ }
+ }
+ }
+ }
+ return anchoringRuleElement;
+ }
+
private AnnotationFS getPrefixAnnotation(RuleMatch ruleMatch, RutaStream stream) {
MatchContext context = new MatchContext(this, ruleMatch);
AnnotationFS lastMatchedAnnotation = ruleMatch.getLastMatchedAnnotation(context, stream);
Modified: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/SidestepInComposedTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/SidestepInComposedTest.java?rev=1869157&r1=1869156&r2=1869157&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/SidestepInComposedTest.java (original)
+++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/rule/SidestepInComposedTest.java Wed Oct 30 10:22:08 2019
@@ -22,7 +22,6 @@ package org.apache.uima.ruta.rule;
import org.apache.uima.cas.CAS;
import org.apache.uima.ruta.engine.Ruta;
import org.apache.uima.ruta.engine.RutaTestUtils;
-import org.junit.Ignore;
import org.junit.Test;
public class SidestepInComposedTest {
@@ -42,7 +41,6 @@ public class SidestepInComposedTest {
}
@Test
- @Ignore
public void testAnchorAtDisjunct() throws Exception {
String document = "15. Mai 2005";
String script = "(NUM PERIOD @(SW | CW) NUM){-> T1};\n";