ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chen...@apache.org
Subject svn commit: r1605170 - in /ctakes/trunk/ctakes-temporal: ./ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apach/ src/test/java/org/apach/ctakes/ src/test/java/org/apach/ctakes/temporal/ src/test/java/org/apach/ctakes/temporal/ae/
Date Tue, 24 Jun 2014 20:06:31 GMT
Author: chenpei
Date: Tue Jun 24 20:06:30 2014
New Revision: 1605170

URL: http://svn.apache.org/r1605170
Log:
CTAKES-82 
Adding some junit test cases to the temporal modules- 
Backwards TimeAnnotator
EventAnnotator
DocTimeRel
ContextualModality

Added:
    ctakes/trunk/ctakes-temporal/src/test/
    ctakes/trunk/ctakes-temporal/src/test/java/
    ctakes/trunk/ctakes-temporal/src/test/java/org/
    ctakes/trunk/ctakes-temporal/src/test/java/org/apach/
    ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/
    ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/
    ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/
    ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/BackwardsTimeAnnotatorTest.java
  (with props)
    ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/ContextualModalityAnnotatorTest.java
  (with props)
    ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java
  (with props)
    ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/EventAnnotatorTest.java
  (with props)
Modified:
    ctakes/trunk/ctakes-temporal/pom.xml

Modified: ctakes/trunk/ctakes-temporal/pom.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/pom.xml?rev=1605170&r1=1605169&r2=1605170&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/pom.xml (original)
+++ ctakes/trunk/ctakes-temporal/pom.xml Tue Jun 24 20:06:30 2014
@@ -83,11 +83,10 @@
       <groupId>org.apache.ctakes</groupId>
       <artifactId>ctakes-constituency-parser</artifactId>
     </dependency>
-		<dependency>
-			<groupId>net.sourceforge.ctakesresources</groupId>
-			<artifactId>ctakes-resources-umls2011ab</artifactId>
-			<version>3.1.1</version>
-		</dependency>
+    <dependency>
+      <groupId>org.apache.ctakes</groupId>
+      <artifactId>ctakes-clinical-pipeline</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.cleartk</groupId>
       <artifactId>cleartk-util</artifactId>

Added: ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/BackwardsTimeAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/BackwardsTimeAnnotatorTest.java?rev=1605170&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/BackwardsTimeAnnotatorTest.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/BackwardsTimeAnnotatorTest.java
Tue Jun 24 20:06:30 2014
@@ -0,0 +1,76 @@
+package org.apach.ctakes.temporal.ae;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.ctakes.assertion.medfacts.cleartk.PolarityCleartkAnalysisEngine;
+import org.apache.ctakes.clinicalpipeline.ClinicalPipelineFactory;
+import org.apache.ctakes.clinicalpipeline.ClinicalPipelineFactory.CopyNPChunksToLookupWindowAnnotations;
+import org.apache.ctakes.clinicalpipeline.ClinicalPipelineFactory.RemoveEnclosedLookupWindows;
+import org.apache.ctakes.dependency.parser.ae.ClearNLPDependencyParserAE;
+import org.apache.ctakes.dictionary.lookup.ae.UmlsDictionaryLookupAnnotator;
+import org.apache.ctakes.temporal.ae.BackwardsTimeAnnotator;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textsem.TimeMention;
+import org.apache.log4j.Logger;
+import org.apache.uima.UIMAException;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.cleartk.classifier.CleartkAnnotator;
+import org.cleartk.classifier.jar.GenericJarClassifierFactory;
+import org.junit.Test;
+import org.uimafit.factory.AggregateBuilder;
+import org.uimafit.factory.AnalysisEngineFactory;
+import org.uimafit.factory.JCasFactory;
+import org.uimafit.pipeline.SimplePipeline;
+import org.uimafit.util.JCasUtil;
+
+public class BackwardsTimeAnnotatorTest {
+
+	// LOG4J logger based on class name
+	private Logger LOGGER = Logger.getLogger(getClass().getName());
+	
+	@Test
+	public void testPipeline() throws UIMAException, IOException {
+		
+		String note = "The patient is a 55-year-old man referred by Dr. Good for recently diagnosed
colorectal cancer.  "
+				+ "The patient was well till 6 months ago, when he started having a little blood with
stool.";
+		JCas jcas = JCasFactory.createJCas();
+		jcas.setDocumentText(note);
+  
+		//Get the default pipeline with umls dictionary lookup
+	    AggregateBuilder builder = new AggregateBuilder();
+	    builder.add(ClinicalPipelineFactory.getTokenProcessingPipeline());
+	    builder.add(AnalysisEngineFactory.createPrimitiveDescription(CopyNPChunksToLookupWindowAnnotations.class));
+	    builder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveEnclosedLookupWindows.class));
+	    builder.add(UmlsDictionaryLookupAnnotator.createAnnotatorDescription());
+	    builder.add(ClearNLPDependencyParserAE.createAnnotatorDescription());
+		
+		//Add BackwardsTimeAnnotator
+	    builder.add(AnalysisEngineFactory.createPrimitiveDescription(
+	            BackwardsTimeAnnotator.class,
+	            CleartkAnnotator.PARAM_IS_TRAINING,
+	            false,
+	            GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
+	            "/org/apache/ctakes/temporal/ae/timeannotator/model.jar"));
+	    
+	    SimplePipeline.runPipeline(jcas, builder.createAggregateDescription());
+
+	    Collection<TimeMention> mentions = JCasUtil.select(jcas, TimeMention.class);
+
+	    ArrayList<String> temp = new ArrayList<>();
+	    for(IdentifiedAnnotation entity : mentions){
+	    	LOGGER.info("Entity: " + entity.getCoveredText());
+	    	temp.add(entity.getCoveredText());
+	    }
+	    assertEquals(2, temp.size());	    
+	    assertTrue(temp.contains("recently"));
+	    assertTrue(temp.contains("6 months ago"));
+	}
+
+}

Propchange: ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/BackwardsTimeAnnotatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/ContextualModalityAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/ContextualModalityAnnotatorTest.java?rev=1605170&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/ContextualModalityAnnotatorTest.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/ContextualModalityAnnotatorTest.java
Tue Jun 24 20:06:30 2014
@@ -0,0 +1,14 @@
+package org.apach.ctakes.temporal.ae;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ContextualModalityAnnotatorTest {
+
+	@Test
+	public void test() {
+		fail("Not yet implemented");
+	}
+
+}

Propchange: ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/ContextualModalityAnnotatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java?rev=1605170&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java
Tue Jun 24 20:06:30 2014
@@ -0,0 +1,14 @@
+package org.apach.ctakes.temporal.ae;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class DocTimeRelAnnotatorTest {
+
+	@Test
+	public void test() {
+		fail("Not yet implemented");
+	}
+
+}

Propchange: ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/EventAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/EventAnnotatorTest.java?rev=1605170&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/EventAnnotatorTest.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/EventAnnotatorTest.java
Tue Jun 24 20:06:30 2014
@@ -0,0 +1,77 @@
+package org.apach.ctakes.temporal.ae;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.ctakes.clinicalpipeline.ClinicalPipelineFactory;
+import org.apache.ctakes.clinicalpipeline.ClinicalPipelineFactory.CopyNPChunksToLookupWindowAnnotations;
+import org.apache.ctakes.clinicalpipeline.ClinicalPipelineFactory.RemoveEnclosedLookupWindows;
+import org.apache.ctakes.dependency.parser.ae.ClearNLPDependencyParserAE;
+import org.apache.ctakes.dictionary.lookup.ae.UmlsDictionaryLookupAnnotator;
+import org.apache.ctakes.temporal.ae.BackwardsTimeAnnotator;
+import org.apache.ctakes.temporal.ae.EventAnnotator;
+import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textsem.TimeMention;
+import org.apache.log4j.Logger;
+import org.apache.uima.UIMAException;
+import org.apache.uima.jcas.JCas;
+import org.cleartk.classifier.CleartkAnnotator;
+import org.cleartk.classifier.jar.GenericJarClassifierFactory;
+import org.junit.Test;
+import org.uimafit.factory.AggregateBuilder;
+import org.uimafit.factory.AnalysisEngineFactory;
+import org.uimafit.factory.JCasFactory;
+import org.uimafit.pipeline.SimplePipeline;
+import org.uimafit.util.JCasUtil;
+
+public class EventAnnotatorTest {
+
+	// LOG4J logger based on class name
+	private Logger LOGGER = Logger.getLogger(getClass().getName());
+	
+	@Test
+	public void testPipeline() throws UIMAException, IOException {
+		
+		String note = "The patient is a 55-year-old man referred by Dr. Good for recently diagnosed
colorectal cancer.  "
+				+ "The patient was well till 6 months ago, when he started having a little blood with
stool.";
+		JCas jcas = JCasFactory.createJCas();
+		jcas.setDocumentText(note);
+  
+		//Get the default pipeline with umls dictionary lookup
+	    AggregateBuilder builder = new AggregateBuilder();
+	    builder.add(ClinicalPipelineFactory.getTokenProcessingPipeline());
+	    builder.add(AnalysisEngineFactory.createPrimitiveDescription(CopyNPChunksToLookupWindowAnnotations.class));
+	    builder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveEnclosedLookupWindows.class));
+	    builder.add(UmlsDictionaryLookupAnnotator.createAnnotatorDescription());
+	    builder.add(ClearNLPDependencyParserAE.createAnnotatorDescription());
+		
+		//Add EventAnnotator
+	    builder.add(AnalysisEngineFactory.createPrimitiveDescription(
+	    		EventAnnotator.class,
+	            CleartkAnnotator.PARAM_IS_TRAINING,
+	            false,
+	            GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
+	            "/org/apache/ctakes/temporal/ae/eventannotator/model.jar"));
+	    
+	    SimplePipeline.runPipeline(jcas, builder.createAggregateDescription());
+
+	    Collection<EventMention> mentions = JCasUtil.select(jcas, EventMention.class);
+
+	    ArrayList<String> temp = new ArrayList<>();
+	    for(IdentifiedAnnotation entity : mentions){
+	    	LOGGER.info("Entity: " + entity.getCoveredText());
+	    	temp.add(entity.getCoveredText());
+	    }
+	   	assertEquals(7, temp.size());	    
+	    assertTrue(temp.contains("old"));
+	    assertTrue(temp.contains("referred"));	    
+	    assertTrue(temp.contains("cancer"));
+	    assertTrue(temp.contains("till"));
+	    assertTrue(temp.contains("blood"));
+	    assertTrue(temp.contains("stool"));
+	}
+}

Propchange: ctakes/trunk/ctakes-temporal/src/test/java/org/apach/ctakes/temporal/ae/EventAnnotatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message