ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevenbeth...@apache.org
Subject svn commit: r1511845 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal: ae/ClearTKDocTimeRelAnnotator.java ae/EventToClearTKEventAnnotator.java eval/EvaluationOfClearTKEventProperties.java
Date Thu, 08 Aug 2013 16:01:45 GMT
Author: stevenbethard
Date: Thu Aug  8 16:01:44 2013
New Revision: 1511845

URL: http://svn.apache.org/r1511845
Log:
Fixes some bugs in the evaluation of ClearTK docTimeRels.

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/ClearTKDocTimeRelAnnotator.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventToClearTKEventAnnotator.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfClearTKEventProperties.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/ClearTKDocTimeRelAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/ClearTKDocTimeRelAnnotator.java?rev=1511845&r1=1511844&r2=1511845&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/ClearTKDocTimeRelAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/ClearTKDocTimeRelAnnotator.java
Thu Aug  8 16:01:44 2013
@@ -1,23 +1,26 @@
 package org.apache.ctakes.temporal.ae;
 
-import org.apache.ctakes.typesystem.type.refsem.Event;
-import org.apache.ctakes.typesystem.type.refsem.EventProperties;
+import java.util.Map;
+
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.jcas.JCas;
-import org.apache.uima.jcas.cas.FSArray;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.cleartk.timeml.type.Anchor;
+import org.cleartk.timeml.type.DocumentCreationTime;
 import org.cleartk.timeml.type.TemporalLink;
 import org.uimafit.component.JCasAnnotator_ImplBase;
 import org.uimafit.factory.AnalysisEngineFactory;
 import org.uimafit.util.JCasUtil;
 
+import com.google.common.collect.Maps;
+
 /**
  * for every cTAKES EventMention annotation, create a ClearTK Event Annotation
+ * 
  * @author Chen Lin
- *
+ * 
  */
 public class ClearTKDocTimeRelAnnotator extends JCasAnnotator_ImplBase {
 
@@ -26,40 +29,35 @@ public class ClearTKDocTimeRelAnnotator 
 	}
 
 	@Override
-	public void process(JCas jCas)
-			throws AnalysisEngineProcessException {
+	public void process(JCas jCas) throws AnalysisEngineProcessException {
+		DocumentCreationTime dct = JCasUtil.selectSingle(jCas, DocumentCreationTime.class);
+		Map<EventMention, String> docTimeRels = Maps.newHashMap();
 		for (TemporalLink tlink : JCasUtil.select(jCas, TemporalLink.class)) {
-			// create a cleartk event object
-			String relation = tlink.getRelationType();
-//			System.out.println("__find tlink relation: " + relation + "		srouce: " + tlink.getSource().getCoveredText()
+ "  target: " + tlink.getTarget().getType().getName());
-			
-			Anchor linksource = tlink.getSource();
-			
-			EventMention ement = new EventMention(jCas);
-			ement.setBegin(linksource.getBegin());
-			ement.setEnd(linksource.getEnd());
-			Event event = new Event(jCas);
-			
-			EventProperties eventProperties = new EventProperties(jCas);
-			if ("INCLUDES".equals(relation)){
-  		    	eventProperties.setDocTimeRel("OVERLAP");
-  		    }else{
-  		    	eventProperties.setDocTimeRel(relation);
-  		    }
-  		    event.setProperties(eventProperties);
-  		    event.setMentions(new FSArray(jCas, 1));
-  		    event.setMentions(0, ement);
-		    ement.setEvent(event);
-		    
-		    eventProperties.addToIndexes();
-  		  	event.addToIndexes();
-  		  	ement.addToIndexes();
-		    
+			Anchor source = tlink.getSource();
+			Anchor target = tlink.getTarget();
+			if (source instanceof org.cleartk.timeml.type.Event && target.equals(dct)) {
+				for (EventMention event : JCasUtil.selectCovered(jCas, EventMention.class, source)) {
+					docTimeRels.put(event, tlink.getRelationType());
+				}
+			}
 		}
 
+		for (EventMention eventMention : JCasUtil.select(jCas, EventMention.class)) {
+			// needed because SignSymptomMention, etc. do not have EventProperties
+			if (eventMention.getClass().equals(EventMention.class)) {
+				String docTimeRel = docTimeRels.get(eventMention);
+				
+				// convert missing or INCLUDES to OVERLAP
+				if (docTimeRel == null || "INCLUDES".equals(docTimeRel)) {
+					docTimeRel = "OVERLAP";
+				}
+				eventMention.getEvent().getProperties().setDocTimeRel(docTimeRel);
+			}
+		}
 	}
 
-	public static AnalysisEngineDescription getAnnotatorDescription() throws ResourceInitializationException
{
+	public static AnalysisEngineDescription getAnnotatorDescription()
+			throws ResourceInitializationException {
 		return AnalysisEngineFactory.createPrimitiveDescription(ClearTKDocTimeRelAnnotator.class);
 	}
 

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventToClearTKEventAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventToClearTKEventAnnotator.java?rev=1511845&r1=1511844&r2=1511845&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventToClearTKEventAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventToClearTKEventAnnotator.java
Thu Aug  8 16:01:44 2013
@@ -12,8 +12,9 @@ import org.uimafit.util.JCasUtil;
 
 /**
  * for every cTAKES EventMention annotation, create a ClearTK Event Annotation
+ * 
  * @author Chen Lin
- *
+ * 
  */
 public class EventToClearTKEventAnnotator extends JCasAnnotator_ImplBase {
 
@@ -22,20 +23,23 @@ public class EventToClearTKEventAnnotato
 	}
 
 	@Override
-	public void process(JCas jCas)
-			throws AnalysisEngineProcessException {
+	public void process(JCas jCas) throws AnalysisEngineProcessException {
 		for (EventMention eMention : JCasUtil.select(jCas, EventMention.class)) {
-			// create a cleartk event object
-			Event event = new Event(jCas);
-			event.setBegin(eMention.getBegin());
-			event.setEnd(eMention.getEnd());
-			
-			event.addToIndexes();
+			// needed because SignSymptomMention, etc. do not have EventProperties
+			if (eMention.getClass().equals(EventMention.class)) {
+				// create a cleartk event object
+				Event event = new Event(jCas);
+				event.setBegin(eMention.getBegin());
+				event.setEnd(eMention.getEnd());
+
+				event.addToIndexes();
+			}
 		}
 
 	}
 
-	public static AnalysisEngineDescription getAnnotatorDescription() throws ResourceInitializationException
{
+	public static AnalysisEngineDescription getAnnotatorDescription()
+			throws ResourceInitializationException {
 		return AnalysisEngineFactory.createPrimitiveDescription(EventToClearTKEventAnnotator.class);
 	}
 

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfClearTKEventProperties.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfClearTKEventProperties.java?rev=1511845&r1=1511844&r2=1511845&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfClearTKEventProperties.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfClearTKEventProperties.java
Thu Aug  8 16:01:44 2013
@@ -35,6 +35,7 @@ import org.apache.ctakes.temporal.ae.Cle
 import org.apache.ctakes.temporal.ae.ClearTKDocTimeRelAnnotator;
 import org.apache.ctakes.typesystem.type.refsem.EventProperties;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textsem.TimeMention;
 import org.apache.ctakes.typesystem.type.textspan.Segment;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.cas.CAS;
@@ -119,14 +120,13 @@ public class EvaluationOfClearTKEventPro
 		  CollectionReader collectionReader,
 		  File directory) throws Exception {
 	  AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
-//	  aggregateBuilder.add(UriToDocumentTextAnnotator.getDescription()); 
+	  aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class));
+	  aggregateBuilder.add(CopyFromGold.getDescription(TimeMention.class));
 	  aggregateBuilder.add(SentenceAnnotator.getDescription());
 	  aggregateBuilder.add(TokenAnnotator.getDescription());
 	  aggregateBuilder.add(PosTaggerAnnotator.getDescription());
 	  aggregateBuilder.add(DefaultSnowballStemmer.getDescription("English"));
 	  aggregateBuilder.add(ParserAnnotator.getDescription());
-//	  aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class));
-//	  aggregateBuilder.add(CopyFromGold.getDescription(TimeMention.class));
 	  aggregateBuilder.add(EventToClearTKEventAnnotator.getAnnotatorDescription());//for every
cTakes eventMention, create a cleartk event
 	  aggregateBuilder.add(ClearTKDocumentCreationTimeAnnotator.getAnnotatorDescription());//for
every jCAS create an empty DCT, and add it to index
 	  aggregateBuilder.add(EventTenseAnnotator.FACTORY.getAnnotatorDescription("/org/cleartk/timeml/event/eventtenseannotator/model.jar"));



Mime
View raw message