Author: pkluegl Date: Tue Nov 5 15:59:38 2019 New Revision: 1869414 URL: http://svn.apache.org/viewvc?rev=1869414&view=rev Log: UIMA-6119: allow composed rule elements as side step origin in order to avoid workarounds
Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleElement.java uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ConjunctRulesRuleElement.java uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElement.java uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.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/AbstractRuleElement.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleElement.java?rev=1869414&r1=1869413&r2=1869414&view=diff ============================================================================== --- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleElement.java (original) +++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleElement.java Tue Nov 5 15:59:38 2019 @@ -79,6 +79,52 @@ public abstract class AbstractRuleElemen } } + @Override + public List<RuleMatch> continueSideStep(boolean after, RuleMatch ruleMatch, RuleApply ruleApply, + ComposedRuleElementMatch containerMatch, RuleElement entryPoint, RutaStream stream, + InferenceCrowd crowd) { + List<RuleMatch> result = new ArrayList<RuleMatch>(); + boolean newDirection = !after; + List<AnnotationFS> matchedAnnotationsOf = ruleMatch.getMatchedAnnotationsOfElement(this); + AnnotationFS annotation = null; + if (!matchedAnnotationsOf.isEmpty()) { + if (newDirection) { + annotation = matchedAnnotationsOf.get(matchedAnnotationsOf.size() - 1); + } else { + annotation = matchedAnnotationsOf.get(0); + } + ComposedRuleElementMatch sideStepContainerMatch = containerMatch; + if (!containerMatch.getRuleElement().equals(getContainer())) { + List<List<RuleElementMatch>> matchInfo = ruleMatch + .getMatchInfo((ComposedRuleElement) getContainer()); + if (newDirection) { + List<RuleElementMatch> list = matchInfo.get(matchInfo.size() - 1); + sideStepContainerMatch = (ComposedRuleElementMatch) list.get(list.size() - 1); + } else { + List<RuleElementMatch> list = matchInfo.get(0); + sideStepContainerMatch = (ComposedRuleElementMatch) list.get(0); + } + } + MatchContext context = new MatchContext(this, ruleMatch, newDirection); + if (quantifier.continueMatch(newDirection, context, annotation, sideStepContainerMatch, + stream, crowd)) { + continueMatch(newDirection, annotation, ruleMatch, ruleApply, sideStepContainerMatch, null, + entryPoint, stream, crowd); + } else { + RuleElement nextRuleElement = getContainer().getNextElement(newDirection, this); + if (nextRuleElement != null) { + result = nextRuleElement.continueMatch(newDirection, annotation, ruleMatch, ruleApply, + sideStepContainerMatch, null, null, stream, crowd); + } else if (getContainer() instanceof ComposedRuleElement) { + ComposedRuleElement composed = (ComposedRuleElement) getContainer(); + result = composed.fallbackContinue(newDirection, false, annotation, ruleMatch, ruleApply, + sideStepContainerMatch, null, entryPoint, stream, crowd); + } + } + } + return result; + } + protected void doneMatching(RuleMatch ruleMatch, RuleApply ruleApply, RutaStream stream, InferenceCrowd crowd) { if (!ruleMatch.isApplied()) { 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=1869414&r1=1869413&r2=1869414&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 Tue Nov 5 15:59:38 2019 @@ -104,14 +104,9 @@ 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); + RuleElement sideStepOrigin = hasAncestor(false) ? this : null; - if (anchoringRuleElement instanceof RutaRuleElement && hasAncestor(false)) { - sideStepOrigin = (RutaRuleElement) anchoringRuleElement; - } List<RuleMatch> fallbackContinue = fallbackContinue(true, failed, lastAnnotation, eachRuleMatch, ruleApply, eachComposedMatch, sideStepOrigin, entryPoint, stream, crowd); @@ -121,11 +116,7 @@ public class ComposedRuleElement extends // conjunctive Map<RuleMatch, ComposedRuleElementMatch> ruleMatches = new LinkedHashMap<RuleMatch, ComposedRuleElementMatch>(); RuleElement anchoringRuleElement = getAnchoringRuleElement(stream); - RutaRuleElement sideStepOrigin = null; - if (anchoringRuleElement instanceof RutaRuleElement && hasAncestor(false)) { - sideStepOrigin = (RutaRuleElement) anchoringRuleElement; - } ComposedRuleElementMatch composedMatch = createComposedMatch(ruleMatch, containerMatch, stream); List<RuleMatch> startRuleMatches = anchoringRuleElement.startMatch(ruleMatch, null, @@ -162,6 +153,9 @@ public class ComposedRuleElement extends List<AnnotationFS> textsMatched = eachComposedMatch.getTextsMatched(); if ((!stream.isGreedyAnchoring() && !stream.isOnlyOnce()) || !earlyExit(textsMatched.get(0), ruleApply, stream)) { + + RuleElement sideStepOrigin = hasAncestor(false) ? this : null; + List<RuleMatch> fallbackContinue = fallbackContinue(true, failed, lastAnnotation, eachRuleMatch, ruleApply, eachComposedMatch, sideStepOrigin, entryPoint, stream, crowd); @@ -172,25 +166,6 @@ 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); @@ -211,9 +186,8 @@ public class ComposedRuleElement extends @Override public List<RuleMatch> continueMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, - RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, - InferenceCrowd crowd) { + RuleApply ruleApply, ComposedRuleElementMatch containerMatch, RuleElement sideStepOrigin, + RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); if (conjunct == null) { // inner next sequential @@ -389,7 +363,7 @@ public class ComposedRuleElement extends @Override public List<RuleMatch> continueOwnMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, + RuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); if (!stream.isSimpleGreedyForComposed()) { @@ -439,7 +413,7 @@ public class ComposedRuleElement extends public List<RuleMatch> fallbackContinue(boolean after, boolean failed, AnnotationFS annotation, RuleMatch ruleMatch, RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, + RuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); RuleElementContainer container = getContainer(); @@ -539,7 +513,7 @@ public class ComposedRuleElement extends private List<RuleMatch> fallback(boolean after, boolean failed, AnnotationFS annotation, RuleMatch ruleMatch, RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, + RuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); RuleElementContainer parentContainer = getContainer(); Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ConjunctRulesRuleElement.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ConjunctRulesRuleElement.java?rev=1869414&r1=1869413&r2=1869414&view=diff ============================================================================== --- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ConjunctRulesRuleElement.java (original) +++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ConjunctRulesRuleElement.java Tue Nov 5 15:59:38 2019 @@ -82,16 +82,15 @@ public class ConjunctRulesRuleElement ex @Override public List<RuleMatch> continueMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, - RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, - InferenceCrowd crowd) { + RuleApply ruleApply, ComposedRuleElementMatch containerMatch, RuleElement sideStepOrigin, + RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { throw new UnsupportedOperationException(); } @Override public List<RuleMatch> continueOwnMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, + RuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { throw new UnsupportedOperationException(); } Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElement.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElement.java?rev=1869414&r1=1869413&r2=1869414&view=diff ============================================================================== --- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElement.java (original) +++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElement.java Tue Nov 5 15:59:38 2019 @@ -40,13 +40,15 @@ public interface RuleElement { InferenceCrowd crowd); List<RuleMatch> continueMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, - RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, - InferenceCrowd crowd); + RuleApply ruleApply, ComposedRuleElementMatch containerMatch, RuleElement sideStepOrigin, + RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd); List<RuleMatch> continueOwnMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, - RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, + RuleApply ruleApply, ComposedRuleElementMatch containerMatch, RuleElement sideStepOrigin, + RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd); + + List<RuleMatch> continueSideStep(boolean after, RuleMatch ruleMatch, RuleApply ruleApply, + ComposedRuleElementMatch containerMatch, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd); void doMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java?rev=1869414&r1=1869413&r2=1869414&view=diff ============================================================================== --- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java (original) +++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaRuleElement.java Tue Nov 5 15:59:38 2019 @@ -127,7 +127,7 @@ public class RutaRuleElement extends Abs @Override public List<RuleMatch> continueOwnMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, + RuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); MatchContext context = new MatchContext(this, ruleMatch, after); @@ -187,7 +187,7 @@ public class RutaRuleElement extends Abs protected List<RuleMatch> continueMatchSomewhereElse(boolean after, boolean failed, AnnotationFS eachAnchor, RuleMatch extendedMatch, RuleApply ruleApply, - ComposedRuleElementMatch extendedContainerMatch, RutaRuleElement sideStepOrigin, + ComposedRuleElementMatch extendedContainerMatch, RuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); RuleElement nextRuleElement = getContainer().getNextElement(after, this); @@ -204,9 +204,8 @@ public class RutaRuleElement extends Abs @Override public List<RuleMatch> continueMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, - RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, - InferenceCrowd crowd) { + RuleApply ruleApply, ComposedRuleElementMatch containerMatch, RuleElement sideStepOrigin, + RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); // if() for really lazy quantifiers MatchContext context = new MatchContext(this, ruleMatch, after); @@ -271,7 +270,7 @@ public class RutaRuleElement extends Abs protected List<RuleMatch> stepbackMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RutaStream stream, InferenceCrowd crowd, + RuleElement sideStepOrigin, RutaStream stream, InferenceCrowd crowd, RuleElement entryPoint) { List<RuleMatch> result = new ArrayList<RuleMatch>(); if (this.equals(entryPoint) && ruleApply == null) { @@ -324,51 +323,6 @@ public class RutaRuleElement extends Abs } } } - return result; - } - - public List<RuleMatch> continueSideStep(boolean after, RuleMatch ruleMatch, RuleApply ruleApply, - ComposedRuleElementMatch containerMatch, RuleElement entryPoint, RutaStream stream, - InferenceCrowd crowd) { - List<RuleMatch> result = new ArrayList<RuleMatch>(); - boolean newDirection = !after; - List<AnnotationFS> matchedAnnotationsOf = ruleMatch.getMatchedAnnotationsOfElement(this); - AnnotationFS annotation = null; - if (!matchedAnnotationsOf.isEmpty()) { - if (newDirection) { - annotation = matchedAnnotationsOf.get(matchedAnnotationsOf.size() - 1); - } else { - annotation = matchedAnnotationsOf.get(0); - } - ComposedRuleElementMatch sideStepContainerMatch = containerMatch; - if (!containerMatch.getRuleElement().equals(getContainer())) { - List<List<RuleElementMatch>> matchInfo = ruleMatch - .getMatchInfo((ComposedRuleElement) getContainer()); - if (newDirection) { - List<RuleElementMatch> list = matchInfo.get(matchInfo.size() - 1); - sideStepContainerMatch = (ComposedRuleElementMatch) list.get(list.size() - 1); - } else { - List<RuleElementMatch> list = matchInfo.get(0); - sideStepContainerMatch = (ComposedRuleElementMatch) list.get(0); - } - } - MatchContext context = new MatchContext(this, ruleMatch, newDirection); - if (quantifier.continueMatch(newDirection, context, annotation, sideStepContainerMatch, - stream, crowd)) { - continueMatch(newDirection, annotation, ruleMatch, ruleApply, sideStepContainerMatch, null, - entryPoint, stream, crowd); - } else { - RuleElement nextRuleElement = getContainer().getNextElement(newDirection, this); - if (nextRuleElement != null) { - result = nextRuleElement.continueMatch(newDirection, annotation, ruleMatch, ruleApply, - sideStepContainerMatch, null, null, stream, crowd); - } else if (getContainer() instanceof ComposedRuleElement) { - ComposedRuleElement composed = (ComposedRuleElement) getContainer(); - result = composed.fallbackContinue(newDirection, false, annotation, ruleMatch, ruleApply, - sideStepContainerMatch, null, entryPoint, stream, crowd); - } - } - } return result; } Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java?rev=1869414&r1=1869413&r2=1869414&view=diff ============================================================================== --- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java (original) +++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/WildCardRuleElement.java Tue Nov 5 15:59:38 2019 @@ -62,9 +62,8 @@ public class WildCardRuleElement extends @Override public List<RuleMatch> continueMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, - RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, - InferenceCrowd crowd) { + RuleApply ruleApply, ComposedRuleElementMatch containerMatch, RuleElement sideStepOrigin, + RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { Pair<RuleElement, Integer> next = getNextRuleElement(after, this); RuleElement nextElement = next.getLeft(); int nextDepth = next.getRight().intValue(); @@ -95,7 +94,7 @@ public class WildCardRuleElement extends private List<RuleMatch> tryWithNextRuleElement(RuleElement nextElement, boolean after, AnnotationFS annotation, RuleMatch ruleMatch, RuleApply ruleApply, - ComposedRuleElementMatch containerMatch, int nextDepth, RutaRuleElement sideStepOrigin, + ComposedRuleElementMatch containerMatch, int nextDepth, RuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); // what is the next stuff that should match? @@ -132,7 +131,7 @@ public class WildCardRuleElement extends private List<RuleMatch> tryWithNextComposed(boolean after, AnnotationFS annotation, ComposedRuleElement cre, RuleMatch ruleMatch, RuleApply ruleApply, - ComposedRuleElementMatch containerMatch, int nextDepth, RutaRuleElement sideStepOrigin, + ComposedRuleElementMatch containerMatch, int nextDepth, RuleElement sideStepOrigin, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); AnnotationFS nextOne = annotation; @@ -304,7 +303,7 @@ public class WildCardRuleElement extends private List<RuleMatch> tryWithNextAnnotationType(boolean after, AnnotationFS annotation, RuleElement nextElement, Type defaultType, RuleMatch ruleMatch, RuleApply ruleApply, - ComposedRuleElementMatch containerMatch, int nextDepth, RutaRuleElement sideStepOrigin, + ComposedRuleElementMatch containerMatch, int nextDepth, RuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); FSIterator<AnnotationFS> iterator = getIterator(after, annotation, nextElement, defaultType, @@ -402,7 +401,7 @@ public class WildCardRuleElement extends private AnnotationFS getNextAnchor(boolean after, AnnotationFS annotation, RuleElement nextElement, RuleMatch ruleMatch, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RutaStream stream, InferenceCrowd crowd) { + RuleElement sideStepOrigin, RutaStream stream, InferenceCrowd crowd) { AnnotationFS nextAnchor = null; Pair<RuleElement, Integer> nextNext = getNextRuleElement(after, nextElement); if (nextNext != null && nextNext.getLeft() != null) { @@ -580,7 +579,7 @@ public class WildCardRuleElement extends private List<RuleMatch> tryWithNextLiteral(boolean after, AnnotationFS annotation, RutaRuleElement nextElement, RuleMatch ruleMatch, RuleApply ruleApply, - ComposedRuleElementMatch containerMatch, int nextDepth, RutaRuleElement sideStepOrigin, + ComposedRuleElementMatch containerMatch, int nextDepth, RuleElement sideStepOrigin, RutaStream stream, InferenceCrowd crowd) { List<RuleMatch> result = new ArrayList<RuleMatch>(); RutaLiteralMatcher matcher = (RutaLiteralMatcher) nextElement.getMatcher(); @@ -761,7 +760,7 @@ public class WildCardRuleElement extends @Override public List<RuleMatch> continueOwnMatch(boolean after, AnnotationFS annotation, RuleMatch ruleMatch, RuleApply ruleApply, ComposedRuleElementMatch containerMatch, - RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, + RuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) { // won't happen return Collections.emptyList(); 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=1869414&r1=1869413&r2=1869414&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 Tue Nov 5 15:59:38 2019 @@ -36,19 +36,34 @@ public class SidestepInComposedTest { Ruta.apply(cas, script); RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "15"); - - cas.release(); } @Test public void testAnchorAtDisjunct() throws Exception { String document = "15. Mai 2005"; String script = "(NUM PERIOD @(SW | CW) NUM){-> T1};\n"; + script += "(NUM PERIOD (@((SW | CW))) NUM){-> T2};\n"; + + CAS cas = RutaTestUtils.getCAS(document); + Ruta.apply(cas, script); + + RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "15. Mai 2005"); + RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "15. Mai 2005"); + + } + + @Test + public void testAnchorAtConjunct() throws Exception { + String document = "15. Mai 2005"; + String script = "(NUM PERIOD @(W & CW) NUM){-> T1};\n"; + script += "(NUM PERIOD (@((CW & W))) NUM){-> T2};\n"; CAS cas = RutaTestUtils.getCAS(document); Ruta.apply(cas, script); RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "15. Mai 2005"); + RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "15. Mai 2005"); } + }