ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1647845 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal: ae/ ae/feature/ eval/
Date Wed, 24 Dec 2014 21:19:14 GMT
Author: clin
Date: Wed Dec 24 21:19:14 2014
New Revision: 1647845

URL: http://svn.apache.org/r1647845
Log:
set the evaluation script for ablation test

Added:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EmptyFeaturesExtractor.java
  (with props)
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/EvaluationOfEventEventThymeRelations.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventTimeRelations.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.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=1647845&r1=1647844&r2=1647845&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
Wed Dec 24 21:19:14 2014
@@ -35,6 +35,8 @@ import org.apache.ctakes.temporal.ae.fea
 import org.apache.ctakes.temporal.ae.feature.DependencyPathFeaturesExtractor;
 import org.apache.ctakes.temporal.ae.feature.CoordinateFeaturesExtractor;
 import org.apache.ctakes.temporal.ae.feature.DependingVerbsFeatureExtractor;
+import org.apache.ctakes.temporal.ae.feature.EmptyFeaturesExtractor;
+import org.apache.ctakes.temporal.ae.feature.MultiTokenFeaturesExtractor;
 //import org.apache.ctakes.temporal.ae.feature.EventInBetweenPropertyExtractor;
 //import org.apache.ctakes.temporal.ae.feature.EventOutsidePropertyExtractor;
 import org.apache.ctakes.temporal.ae.feature.SpecialAnnotationRelationExtractor;
@@ -53,6 +55,7 @@ import org.apache.ctakes.temporal.ae.fea
 import org.apache.ctakes.temporal.ae.feature.SectionHeaderRelationExtractor;
 //import org.apache.ctakes.temporal.ae.feature.TemporalAttributeFeatureExtractor;
 import org.apache.ctakes.temporal.ae.feature.UmlsFeatureExtractor;
+import org.apache.ctakes.temporal.ae.feature.UnexpandedTokenFeaturesExtractor;
 //import org.apache.ctakes.temporal.ae.feature.UnexpandedTokenFeaturesExtractor;
 //import org.apache.ctakes.temporal.ae.feature.treekernel.TemporalPETExtractor;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
@@ -124,32 +127,34 @@ public class EventEventRelationAnnotator
 	@Override
 	protected List<RelationFeaturesExtractor> getFeatureExtractors() {
 		return Lists.newArrayList(
-				new TokenFeaturesExtractor()
-				//				new UnexpandedTokenFeaturesExtractor() //use unexpanded version for i2b2 data
+				new TokenFeaturesExtractor()								
 				, new PartOfSpeechFeaturesExtractor()
-				//	    		, new TemporalPETExtractor()
 				, new EventArgumentPropertyExtractor()
 				, new NumberOfEventTimeBetweenCandidatesExtractor()
-				, new SectionHeaderRelationExtractor()
 				, new NearbyVerbTenseRelationExtractor()
 				, new CheckSpecialWordRelationExtractor()
 				, new UmlsFeatureExtractor()
-				, new DependencyPathFeaturesExtractor()
+//				, new DependencyPathFeaturesExtractor()
 				, new CoordinateFeaturesExtractor()
 				, new OverlappedHeadFeaturesExtractor()
 				, new SRLRelationFeaturesExtractor()
 				, new NumberOfEventsInTheSameSentenceExtractor()
-				, new EventPositionRelationFeaturesExtractor() //not helpful
-				, new TimeXRelationFeaturesExtractor() //not helpful
 				, new ConjunctionRelationFeaturesExtractor()
-				, new DeterminerRelationFeaturesExtractor()
 				, new EventTimeRelationFeatureExtractor()
-				, new TokenPropertyFeaturesExtractor()
-				, new DependingVerbsFeatureExtractor()
-				, new SpecialAnnotationRelationExtractor() //not helpful
-				, new TemporalPETFlatExtractor()
-				//				, new EventInBetweenPropertyExtractor()
-				//				, new EventOutsidePropertyExtractor()
+
+//				new MultiTokenFeaturesExtractor()
+//				new UnexpandedTokenFeaturesExtractor() //use unexpanded version for i2b2 data
+//				, new EmptyFeaturesExtractor()
+
+//				, new SectionHeaderRelationExtractor()
+//				, new EventPositionRelationFeaturesExtractor() //not helpful
+//				, new TimeXRelationFeaturesExtractor() //not helpful
+//				, new DeterminerRelationFeaturesExtractor()
+//				, new TokenPropertyFeaturesExtractor()
+//				, new DependingVerbsFeatureExtractor()
+//				, new SpecialAnnotationRelationExtractor() //not helpful
+//				, new TemporalPETFlatExtractor()
+
 				);
 	}
 
@@ -208,16 +213,16 @@ public class EventEventRelationAnnotator
 						for(EventMention event2 : coveringMap.get(eventB)){
 							pairs.add(new IdentifiedAnnotationPair(eventA, event2));
 						}
-						//pairing covered system events:
-						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(event1, eventB));
-						}
-						for(EventMention event2 : JCasUtil.selectCovered(jCas, EventMention.class, eventB)){
-							pairs.add(new IdentifiedAnnotationPair(eventA, event2));
-						}
+//						//pairing covered system events:
+//						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(event1, eventB));
+//						}
+//						for(EventMention event2 : JCasUtil.selectCovered(jCas, EventMention.class, eventB)){
+//							pairs.add(new IdentifiedAnnotationPair(eventA, 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=1647845&r1=1647844&r2=1647845&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
Wed Dec 24 21:19:14 2014
@@ -32,7 +32,9 @@ import org.apache.ctakes.temporal.ae.fea
 import org.apache.ctakes.temporal.ae.feature.ConjunctionRelationFeaturesExtractor;
 import org.apache.ctakes.temporal.ae.feature.DependencyFeatureExtractor;
 import org.apache.ctakes.temporal.ae.feature.DependencyPathFeaturesExtractor;
+import org.apache.ctakes.temporal.ae.feature.EmptyFeaturesExtractor;
 import org.apache.ctakes.temporal.ae.feature.EventArgumentPropertyExtractor;
+import org.apache.ctakes.temporal.ae.feature.MultiTokenFeaturesExtractor;
 //import org.apache.ctakes.temporal.ae.feature.EventIndexOfSameSentenceRelationFeaturesExtractor;
 //import org.apache.ctakes.temporal.ae.feature.EventPositionRelationFeaturesExtractor;
 //import org.apache.ctakes.temporal.ae.feature.EventTimeRelationFeatureExtractor;
@@ -47,6 +49,7 @@ import org.apache.ctakes.temporal.ae.fea
 //import org.apache.ctakes.temporal.ae.feature.TimeWordTypeRelationExtractor;
 import org.apache.ctakes.temporal.ae.feature.TimeXPropertyRelationFeaturesExtractor;
 import org.apache.ctakes.temporal.ae.feature.TimeXRelationFeaturesExtractor;
+import org.apache.ctakes.temporal.ae.feature.UnexpandedTokenFeaturesExtractor;
 //import org.apache.ctakes.temporal.ae.feature.UnexpandedTokenFeaturesExtractor;
 //import org.apache.ctakes.temporal.ae.feature.TemporalAttributeFeatureExtractor;
 //import org.apache.ctakes.temporal.ae.feature.treekernel.EventTimeFlatTreeFeatureExtractor;
@@ -121,32 +124,25 @@ public class EventTimeSelfRelationAnnota
 	@Override
 	protected List<RelationFeaturesExtractor> getFeatureExtractors() {
 		return Lists.newArrayList(
-				new TokenFeaturesExtractor()
-				//				new UnexpandedTokenFeaturesExtractor() //use unexpanded version for i2b2 data
+				new TokenFeaturesExtractor()							
 				, new PartOfSpeechFeaturesExtractor()
 				, new TemporalAttributeFeatureExtractor()
-				//				, new EventTimeFlatTreeFeatureExtractor()
-				//				, new TemporalPETExtractor()
-				//, new TemporalPathExtractor()
-				//				, new EventVerbRelationTreeExtractor()
 				, new NumberOfEventTimeBetweenCandidatesExtractor()
-				//				, new SectionHeaderRelationExtractor()
 				, new NearbyVerbTenseRelationExtractor()
 				, new CheckSpecialWordRelationExtractor()
 				, new NearestFlagFeatureExtractor()
 				, new DependencyPathFeaturesExtractor()
 				, new DependencyFeatureExtractor()
-				//				, new SRLRelationFeaturesExtractor()// tried, but not helpful
 				, new EventArgumentPropertyExtractor()
 				, new OverlappedHeadFeaturesExtractor()
-				//				, new EventTimeRelationFeatureExtractor()
 				, new ConjunctionRelationFeaturesExtractor()
-				//				, new EventPositionRelationFeaturesExtractor() //tried, but not helpful
 				, new TimeXRelationFeaturesExtractor()
-				, new TemporalPETFlatExtractor()
-				, new TimeXPropertyRelationFeaturesExtractor()
-				//				, new TimeWordTypeRelationExtractor() //tried, but not helpful
-				//				, new EventIndexOfSameSentenceRelationFeaturesExtractor() //tried, but not helpful
+
+//				new MultiTokenFeaturesExtractor()
+//				new UnexpandedTokenFeaturesExtractor() //use unexpanded version for i2b2 data
+//				, new EmptyFeaturesExtractor()
+//				, new TemporalPETFlatExtractor()
+//				, new TimeXPropertyRelationFeaturesExtractor()
 				);
 	}
 
@@ -166,12 +162,12 @@ public class EventTimeSelfRelationAnnota
 		for (EventMention event : JCasUtil.selectCovered(jCas, EventMention.class, sentence)) {
 			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
+//				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;
-					}
-				}
+//						break;
+//					}
+//				}
 			}
 
 			if(eventValid){
@@ -183,9 +179,9 @@ public class EventTimeSelfRelationAnnota
 							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));
-						}
+//						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
 					for (TimeMention time : JCasUtil.selectCovered(jCas, TimeMention.class, sentence)) {

Added: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EmptyFeaturesExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EmptyFeaturesExtractor.java?rev=1647845&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EmptyFeaturesExtractor.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EmptyFeaturesExtractor.java
Wed Dec 24 21:19:14 2014
@@ -0,0 +1,19 @@
+package org.apache.ctakes.temporal.ae.feature;
+
+import java.util.List;
+
+import org.apache.ctakes.relationextractor.ae.features.RelationFeaturesExtractor;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.jcas.JCas;
+import org.cleartk.ml.Feature;
+
+public class EmptyFeaturesExtractor implements RelationFeaturesExtractor {
+
+	public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1,
+			IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+ //do noting
+}

Propchange: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EmptyFeaturesExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventThymeRelations.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventThymeRelations.java?rev=1647845&r1=1647844&r2=1647845&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventThymeRelations.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventThymeRelations.java
Wed Dec 24 21:19:14 2014
@@ -39,6 +39,7 @@ import org.apache.ctakes.temporal.ae.Eve
 //import org.apache.ctakes.temporal.ae.EventTimeRelationAnnotator;
 //import org.apache.ctakes.temporal.ae.EventEventRelationAnnotator;
 import org.apache.ctakes.temporal.ae.baselines.RecallBaselineEventTimeRelationAnnotator;
+import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.Overlap2Contains;
 import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.ParameterSettings;
 import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations_ImplBase.RemoveNonContainsRelations.RemoveGoldAttributes;
 //import org.apache.ctakes.temporal.eval.Evaluation_ImplBase.WriteI2B2XML;
@@ -285,6 +286,8 @@ EvaluationOfTemporalRelations_ImplBase{
 		//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNonContainsRelations.class));
 		//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddFlippedOverlap.class));//add
flipped overlap instances to training data
 
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(Overlap2Contains.class));
+		
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(PreserveEventEventRelations.class));
 		//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNonUMLSEvents.class));
 		
@@ -329,7 +332,7 @@ EvaluationOfTemporalRelations_ImplBase{
 		}
 
 		//    HideOutput hider = new HideOutput();
-		JarClassifierBuilder.trainAndPackage(new File(directory,"event-event"),"-w1","0.08","-w3","3","-w4","17","-w5","20","-w6","16","-w7","10","-w8","6",
"-w9","45","-w10","30","-c", optArray[1]);//"-c", "0.05");//optArray);
+		JarClassifierBuilder.trainAndPackage(new File(directory,"event-event"),"-w1","0.2","-w3","15","-w4","4","-w5","64","-w6","24","-w7","29","-w9","70","-c",
optArray[1]);//"-c", "0.05");//"0.08","-w3","3","-w4","17","-w5","20","-w6","16","-w7","10","-w8","6",
"-w9","45","-w10","30","-c", optArray[1]);//"-c", "0.05");//optArray);
 		//		JarClassifierBuilder.trainAndPackage(new File(directory,"event-event"), "-h","0","-c",
"1000");
 		//    hider.restoreOutput();
 		//    hider.close();

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=1647845&r1=1647844&r2=1647845&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
Wed Dec 24 21:19:14 2014
@@ -29,6 +29,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Deque;
+import java.util.HashMap;
 //import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -131,20 +132,20 @@ EvaluationOfTemporalRelations_ImplBase{
 
 	public static void main(String[] args) throws Exception {
 		TempRelOptions options = CliFactory.parseArguments(TempRelOptions.class, args);
-    List<Integer> trainItems = null;
-    List<Integer> devItems = null;
-    List<Integer> testItems = null;
-    
-    List<Integer> patientSets = options.getPatients().getList();
-    if(options.getXMLFormat() == XMLFormat.I2B2){
-      trainItems = I2B2Data.getTrainPatientSets(options.getXMLDirectory());
-      devItems = I2B2Data.getDevPatientSets(options.getXMLDirectory());
-      testItems = I2B2Data.getTestPatientSets(options.getXMLDirectory());
-    }else{
-      trainItems = THYMEData.getPatientSets(patientSets, options.getTrainRemainders().getList());
-      devItems = THYMEData.getPatientSets(patientSets, options.getDevRemainders().getList());
-      testItems = THYMEData.getPatientSets(patientSets, options.getTestRemainders().getList());
-    }
+		List<Integer> trainItems = null;
+		List<Integer> devItems = null;
+		List<Integer> testItems = null;
+
+		List<Integer> patientSets = options.getPatients().getList();
+		if(options.getXMLFormat() == XMLFormat.I2B2){
+			trainItems = I2B2Data.getTrainPatientSets(options.getXMLDirectory());
+			devItems = I2B2Data.getDevPatientSets(options.getXMLDirectory());
+			testItems = I2B2Data.getTestPatientSets(options.getXMLDirectory());
+		}else{
+			trainItems = THYMEData.getPatientSets(patientSets, options.getTrainRemainders().getList());
+			devItems = THYMEData.getPatientSets(patientSets, options.getDevRemainders().getList());
+			testItems = THYMEData.getPatientSets(patientSets, options.getTestRemainders().getList());
+		}
 		ParameterSettings params = allParams;
 
 		//    possibleParams.add(defaultParams);
@@ -173,7 +174,7 @@ EvaluationOfTemporalRelations_ImplBase{
 					options.getUseGoldAttributes(),
 					options.getKernelParams(),
 					params);
-			
+
 			if(options.getI2B2Output()!=null) evaluation.setI2B2Output(options.getI2B2Output() + "/temporal-relations/event-time");
 			List<Integer> training = trainItems;
 			List<Integer> testing = null;
@@ -190,12 +191,12 @@ EvaluationOfTemporalRelations_ImplBase{
 			}else{
 				evaluation.prepareXMIsFor(patientSets);
 			}
-			
+
 			params.stats = evaluation.trainAndTest(training, testing);//training);//
 			//      System.err.println(options.getKernelParams() == null ? params : options.getKernelParams());
 			System.err.println("No closure on gold::Closure on System::Recall Mode");
 			System.err.println(params.stats);
-			
+
 			//do closure on gold, but not on system, to calculate precision
 			evaluation.skipTrain = true;
 			recallModeEvaluation = false;
@@ -203,7 +204,7 @@ EvaluationOfTemporalRelations_ImplBase{
 			//      System.err.println(options.getKernelParams() == null ? params : options.getKernelParams());
 			System.err.println("No closure on System::Closure on Gold::Precision Mode");
 			System.err.println(params.stats);
-			
+
 			//do closure on train, but not on test, to calculate plain results
 			evaluation.skipTrain = true;
 			evaluation.useClosure = false;
@@ -211,7 +212,7 @@ EvaluationOfTemporalRelations_ImplBase{
 			//      System.err.println(options.getKernelParams() == null ? params : options.getKernelParams());
 			System.err.println("Closure on train::No closure on Test::Plain Mode");
 			System.err.println(params.stats);
-			
+
 			if(options.getUseTmp()){
 				// won't work because it's not empty. should we be concerned with this or is it responsibility
of 
 				// person invoking the tmp flag?
@@ -287,13 +288,15 @@ EvaluationOfTemporalRelations_ImplBase{
 			//			aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveBeforeAndOnRelations.class));
 		}
 		//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNonContainsRelations.class));
-//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddFlippedOverlap.class));//add
flipped overlap instances to training data
+		//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddFlippedOverlap.class));//add
flipped overlap instances to training data
+
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(Overlap2Contains.class));
 
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveEventEventRelations.class));
-		
+
 		//add unlabeled nearby system events as potential links: 
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(AddPotentialRelations.class));
-		
+
 		aggregateBuilder.add(EventTimeSelfRelationAnnotator.createDataWriterDescription(
 				LibLinearStringOutcomeDataWriter.class,
 				//				LIBSVMStringOutcomeDataWriter.class,
@@ -332,7 +335,7 @@ EvaluationOfTemporalRelations_ImplBase{
 		}
 
 		//    HideOutput hider = new HideOutput();
-		JarClassifierBuilder.trainAndPackage(new File(directory,"event-time"), "-w3","2","-w4","18","-w5","14","-w6","21","-w7","100","-w8","19","-c",
optArray[1]);//"0.05");//"-h","0","-c", "1000");//optArray);
+		JarClassifierBuilder.trainAndPackage(new File(directory,"event-time"), "-w3","2","-w4","19","-w5","13","-w6","22","-w7","96","-w8","18","-c",
optArray[1]);//"-w3","2","-w4","19","-w5","13","-w6","22","-w7","96","-w8","18","-c", optArray[1]);//"-w4","18","-w5","14","-w6","21","-w7","100","-w8","19","-c",
optArray[1]);//"0.05");//"-h","0","-c", "1000");//optArray);
 		//		JarClassifierBuilder.trainAndPackage(new File(directory,"event-event"), "-h","0","-c",
"1000");
 		//    hider.restoreOutput();
 		//    hider.close();
@@ -362,16 +365,16 @@ EvaluationOfTemporalRelations_ImplBase{
 				AnalysisEngineFactory.createEngineDescription(RemoveEventEventRelations.class),
 				CAS.NAME_DEFAULT_SOFA,
 				GOLD_VIEW_NAME);
-		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveNonUMLSEtEvents.class));
+		//		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveNonUMLSEtEvents.class));
 
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveRelations.class));
 		aggregateBuilder.add(this.baseline ? RecallBaselineEventTimeRelationAnnotator.createAnnotatorDescription(directory)
:
 			EventTimeSelfRelationAnnotator.createEngineDescription(new File(directory,"event-time")));
-		
+
 		if(this.i2b2Output != null){
 			aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(WriteI2B2XML.class,
WriteI2B2XML.PARAM_OUTPUT_DIR, this.i2b2Output), "TimexView", CAS.NAME_DEFAULT_SOFA);
 		}
-		
+
 		File outf = null;
 		if (recallModeEvaluation && this.useClosure) {//add closure for system output
 			aggregateBuilder.add(
@@ -392,9 +395,9 @@ EvaluationOfTemporalRelations_ImplBase{
 		}
 
 		PrintWriter outDrop =null;
-		
+
 		outDrop = new PrintWriter(new BufferedWriter(new FileWriter(outf, false)));
-		
+
 		Function<BinaryTextRelation, ?> getSpan = new Function<BinaryTextRelation, HashableArguments>()
{
 			public HashableArguments apply(BinaryTextRelation relation) {
 				return new HashableArguments(relation);
@@ -418,7 +421,7 @@ EvaluationOfTemporalRelations_ImplBase{
 
 			//newly add
 			//			systemRelations = removeNonGoldRelations(systemRelations, goldRelations, getSpan);//for
removing non-gold pairs
-//			systemRelations = correctArgOrder(systemRelations, goldRelations);//change the argument
order of "OVERLAP" relation, if the order is flipped
+			//			systemRelations = correctArgOrder(systemRelations, goldRelations);//change the argument
order of "OVERLAP" relation, if the order is flipped
 			//find duplicates in gold relations:
 			//			Collection<BinaryTextRelation> duplicateGoldRelations = getDuplicateRelations(goldRelations,
getSpan);
 			//			if(!duplicateGoldRelations.isEmpty()){
@@ -467,7 +470,7 @@ 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";
 
@@ -555,31 +558,31 @@ EvaluationOfTemporalRelations_ImplBase{
   }
 	 */
 
-//	private static <SPAN_TYPE> Collection<BinaryTextRelation> removeNonGoldRelations(
-//			Collection<BinaryTextRelation> systemRelations,
-//			Collection<BinaryTextRelation> goldRelations, Function<BinaryTextRelation,
?> getSpan) {
-//		//remove non-gold pairs from system relations:
-//		Set<BinaryTextRelation> goodSys = Sets.newHashSet();
-//		Set<SPAN_TYPE> goldspans = new HashSet<>();
-//
-//		for (BinaryTextRelation relation : goldRelations) {
-//			goldspans.add(((SPAN_TYPE) getSpan.apply(relation)));			
-//		}
-//
-//		for (BinaryTextRelation relation : systemRelations) {
-//			if (goldspans.contains(((SPAN_TYPE) getSpan.apply(relation)))) {
-//				goodSys.add(relation);
-//			}
-//		}
-//
-//		return goodSys;
-//	}
-//
-//	private static boolean matchSpan(Annotation arg1, Annotation arg2) {
-//		boolean result = false;
-//		result = arg1.getBegin() == arg2.getBegin() && arg1.getEnd() == arg2.getEnd();
-//		return result;
-//	}
+	//	private static <SPAN_TYPE> Collection<BinaryTextRelation> removeNonGoldRelations(
+	//			Collection<BinaryTextRelation> systemRelations,
+	//			Collection<BinaryTextRelation> goldRelations, Function<BinaryTextRelation,
?> getSpan) {
+	//		//remove non-gold pairs from system relations:
+	//		Set<BinaryTextRelation> goodSys = Sets.newHashSet();
+	//		Set<SPAN_TYPE> goldspans = new HashSet<>();
+	//
+	//		for (BinaryTextRelation relation : goldRelations) {
+	//			goldspans.add(((SPAN_TYPE) getSpan.apply(relation)));			
+	//		}
+	//
+	//		for (BinaryTextRelation relation : systemRelations) {
+	//			if (goldspans.contains(((SPAN_TYPE) getSpan.apply(relation)))) {
+	//				goodSys.add(relation);
+	//			}
+	//		}
+	//
+	//		return goodSys;
+	//	}
+	//
+	//	private static boolean matchSpan(Annotation arg1, Annotation arg2) {
+	//		boolean result = false;
+	//		result = arg1.getBegin() == arg2.getBegin() && arg1.getEnd() == arg2.getEnd();
+	//		return result;
+	//	}
 
 	//	@SuppressWarnings("unchecked")
 	//	private static <SPAN> Collection<BinaryTextRelation> getDuplicateRelations(
@@ -662,7 +665,7 @@ EvaluationOfTemporalRelations_ImplBase{
 
 		}
 	}
-	
+
 	public static class AddPotentialRelations extends JCasAnnotator_ImplBase {
 		public static final String PARAM_RELATION_VIEW = "RelationView";
 		@ConfigurationParameter(name = PARAM_RELATION_VIEW,mandatory=false)
@@ -678,7 +681,7 @@ EvaluationOfTemporalRelations_ImplBase{
 			}
 
 			Map<EventMention, Collection<EventMention>> coveringMap =
-					  JCasUtil.indexCovering(relationView, EventMention.class, EventMention.class);
+					JCasUtil.indexCovering(relationView, EventMention.class, EventMention.class);
 			for(TemporalTextRelation relation : Lists.newArrayList(JCasUtil.select(relationView, TemporalTextRelation.class))){
 				Annotation arg1 = relation.getArg1().getArgument();
 				Annotation arg2 = relation.getArg2().getArgument();
@@ -725,7 +728,7 @@ EvaluationOfTemporalRelations_ImplBase{
 			relation.setArg2(relArg2);
 			relation.setCategory(category);
 			relation.addToIndexes();
-			
+
 		}
 	}
 
@@ -1023,6 +1026,42 @@ EvaluationOfTemporalRelations_ImplBase{
 		}
 	}
 
+	/**
+	 * For conflicting temporal relations on the same pair of arguments, if some of the relation
types are "overlap", and "contains", remove "overlap" and keep "contains" 
+	 * @author CH151862
+	 *
+	 */
+	public static class Overlap2Contains extends JCasAnnotator_ImplBase {
+
+		@Override
+		public void process(JCas jCas) throws AnalysisEngineProcessException {
+			Map<List<Annotation>, BinaryTextRelation> relationLookup;
+			relationLookup = new HashMap<>();
+			for (BinaryTextRelation relation : JCasUtil.select(jCas, BinaryTextRelation.class)) {
+				Annotation arg1 = relation.getArg1().getArgument();
+				Annotation arg2 = relation.getArg2().getArgument();
+				String relationType = relation.getCategory();
+				// The key is a list of args so we can do bi-directional lookup
+				List<Annotation> key = Arrays.asList(arg1, arg2);
+				if(relationLookup.containsKey(key)){
+					BinaryTextRelation storedRel = relationLookup.get(key);
+					String reln = storedRel.getCategory();
+					if(!relationType.equals(reln)){//if there is category conflicts
+						if(relationType.startsWith("OVERLAP") ){
+							//override "OVERLAP"
+							relation.setCategory(reln);
+						}else if( reln.startsWith("OVERLAP") ){
+							//remove duplicate:
+							storedRel.setCategory(relationType);
+						}
+					}
+				}
+				relationLookup.put(key, relation);
+			}
+
+		}
+	}
+
 	public static class AddClosure extends JCasAnnotator_ImplBase {
 
 		@Override

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java?rev=1647845&r1=1647844&r2=1647845&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
Wed Dec 24 21:19:14 2014
@@ -440,14 +440,9 @@ org.cleartk.eval.Evaluation_ImplBase<Int
 				"DeleteAction",
 				new String[] { "selector=B" }));
 		// add UMLS on top of lookup windows
-		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(DefaultJCasTermAnnotator.class,
-		          AbstractJCasTermAnnotator.PARAM_WINDOW_ANNOT_PRP,
-		          "org.apache.ctakes.typesystem.type.textspan.Sentence",
-		          JCasTermAnnotator.DICTIONARY_DESCRIPTOR_KEY,
-		          ExternalResourceFactory.createExternalResourceDescription(
-		              FileResourceImpl.class,
-		              FileLocator.locateFile("org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml"))
-		          ));
+		aggregateBuilder.add(
+				UmlsDictionaryLookupAnnotator.createAnnotatorDescription()
+				);
 
 		aggregateBuilder.add(LvgAnnotator.createAnnotatorDescription());
 



Mime
View raw message