Author: pkluegl
Date: Wed Feb 13 17:07:00 2013
New Revision: 1445741

URL: http://svn.apache.org/r1445741
Log:
UIMA-2660
- if there are no more annotations for a greedy match, then step back and 
evaluate the matches before continuing the match
- extended tests to cover problem

Modified:
    
uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java
    
uima/sandbox/textmarker/trunk/textmarker-core/src/test/java/org/apache/uima/textmarker/QuantifierTest3.java
    
uima/sandbox/textmarker/trunk/textmarker-core/src/test/resources/org/apache/uima/textmarker/QuantifierTest3.tm

Modified: 
uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java?rev=1445741&r1=1445740&r2=1445741&view=diff
==============================================================================
--- 
uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java
 (original)
+++ 
uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java
 Wed Feb 13 17:07:00 2013
@@ -129,7 +129,12 @@ public class TextMarkerRuleElement exten
           break;
         }
         Collection<AnnotationFS> nextAnnotations = getNextAnnotations(after, 
eachAnchor, stream);
-        if (nextAnnotations.size() == 1) {
+        if(nextAnnotations.size() == 0) {
+          stopMatching = true;
+          stepbackMatch(after, eachAnchor, extendedMatch, ruleApply, 
extendedContainerMatch,
+                  sideStepOrigin, stream, crowd, entryPoint);
+        } else 
+          if (nextAnnotations.size() == 1) {
           lastAnchor = eachAnchor;
           eachAnchor = nextAnnotations.iterator().next();
           doMatch(eachAnchor, extendedMatch, extendedContainerMatch, false, 
stream, crowd);

Modified: 
uima/sandbox/textmarker/trunk/textmarker-core/src/test/java/org/apache/uima/textmarker/QuantifierTest3.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-core/src/test/java/org/apache/uima/textmarker/QuantifierTest3.java?rev=1445741&r1=1445740&r2=1445741&view=diff
==============================================================================
--- 
uima/sandbox/textmarker/trunk/textmarker-core/src/test/java/org/apache/uima/textmarker/QuantifierTest3.java
 (original)
+++ 
uima/sandbox/textmarker/trunk/textmarker-core/src/test/java/org/apache/uima/textmarker/QuantifierTest3.java
 Wed Feb 13 17:07:00 2013
@@ -61,6 +61,16 @@ public class QuantifierTest3 {
     ai = cas.getAnnotationIndex(t);
     assertEquals(0, ai.size());
 
+    t = TextMarkerTestUtils.getTestType(cas, 4);
+    ai = cas.getAnnotationIndex(t);
+    assertEquals(1, ai.size());
+    iterator = ai.iterator();
+    assertEquals("Big Big Big", iterator.next().getCoveredText());
+    
+    t = TextMarkerTestUtils.getTestType(cas, 5);
+    ai = cas.getAnnotationIndex(t);
+    assertEquals(0, ai.size());
+    
     cas.release();
   }
 }

Modified: 
uima/sandbox/textmarker/trunk/textmarker-core/src/test/resources/org/apache/uima/textmarker/QuantifierTest3.tm
URL: 
http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-core/src/test/resources/org/apache/uima/textmarker/QuantifierTest3.tm?rev=1445741&r1=1445740&r2=1445741&view=diff
==============================================================================
--- 
uima/sandbox/textmarker/trunk/textmarker-core/src/test/resources/org/apache/uima/textmarker/QuantifierTest3.tm
 (original)
+++ 
uima/sandbox/textmarker/trunk/textmarker-core/src/test/resources/org/apache/uima/textmarker/QuantifierTest3.tm
 Wed Feb 13 17:07:00 2013
@@ -5,5 +5,7 @@ DECLARE T1, T2, T3, T4, T5, T6, T7, T8, 
 SW CW[2,100]?{-> MARK(T1)} SW;
 SW W[2,100]?{-> MARK(T2)} SW;
 SW W[4,5]?{-> MARK(T3)} SW;
+CW[3]{-> MARK(T4)};
+CW[4]{-> MARK(T5)};
 
 


Reply via email to