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 2015/02/13 21:18:30 UTC

svn commit: r1659660 - in /uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta: RutaStream.java type/RutaBasic.java

Author: pkluegl
Date: Fri Feb 13 20:18:29 2015
New Revision: 1659660

URL: http://svn.apache.org/r1659660
Log:
UIMA-4239
- copy information, update "empty"

Modified:
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java?rev=1659660&r1=1659659&r2=1659660&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java Fri Feb 13 20:18:29 2015
@@ -154,7 +154,9 @@ public class RutaStream extends FSIterat
     AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex();
     final List<AnnotationFS> allAnnotations = new LinkedList<AnnotationFS>();
     for (AnnotationFS a : annotationIndex) {
-      allAnnotations.add(a);
+      if(a.getBegin() != a.getEnd()) {
+        allAnnotations.add(a);
+      }
     }
     if (basicIndex.size() == 0) {
       TreeSet<Integer> anchors = new TreeSet<Integer>();
@@ -298,15 +300,17 @@ public class RutaStream extends FSIterat
       int newEnd = toSplit.getEnd();
       cas.removeFsFromIndexes(toSplit);
       toSplit.setEnd(anchor);
-      RutaBasic newTMB = new RutaBasic(getJCas(), anchor, newEnd);
-      newTMB.setLowMemoryProfile(lowMemoryProfile);
+      RutaBasic newRB = new RutaBasic(getJCas(), anchor, newEnd);
+      newRB.setLowMemoryProfile(lowMemoryProfile);
+      newRB.setEndMap(toSplit.getEndMap());
+      toSplit.clearEndMap();
       cas.addFsToIndexes(toSplit);
-      cas.addFsToIndexes(newTMB);
+      cas.addFsToIndexes(newRB);
       beginAnchors.put(floor.getBegin(), floor);
-      beginAnchors.put(newTMB.getBegin(), newTMB);
+      beginAnchors.put(newRB.getBegin(), newRB);
       beginAnchors.put(ceiling.getBegin(), ceiling);
       endAnchors.put(floor.getEnd(), floor);
-      endAnchors.put(newTMB.getEnd(), newTMB);
+      endAnchors.put(newRB.getEnd(), newRB);
       endAnchors.put(ceiling.getEnd(), ceiling);
       return true;
     } else {
@@ -685,6 +689,13 @@ public class RutaStream extends FSIterat
     return beginAnchors.firstEntry().getValue();
   }
 
+  public RutaBasic getLastBasicOfAll() {
+    if (endAnchors.isEmpty()) {
+      return null;
+    }
+    return endAnchors.lastEntry().getValue();
+  }
+
   public Type getDocumentAnnotationType() {
     return documentAnnotationType;
   }

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java?rev=1659660&r1=1659659&r2=1659660&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/type/RutaBasic.java Fri Feb 13 20:18:29 2015
@@ -42,7 +42,7 @@ public class RutaBasic extends Annotatio
           .getLargestTypeCode()];
 
   private boolean empty = true;
-  
+
   public boolean isEmpty() {
     return empty;
   }
@@ -284,6 +284,33 @@ public class RutaBasic extends Annotatio
     return endMap;
   }
 
+  public void setBeginMap(Collection<?>[] beginMap) {
+    this.beginMap = beginMap;
+    for (Collection<?> each : beginMap) {
+      if (each != null && !each.isEmpty()) {
+        this.empty = false;
+      }
+    }
+  }
+
+  public void setEndMap(Collection<?>[] endMap) {
+    this.endMap = endMap;
+    for (Collection<?> each : endMap) {
+      if (each != null && !each.isEmpty()) {
+        this.empty = false;
+      }
+    }
+  }
+
+  public void clearBeginMap() {
+    this.beginMap = new ArrayList<?>[((TypeSystemImpl) getCAS().getTypeSystem())
+            .getLargestTypeCode()];
+  }
+
+  public void clearEndMap() {
+    this.endMap = new ArrayList<?>[((TypeSystemImpl) getCAS().getTypeSystem()).getLargestTypeCode()];
+  }
+
   /**
    * @generated
    * @ordered
@@ -368,7 +395,4 @@ public class RutaBasic extends Annotatio
     jcasType.ll_cas.ll_setStringValue(addr, ((RutaBasic_Type) jcasType).casFeatCode_replacement, v);
   }
 
-
-
-
 }