ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1637168 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal: ae/EventEventRelationAnnotator.java ae/EventTimeSelfRelationAnnotator.java eval/EvaluationOfEventTimeRelations.java
Date Thu, 06 Nov 2014 17:31:01 GMT
Author: clin
Date: Thu Nov  6 17:31:01 2014
New Revision: 1637168

URL: http://svn.apache.org/r1637168
Log:
Add UMLS filter for event-time relations.

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeSelfRelationAnnotator.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventTimeRelations.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java?rev=1637168&r1=1637167&r2=1637168&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java
Thu Nov  6 17:31:01 2014
@@ -203,6 +203,11 @@ public class EventEventRelationAnnotator
 								pairs.add(new IdentifiedAnnotationPair(event1, event2));
 							}
 						}
+						for(EventMention event1 : JCasUtil.selectCovered(jCas, EventMention.class, eventA)){
+							for(EventMention event2 : JCasUtil.selectCovered(jCas, EventMention.class, eventB)){
+								pairs.add(new IdentifiedAnnotationPair(event1, event2));
+							}
+						}
 					}
 					pairs.add(new IdentifiedAnnotationPair(eventA, eventB));
 				}

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeSelfRelationAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeSelfRelationAnnotator.java?rev=1637168&r1=1637167&r2=1637168&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeSelfRelationAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeSelfRelationAnnotator.java
Thu Nov  6 17:31:01 2014
@@ -161,23 +161,33 @@ public class EventTimeSelfRelationAnnota
 			Annotation sentence) {
 		Map<EventMention, Collection<EventMention>> coveringMap =
 				JCasUtil.indexCovering(jCas, EventMention.class, EventMention.class);
-		
+
 		List<IdentifiedAnnotationPair> pairs = Lists.newArrayList();
 		for (EventMention event : JCasUtil.selectCovered(jCas, EventMention.class, sentence)) {
-			// ignore subclasses like Procedure and Disease/Disorder
-			if(this.isTraining()){//if training mode, train on both gold event and nearby system events
-				
-				if (event.getClass().equals(EventMention.class)) {
+			boolean eventValid = false;
+			if (event.getClass().equals(EventMention.class)) {//event is a gold event
+				for( EventMention aEve : JCasUtil.selectCovered(jCas, EventMention.class, event)){
+					if(!aEve.getClass().equals(EventMention.class)){//this event cover a UMLS semantic type
+						eventValid = true;
+						break;
+					}
+				}
+			}
+
+			if(eventValid){
+				// ignore subclasses like Procedure and Disease/Disorder
+				if(this.isTraining()){//if training mode, train on both gold event and span-overlapping
system events
 					for (TimeMention time : JCasUtil.selectCovered(jCas, TimeMention.class, sentence)) {
 						Collection<EventMention> eventList = coveringMap.get(event);
 						for(EventMention covEvent : eventList){
 							pairs.add(new IdentifiedAnnotationPair(covEvent, time));
 						}
 						pairs.add(new IdentifiedAnnotationPair(event, time));
+						for(EventMention covedEvent : JCasUtil.selectCovered(jCas, EventMention.class, event)){//select
covered events
+							pairs.add(new IdentifiedAnnotationPair(covedEvent, time));
+						}
 					}
-				}
-			}else{//if testing mode, only test on system generated events
-				if (event.getClass().equals(EventMention.class)) {
+				}else{//if testing mode, only test on system generated events
 					for (TimeMention time : JCasUtil.selectCovered(jCas, TimeMention.class, sentence)) {
 						pairs.add(new IdentifiedAnnotationPair(event, time));
 					}

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventTimeRelations.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventTimeRelations.java?rev=1637168&r1=1637167&r2=1637168&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventTimeRelations.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventTimeRelations.java
Thu Nov  6 17:31:01 2014
@@ -364,6 +364,7 @@ EvaluationOfTemporalRelations_ImplBase{
 				AnalysisEngineFactory.createEngineDescription(RemoveEventEventRelations.class),
 				CAS.NAME_DEFAULT_SOFA,
 				GOLD_VIEW_NAME);
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveNonUMLSEtEvents.class));
 
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveRelations.class));
 		aggregateBuilder.add(this.baseline ? RecallBaselineEventTimeRelationAnnotator.createAnnotatorDescription(directory)
:
@@ -385,11 +386,11 @@ EvaluationOfTemporalRelations_ImplBase{
 					GOLD_VIEW_NAME,
 					CAS.NAME_DEFAULT_SOFA
 					);
-			outf =  new File("target/eval/thyme/SystemError_eventTime_recall_dev.txt");
+			outf =  new File("target/eval/thyme/SystemError_eventTime_recall_test.txt");
 		}else if (!recallModeEvaluation && this.useClosure){
-			outf =  new File("target/eval/thyme/SystemError_eventTime_precision_dev.txt");
+			outf =  new File("target/eval/thyme/SystemError_eventTime_precision_test.txt");
 		}else{
-			outf =  new File("target/eval/thyme/SystemError_eventTime_plain_dev.txt");
+			outf =  new File("target/eval/thyme/SystemError_eventTime_plain_test.txt");
 		}
 
 		PrintWriter outDrop =null;
@@ -468,6 +469,51 @@ EvaluationOfTemporalRelations_ImplBase{
 		outDrop.close();
 		return stats;
 	}
+	
+	public static class RemoveNonUMLSEtEvents extends org.apache.uima.fit.component.JCasAnnotator_ImplBase
{
+		public static final String PARAM_GOLD_VIEW = "GoldView";
+
+		@ConfigurationParameter(name = PARAM_GOLD_VIEW,mandatory=false)
+		private String goldViewName = CAS.NAME_DEFAULT_SOFA;
+
+		@Override
+		public void process(JCas jCas) throws AnalysisEngineProcessException {
+			JCas sysView;
+			JCas goldView;
+			try {
+				sysView = jCas.getView(CAS.NAME_DEFAULT_SOFA);
+				goldView = jCas.getView(PARAM_GOLD_VIEW);
+			} catch (CASException e) {
+				throw new AnalysisEngineProcessException(e);
+			}
+			for(TemporalTextRelation relation : Lists.newArrayList(JCasUtil.select(goldView, TemporalTextRelation.class))){
+				Annotation arg1 = relation.getArg1().getArgument();
+				Annotation arg2 = relation.getArg2().getArgument();
+				Annotation argEvent = null;
+				if(arg1 instanceof EventMention && arg2 instanceof TimeMention){
+					argEvent = arg1;
+				}else if(arg1 instanceof TimeMention && arg2 instanceof EventMention){
+					argEvent = arg2;
+				}else{
+					continue;
+				}
+				boolean eventValid = false;
+				for (EventMention event : JCasUtil.selectCovered(sysView, EventMention.class, argEvent)){
+					if(!event.getClass().equals(EventMention.class)){
+						eventValid = true;
+						break;
+					}
+				}
+				if(eventValid){
+					// these are the kind we keep.
+					continue;
+				}
+				arg1.removeFromIndexes();
+				arg2.removeFromIndexes();
+				relation.removeFromIndexes();
+			}
+		}   
+	}
 
 	/*
   private static String formatRelation(BinaryTextRelation relation) {



Mime
View raw message