ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1590130 - in /ctakes/trunk/ctakes-core/src: main/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotator.java test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java
Date Fri, 25 Apr 2014 20:25:39 GMT
Author: tmill
Date: Fri Apr 25 20:25:39 2014
New Revision: 1590130

URL: http://svn.apache.org/r1590130
Log:
CTAKES-297: Added methods for getting descriptors for SimpleSegmentAnnotator.

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotator.java
    ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotator.java?rev=1590130&r1=1590129&r2=1590130&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotator.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotator.java
Fri Apr 25 20:25:39 2014
@@ -20,10 +20,13 @@ package org.apache.ctakes.core.ae;
 
 import org.apache.ctakes.core.util.DocumentIDAnnotationUtil;
 import org.apache.ctakes.typesystem.type.textspan.Segment;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
 import org.uimafit.component.JCasAnnotator_ImplBase;
 import org.uimafit.descriptor.ConfigurationParameter;
+import org.uimafit.factory.AnalysisEngineFactory;
 
 /**
  * Creates a single segment annotation that spans the entire document. This is
@@ -60,4 +63,14 @@ public class SimpleSegmentAnnotator exte
 		segment.setId(segmentId);
 		segment.addToIndexes();
 	}
-}
\ No newline at end of file
+	
+	public static AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException{
+	  return AnalysisEngineFactory.createPrimitiveDescription(SimpleSegmentAnnotator.class);
+	}
+	
+	public static AnalysisEngineDescription createAnnotatorDescription(String segmentID) throws
ResourceInitializationException {
+    return AnalysisEngineFactory.createPrimitiveDescription(SimpleSegmentAnnotator.class,
+        SimpleSegmentAnnotator.PARAM_SEGMENT_ID,
+        segmentID);
+	}
+}

Modified: ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java?rev=1590130&r1=1590129&r2=1590130&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java
(original)
+++ ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SimpleSegmentAnnotatorTests.java
Fri Apr 25 20:25:39 2014
@@ -21,14 +21,19 @@ package org.apache.ctakes.core.ae;
 import static org.junit.Assert.assertEquals;
 
 import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
 
+import org.apache.ctakes.typesystem.type.textspan.Segment;
+import org.apache.ctakes.utils.test.TestUtil;
+import org.apache.uima.UIMAException;
 import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
-
-import org.apache.ctakes.typesystem.type.textspan.Segment;
-import org.apache.ctakes.utils.test.TestUtil;
+import org.uimafit.factory.JCasFactory;
+import org.uimafit.pipeline.SimplePipeline;
+import org.uimafit.util.JCasUtil;
 
 public class SimpleSegmentAnnotatorTests {
 
@@ -41,4 +46,24 @@ public class SimpleSegmentAnnotatorTests
 		assertEquals(42, segment.getEnd());
 		assertEquals("seg1234", segment.getId());
 	}
+	
+	@Test
+	public void testSimpleSegmentUimaFit() throws UIMAException, IOException {
+	  JCas jcas = JCasFactory.createJCas();
+	  String doc = "Patient suffers from a shattered tibia and facial contusions. Recommend
bed rest, aspirin, and ice.";
+	  jcas.setDocumentText(doc);
+	  SimplePipeline.runPipeline(jcas, SimpleSegmentAnnotator.createAnnotatorDescription());
+	  Collection<Segment> segs = JCasUtil.select(jcas, Segment.class);
+	  assertEquals(segs.size(), 1);
+	  Segment seg = segs.toArray(new Segment[]{})[0];
+	  assert(seg.getId().equals("SIMPLE_SEGMENT"));
+	  
+	  jcas = JCasFactory.createJCas();
+	  jcas.setDocumentText(doc);
+    SimplePipeline.runPipeline(jcas, SimpleSegmentAnnotator.createAnnotatorDescription("TestId"));
+    segs = JCasUtil.select(jcas, Segment.class);
+    assertEquals(segs.size(), 1);
+    seg = segs.toArray(new Segment[]{})[0];
+    assertEquals("Segment ids do not match!", seg.getId(), "TestId");  
+	}
 }



Mime
View raw message