ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chen...@apache.org
Subject svn commit: r1608955 - /ctakes/trunk/ctakes-temporal/src/test/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java
Date Tue, 08 Jul 2014 21:14:21 GMT
Author: chenpei
Date: Tue Jul  8 21:14:21 2014
New Revision: 1608955

URL: http://svn.apache.org/r1608955
Log:
CTAKES-82 - temporal unit tests. add Event to EventMention link in order for properties such
as doctimerel to work properly.  Thanks Chen for the patch.
The sample test note should output:
08 Jul 2014 17:13:14  INFO DocTimeRelAnnotatorTest - Event: old DocTimeRel:OVERLAP
08 Jul 2014 17:13:14  INFO DocTimeRelAnnotatorTest - Event: referred DocTimeRel:BEFORE
08 Jul 2014 17:13:14  INFO DocTimeRelAnnotatorTest - Event: cancer DocTimeRel:OVERLAP
08 Jul 2014 17:13:14  INFO DocTimeRelAnnotatorTest - Event: till DocTimeRel:BEFORE
08 Jul 2014 17:13:14  INFO DocTimeRelAnnotatorTest - Event: blood DocTimeRel:OVERLAP
08 Jul 2014 17:13:14  INFO DocTimeRelAnnotatorTest - Event: stool DocTimeRel:OVERLAP

Modified:
    ctakes/trunk/ctakes-temporal/src/test/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java

Modified: ctakes/trunk/ctakes-temporal/src/test/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/test/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java?rev=1608955&r1=1608954&r2=1608955&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/test/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/test/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotatorTest.java
Tue Jul  8 21:14:21 2014
@@ -32,21 +32,27 @@ import org.apache.ctakes.temporal.ae.Bac
 import org.apache.ctakes.temporal.ae.ClearTKDocTimeRelAnnotator;
 import org.apache.ctakes.temporal.ae.DocTimeRelAnnotator;
 import org.apache.ctakes.temporal.ae.EventAnnotator;
+import org.apache.ctakes.typesystem.type.refsem.Event;
+import org.apache.ctakes.typesystem.type.refsem.EventProperties;
 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.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.jcas.JCas;
 import org.cleartk.classifier.CleartkAnnotator;
 import org.cleartk.classifier.jar.GenericJarClassifierFactory;
 import org.junit.Test;
+import org.uimafit.component.JCasAnnotator_ImplBase;
 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;
 
+import com.google.common.collect.Lists;
+
 public class DocTimeRelAnnotatorTest {
 
 	// LOG4J logger based on class name
@@ -79,6 +85,8 @@ public class DocTimeRelAnnotatorTest {
 		// Add EventAnnotator
 		builder.add(EventAnnotator
 				.createAnnotatorDescription("/org/apache/ctakes/temporal/ae/eventannotator/model.jar"));
+		//link event to eventMention
+		builder.add(AnalysisEngineFactory.createPrimitiveDescription(AddEvent.class));
 		// Add Document Time Relative Annotator
 		builder.add(DocTimeRelAnnotator
 				.createAnnotatorDescription("/org/apache/ctakes/temporal/ae/doctimerel/model.jar"));
@@ -106,4 +114,26 @@ public class DocTimeRelAnnotatorTest {
 		// assertTrue(temp.contains("6 months ago"));
 	}
 
+	public static class AddEvent extends JCasAnnotator_ImplBase {
+		@Override
+		public void process(JCas jCas) throws AnalysisEngineProcessException {
+			for (EventMention emention : Lists.newArrayList(JCasUtil.select(
+					jCas,
+					EventMention.class))) {
+				EventProperties eventProperties = new org.apache.ctakes.typesystem.type.refsem.EventProperties(jCas);
+
+				// create the event object
+				Event event = new Event(jCas);
+
+				// add the links between event, mention and properties
+				event.setProperties(eventProperties);
+				emention.setEvent(event);
+
+				// add the annotations to the indexes
+				eventProperties.addToIndexes();
+				event.addToIndexes();
+			}
+		}
+	}
+
 }



Mime
View raw message