You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2012/01/12 13:04:48 UTC

svn commit: r1230503 - in /uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule: ComposedRuleElementMatch.java RuleMatch.java TextMarkerRuleElement.java

Author: pkluegl
Date: Thu Jan 12 12:04:47 2012
New Revision: 1230503

URL: http://svn.apache.org/viewvc?rev=1230503&view=rev
Log:
UIMA-2233
restricted creation of alternative "matching realities" to situations where parallel realities are needed, e.g., multiple anchors for rule elements.

Modified:
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/ComposedRuleElementMatch.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleMatch.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/ComposedRuleElementMatch.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/ComposedRuleElementMatch.java?rev=1230503&r1=1230502&r2=1230503&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/ComposedRuleElementMatch.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/ComposedRuleElementMatch.java Thu Jan 12 12:04:47 2012
@@ -168,6 +168,29 @@ public class ComposedRuleElementMatch ex
     return copy;
   }
 
+  public void update(ComposedRuleElementMatch extendedContainerMatch) {
+    for (Entry<RuleElement, List<RuleElementMatch>> entry : innerMatches.entrySet()) {
+      RuleElement key = entry.getKey();
+      List<RuleElementMatch> value = entry.getValue();
+      if (key.equals(extendedContainerMatch.getRuleElement())) {
+        extendedContainerMatch.setContainerMatch(this);
+        if (value != null) {
+          value.set(value.size() - 1, extendedContainerMatch);
+        }
+      } else {
+        if (value != null) {
+          for (RuleElementMatch each : value) {
+            if (each instanceof ComposedRuleElementMatch) {
+              ((ComposedRuleElementMatch)each).update(extendedContainerMatch);
+            }
+          }
+        } 
+      }
+    }
+  }
+
+  
+  
   public String toString() {
     return "CREM" + innerMatches.toString();
   }
@@ -194,4 +217,5 @@ public class ComposedRuleElementMatch ex
 
   }
 
+ 
 }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleMatch.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleMatch.java?rev=1230503&r1=1230502&r2=1230503&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleMatch.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleMatch.java Thu Jan 12 12:04:47 2012
@@ -206,6 +206,14 @@ public class RuleMatch {
     copy.setDelegateApply(newDelegateApply);
     return copy;
   }
+  
+  public void update(ComposedRuleElementMatch extendedContainerMatch) {
+    if (extendedContainerMatch.getContainerMatch() == null) {
+      setRootMatch(extendedContainerMatch);
+    } else {
+      rootMatch.update(extendedContainerMatch);
+    }
+  }
 
   public void setDelegateApply(Map<AbstractTextMarkerAction, ScriptApply> delegateApply) {
     this.delegateApply = delegateApply;

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java?rev=1230503&r1=1230502&r2=1230503&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java Thu Jan 12 12:04:47 2012
@@ -56,13 +56,15 @@ public class TextMarkerRuleElement exten
           InferenceCrowd crowd) {
     Collection<AnnotationFS> anchors = getAnchors(stream);
 
-    boolean useAlternatives = entryPoint == null; // anchors.size() > 1;
+    boolean useAlternatives = entryPoint == null && !(anchors.size() == 1);
     for (AnnotationFS eachAnchor : anchors) {
       ComposedRuleElementMatch extendedContainerMatch = containerMatch;
       RuleMatch extendedMatch = ruleMatch;
       if (useAlternatives) {
         extendedContainerMatch = containerMatch.copy();
         extendedMatch = ruleMatch.copy(extendedContainerMatch);
+      } else {
+        extendedMatch.update(extendedContainerMatch);
       }
       doMatch(eachAnchor, extendedMatch, extendedContainerMatch, true, stream, crowd);
       if (extendedMatch.matched()) {
@@ -121,13 +123,15 @@ public class TextMarkerRuleElement exten
         stepbackMatch(after, annotation, ruleMatch, ruleApply, containerMatch, sideStepOrigin,
                 stream, crowd, entryPoint);
       }
-      boolean useAlternatives = entryPoint == null; // nextAnnotations.size() > 1;
+      boolean useAlternatives = entryPoint == null && !(nextAnnotations.size() == 1);
       for (AnnotationFS eachAnchor : nextAnnotations) {
         ComposedRuleElementMatch extendedContainerMatch = containerMatch;
         RuleMatch extendedMatch = ruleMatch;
         if (useAlternatives) {
           extendedContainerMatch = containerMatch.copy();
           extendedMatch = ruleMatch.copy(extendedContainerMatch);
+        } else {
+          extendedMatch.update(extendedContainerMatch);
         }
 
         doMatch(eachAnchor, extendedMatch, extendedContainerMatch, false, stream, crowd);