ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1590137 - in /ctakes/trunk/ctakes-core/src: main/java/org/apache/ctakes/core/ae/SentenceDetector.java test/java/org/apache/ctakes/core/ae/SentenceDetectorAnnotatorTest.java
Date Fri, 25 Apr 2014 20:51:10 GMT
Author: tmill
Date: Fri Apr 25 20:51:09 2014
New Revision: 1590137

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

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SentenceDetector.java
    ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SentenceDetectorAnnotatorTest.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SentenceDetector.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SentenceDetector.java?rev=1590137&r1=1590136&r2=1590137&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SentenceDetector.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SentenceDetector.java
Fri Apr 25 20:51:09 2014
@@ -48,12 +48,14 @@ import org.apache.ctakes.typesystem.type
 import org.apache.ctakes.typesystem.type.textspan.Sentence;
 import org.apache.log4j.Logger;
 import org.apache.uima.UimaContext;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.analysis_engine.annotator.AnnotatorProcessException;
 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;
 import org.uimafit.util.JCasUtil;
 
 /**
@@ -247,6 +249,12 @@ public class SentenceDetector extends JC
 		return sentenceCount;
 	}
 
+	public static AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException{
+	  return AnalysisEngineFactory.createPrimitiveDescription(SentenceDetector.class,
+	      SentenceDetector.PARAM_SD_MODEL_FILE,
+	      "org/apache/ctakes/core/sentdetect/sd-med-model.zip");
+	}
+	
 	/**
 	 * Train a new sentence detector from the training data in the first file
 	 * and write the model to the second file.<br>

Modified: ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SentenceDetectorAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SentenceDetectorAnnotatorTest.java?rev=1590137&r1=1590136&r2=1590137&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SentenceDetectorAnnotatorTest.java
(original)
+++ ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/ae/SentenceDetectorAnnotatorTest.java
Fri Apr 25 20:51:09 2014
@@ -9,6 +9,7 @@ import org.apache.ctakes.typesystem.type
 import org.apache.ctakes.typesystem.type.textspan.Sentence;
 import org.apache.uima.UIMAException;
 import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.junit.Test;
@@ -48,11 +49,25 @@ public class SentenceDetectorAnnotatorTe
     segs = JCasUtil.select(jcas, Segment.class);
     assertEquals(segs.size(), 1);
     
-    // test # sentences -- if it skips MEDS and Instructions it should be 3 from the physical
exam section only.
+    // test # sentences -- default should be 8.
+    sents = JCasUtil.select(jcas, Sentence.class);
+    assertEquals(sents.size(), 8);
+    
+    jcas = JCasFactory.createJCas();
+    jcas.setDocumentText(note);
+    SimplePipeline.runPipeline(jcas, getUimaFitPipeline());
+    // test # sentences -- default should be 8.
     sents = JCasUtil.select(jcas, Sentence.class);
     assertEquals(sents.size(), 8);
   }
   
+  private static AnalysisEngineDescription getUimaFitPipeline() throws ResourceInitializationException
{
+    AggregateBuilder builder = new AggregateBuilder();
+    builder.add(SimpleSegmentAnnotator.createAnnotatorDescription());
+    builder.add(SentenceDetector.createAnnotatorDescription());
+    return builder.createAggregateDescription();
+  }
+
   private static AnalysisEngine getSegmentingPipeline() throws ResourceInitializationException{
     AggregateBuilder aggregateBuilder = new AggregateBuilder();
 



Mime
View raw message