Author: pkluegl
Date: Fri Jul 27 12:28:37 2012
New Revision: 1366364

URL: http://svn.apache.org/viewvc?rev=1366364&view=rev
Log:
no jira
- fixed imports in TextMarkerStream
- improved output generation in AnnoationWriter
- added test on null in TextMarkerTypeMatcher

Modified:
    
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
    
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/engine/AnnotationWriter.java
    
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/rule/TextMarkerTypeMatcher.java

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java?rev=1366364&r1=1366363&r2=1366364&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
 Fri Jul 27 12:28:37 2012
@@ -37,7 +37,6 @@ import org.apache.uima.cas.FSIterator;
 import org.apache.uima.cas.FSMatchConstraint;
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.Type;
-import org.apache.uima.cas.TypeSystem;
 import org.apache.uima.cas.impl.FSIteratorImplBase;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.cas.text.AnnotationIndex;
@@ -49,7 +48,6 @@ import org.apache.uima.textmarker.rule.R
 import org.apache.uima.textmarker.type.TextMarkerAnnotation;
 import org.apache.uima.textmarker.type.TextMarkerBasic;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
-import org.hamcrest.CoreMatchers;
 
 public class TextMarkerStream extends FSIteratorImplBase<AnnotationFS> {
 

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/engine/AnnotationWriter.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/engine/AnnotationWriter.java?rev=1366364&r1=1366363&r2=1366364&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/engine/AnnotationWriter.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/engine/AnnotationWriter.java
 Fri Jul 27 12:28:37 2012
@@ -67,16 +67,14 @@ public class AnnotationWriter extends JC
     Type targetType = cas.getTypeSystem().getType(type);
     FSIterator<AnnotationFS> iterator = 
cas.getAnnotationIndex(targetType).iterator();
 
-    String newDocument = "";
+    StringBuilder newDocument = new StringBuilder();
     while (iterator.isValid()) {
       AnnotationFS fs = iterator.get();
-      newDocument += fs.getCoveredText() + "\n\n";
+      newDocument.append(fs.getCoveredText());
+      newDocument.append("\n");
       iterator.moveToNext();
     }
-    newDocument = newDocument.trim();
-    if ("".equals(newDocument)) {
-      newDocument = cas.getDocumentText();
-    }
+
 
     Type sdiType = 
cas.getTypeSystem().getType(TextMarkerEngine.SOURCE_DOCUMENT_INFORMATION);
 
@@ -98,7 +96,7 @@ public class AnnotationWriter extends JC
 
     }
     try {
-      FileUtils.saveString2File(newDocument, file, encoding);
+      FileUtils.saveString2File(newDocument.toString(), file, encoding);
     } catch (IOException e) {
       throw new AnalysisEngineProcessException(e);
     }

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/rule/TextMarkerTypeMatcher.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/rule/TextMarkerTypeMatcher.java?rev=1366364&r1=1366363&r2=1366364&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/rule/TextMarkerTypeMatcher.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/rule/TextMarkerTypeMatcher.java
 Fri Jul 27 12:28:37 2012
@@ -85,6 +85,9 @@ public class TextMarkerTypeMatcher imple
   public Collection<AnnotationFS> getAnnotationsAfter(TextMarkerRuleElement 
ruleElement,
           AnnotationFS annotation, TextMarkerStream stream, TextMarkerBlock 
parent) {
     TextMarkerBasic lastBasic = stream.getEndAnchor(annotation.getEnd());
+    if(lastBasic== null) {
+      return Collections.emptyList();
+    }
     stream.moveTo(lastBasic);
     stream.moveToNext();
     if (stream.isValid()) {
@@ -110,6 +113,9 @@ public class TextMarkerTypeMatcher imple
   public Collection<AnnotationFS> getAnnotationsBefore(TextMarkerRuleElement 
ruleElement,
           AnnotationFS annotation, TextMarkerStream stream, TextMarkerBlock 
parent) {
     TextMarkerBasic firstBasic = stream.getBeginAnchor(annotation.getBegin());
+    if(firstBasic== null) {
+      return Collections.emptyList();
+    }
     stream.moveTo(firstBasic);
     stream.moveToPrevious();
     if (stream.isValid()) {


Reply via email to