ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1677203 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/
Date Fri, 01 May 2015 18:30:30 GMT
Author: clin
Date: Fri May  1 18:30:30 2015
New Revision: 1677203

URL: http://svn.apache.org/r1677203
Log:
current temporal relation evaluation code.
both event-event and event-time use event expansion.
closure was not applied to evaluation (i.e. testing, but still applied to training) since standard evaluation would take care closure.

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfBothEEAndETRelations.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/EvaluationOfEventProperties.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/EvaluationOfI2B2TemporalRelations.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfSelfEventTimeRelations.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfBothEEAndETRelations.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfBothEEAndETRelations.java?rev=1677203&r1=1677202&r2=1677203&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfBothEEAndETRelations.java (original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfBothEEAndETRelations.java Fri May  1 18:30:30 2015
@@ -40,9 +40,12 @@ 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.EvaluationOfEventEventThymeRelations.AddEEPotentialRelations;
+import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.AddPotentialRelations;
 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.EvaluationOfTemporalRelations_ImplBase.RemoveGoldAttributes;
+import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations_ImplBase.RemoveNonContainsRelations;
 //import org.apache.ctakes.temporal.eval.Evaluation_ImplBase.WriteI2B2XML;
 //import org.apache.ctakes.temporal.eval.Evaluation_ImplBase.XMLFormat;
 import org.apache.ctakes.temporal.utils.AnnotationIdCollection;
@@ -174,7 +177,7 @@ EvaluationOfTemporalRelations_ImplBase{
 					options.getKernelParams(),
 					params);
 			//			evaluation.prepareXMIsFor(patientSets);
-			if(options.getI2B2Output()!=null) evaluation.setI2B2Output(options.getI2B2Output() + "/temporal-relations/event-event");
+			if(options.getI2B2Output()!=null) evaluation.setI2B2Output(options.getI2B2Output() + "/temporal-relations/both");
 			List<Integer> training = trainItems;
 			List<Integer> testing = null;
 			if(options.getTest()){
@@ -192,25 +195,25 @@ EvaluationOfTemporalRelations_ImplBase{
 			}
 			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("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;
-			params.stats = evaluation.trainAndTest(training, testing);//training);//
-			//      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;
-			//			evaluation.printErrors = false;
-			params.stats = evaluation.trainAndTest(training, testing);//training);//
-			//      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);
+//			evaluation.skipTrain = true;
+//			recallModeEvaluation = false;
+//			params.stats = evaluation.trainAndTest(training, testing);//training);//
+//			//      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;
+//			//			evaluation.printErrors = false;
+//			params.stats = evaluation.trainAndTest(training, testing);//training);//
+//			//      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 
@@ -288,7 +291,7 @@ EvaluationOfTemporalRelations_ImplBase{
 			//			aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddContain2Overlap.class));
 			//			aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveBeforeAndOnRelations.class));
 		}
-		//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNonContainsRelations.class));
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveNonContainsRelations.class));
 		//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddFlippedOverlap.class));//add flipped overlap instances to training data
 
 		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNonTLINKRelations.class));//remove non tlink relations, such as alinks
@@ -299,8 +302,8 @@ EvaluationOfTemporalRelations_ImplBase{
 		//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNonUMLSEvents.class));
 
 		//add unlabeled nearby system events as potential links: 
-		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(AddEEPotentialRelations.class));
-		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(AddPotentialRelations.class));	
+//		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(AddEEPotentialRelations.class));
+//		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(AddPotentialRelations.class));	
 
 		aggregateBuilder.add(EventEventRelationAnnotator.createDataWriterDescription(
 				LibLinearStringOutcomeDataWriter.class,
@@ -338,8 +341,8 @@ EvaluationOfTemporalRelations_ImplBase{
 		}
 
 		//    HideOutput hider = new HideOutput();
-		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-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"),"-w2","10","-w3","86","-c", "0.003");//"-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-time"), "-w3","2","-w4","19","-w5","13","-w6","22","-w7","96","-w8","18","-c", "0.0007"); //"-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();
@@ -349,6 +352,7 @@ EvaluationOfTemporalRelations_ImplBase{
 	@Override
 	protected AnnotationStatistics<String> test(CollectionReader collectionReader, File directory)
 			throws Exception {
+		this.useClosure=false;
 		AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
 		aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class, TimeMention.class));
 
@@ -379,6 +383,10 @@ EvaluationOfTemporalRelations_ImplBase{
 					CAS.NAME_DEFAULT_SOFA,
 					GOLD_VIEW_NAME);
 		}
+		
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveNonContainsRelations.class),
+				CAS.NAME_DEFAULT_SOFA,
+				GOLD_VIEW_NAME);
 
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveRelations.class));
 		aggregateBuilder.add(this.baseline ? RecallBaselineEventTimeRelationAnnotator.createAnnotatorDescription(directory) :
@@ -523,100 +531,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)
-		private String relationViewName = CAS.NAME_DEFAULT_SOFA;
-
-		@Override
-		public void process(JCas jCas) throws AnalysisEngineProcessException {
-			JCas relationView;
-			try {
-				relationView = jCas.getView(this.relationViewName);
-			} catch (CASException e) {
-				throw new AnalysisEngineProcessException(e);
-			}
-
-			Map<EventMention, Collection<EventMention>> coveringMap =
-					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();
-				EventMention event = null;
-				if(arg1 instanceof EventMention && arg2 instanceof TimeMention){
-					event = (EventMention) arg1;
-					Collection<EventMention> eventList = coveringMap.get(event);
-					for(EventMention covEvent : eventList){
-						if(!covEvent.getClass().equals(EventMention.class)){
-							createRelation(relationView, covEvent, arg2, relation.getCategory());
-						}
-					}
-					for(EventMention covedEvent : JCasUtil.selectCovered(jCas, EventMention.class, event)){//select covered events
-						createRelation(relationView, covedEvent, arg2, relation.getCategory());
-					}
-				}else if(arg2 instanceof EventMention && arg1 instanceof TimeMention){
-					event = (EventMention) arg2;
-					Collection<EventMention> eventList = coveringMap.get(event);
-					for(EventMention covEvent : eventList){
-						if(!covEvent.getClass().equals(EventMention.class)){
-							createRelation(relationView, arg1, covEvent, relation.getCategory());
-						}
-					}
-					for(EventMention covedEvent : JCasUtil.selectCovered(jCas, EventMention.class, event)){//select covered events
-						createRelation(relationView, arg1, covedEvent, relation.getCategory());
-					}
-				}
-			}
-
-		}
-	}
-	public static class AddEEPotentialRelations extends org.apache.uima.fit.component.JCasAnnotator_ImplBase {
-		public static final String PARAM_RELATION_VIEW = "RelationView";
-		@ConfigurationParameter(name = PARAM_RELATION_VIEW,mandatory=false)
-		private String relationViewName = CAS.NAME_DEFAULT_SOFA;
-
-		@Override
-		public void process(JCas jCas) throws AnalysisEngineProcessException {
-			JCas relationView;
-			try {
-				relationView = jCas.getView(this.relationViewName);
-			} catch (CASException e) {
-				throw new AnalysisEngineProcessException(e);
-			}
-
-			Map<EventMention, Collection<EventMention>> coveringMap =
-					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();
-				if(arg1 instanceof EventMention && arg2 instanceof EventMention){
-					EventMention event1 = (EventMention) arg1;
-					EventMention event2 = (EventMention) arg2;
-					for(EventMention covEventA : coveringMap.get(event1)){
-						for(EventMention covEventB : coveringMap.get(event2)){
-							createRelation(relationView, covEventA, covEventB, relation.getCategory());
-						}
-						createRelation(relationView, covEventA, event2, relation.getCategory());
-					}
-					for(EventMention covEventB : coveringMap.get(event2)){
-						createRelation(relationView, event1, covEventB, relation.getCategory());
-					}
-					//get covered system events:
-					for(EventMention covedEventA : JCasUtil.selectCovered(jCas, EventMention.class, event1)){//select covered events
-						for(EventMention covedEventB : JCasUtil.selectCovered(jCas, EventMention.class, event2)){
-							createRelation(relationView, covedEventA, covedEventB, relation.getCategory());
-						}
-						createRelation(relationView, covedEventA, event2, relation.getCategory());
-					}
-					for(EventMention covedEventB : JCasUtil.selectCovered(jCas, EventMention.class, event2)){
-						createRelation(relationView, event1, covedEventB, relation.getCategory());
-					}
-				}
-			}
-
-		}
-	}
-
+	
 	static void createRelation(JCas jCas, Annotation arg1,
 			Annotation arg2, String category) {
 		RelationArgument relArg1 = new RelationArgument(jCas);

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=1677203&r1=1677202&r2=1677203&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 Fri May  1 18:30:30 2015
@@ -29,6 +29,8 @@ 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;
 import java.util.Set;
@@ -41,7 +43,7 @@ import org.apache.ctakes.temporal.ae.Eve
 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.EvaluationOfTemporalRelations_ImplBase.RemoveGoldAttributes;
 //import org.apache.ctakes.temporal.eval.Evaluation_ImplBase.WriteI2B2XML;
 //import org.apache.ctakes.temporal.eval.Evaluation_ImplBase.XMLFormat;
 import org.apache.ctakes.temporal.utils.AnnotationIdCollection;
@@ -49,6 +51,7 @@ import org.apache.ctakes.temporal.utils.
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
 import org.apache.ctakes.typesystem.type.relation.RelationArgument;
 import org.apache.ctakes.typesystem.type.relation.TemporalTextRelation;
+import org.apache.ctakes.typesystem.type.syntax.WordToken;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
 import org.apache.ctakes.typesystem.type.textsem.TimeMention;
@@ -125,8 +128,18 @@ EvaluationOfTemporalRelations_ImplBase{
 	protected static ParameterSettings ftParams = new ParameterSettings(DEFAULT_BOTH_DIRECTIONS, DEFAULT_DOWNSAMPLE, "tk", 
 			1.0, 0.1, "radial basis function", ComboOperator.SUM, 0.5, 0.5);
 	private static Boolean recallModeEvaluation = true;
+	
+	static int sysRelationCount;
+	static int closeRelationCount;
+	static int goldRelationCount;
+	static int closeGoldRelationCount;
 
 	public static void main(String[] args) throws Exception {
+		sysRelationCount = 0;
+		closeRelationCount = 0;
+		goldRelationCount = 0;
+		closeGoldRelationCount = 0;
+		
 		TempRelOptions options = CliFactory.parseArguments(TempRelOptions.class, args);
 		List<Integer> trainItems = null;
 		List<Integer> devItems = null;
@@ -181,6 +194,9 @@ EvaluationOfTemporalRelations_ImplBase{
 			}else{
 				testing = devItems;
 			}
+			
+			evaluation.printErrors = false;
+			
 			//do closure on system, but not on gold, to calculate recall
 			evaluation.skipTrain = options.getSkipTrain();
 			if(evaluation.skipTrain && options.getTest()){
@@ -188,27 +204,32 @@ EvaluationOfTemporalRelations_ImplBase{
 			}else{
 				evaluation.prepareXMIsFor(patientSets);
 			}
+			evaluation.printErrors=true;
 			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("No closure on gold::Closure on System::Recall Mode");
 			System.err.println(params.stats);
+			
+			System.err.println("System predict relations #: "+ sysRelationCount);
+			System.err.println("# of system relations whose arguments are close: "+ closeRelationCount);
+			System.err.println("Gold relations #: "+ goldRelationCount);
+			System.err.println("# of gold relations whose arguments are close: "+ closeGoldRelationCount);
 
 			//do closure on gold, but not on system, to calculate precision
-			evaluation.skipTrain = true;
-			recallModeEvaluation = false;
-			params.stats = evaluation.trainAndTest(training, testing);//training);//
-			//      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;
-//			evaluation.printErrors = false;
-			params.stats = evaluation.trainAndTest(training, testing);//training);//
-			//      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);
+//			evaluation.skipTrain = true;
+//			recallModeEvaluation = false;
+//			params.stats = evaluation.trainAndTest(training, testing);//training);//
+//			//      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;
+//			params.stats = evaluation.trainAndTest(training, testing);//training);//
+//			//      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 
@@ -281,17 +302,20 @@ EvaluationOfTemporalRelations_ImplBase{
 		if(!this.useGoldAttributes){
 			aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveGoldAttributes.class));
 		}
+		
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(PreserveEventEventRelations.class));
+		
 		if (this.useClosure) {
 			aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(AddClosure.class));//aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveContainsRelations.class));
 			//			aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddContain2Overlap.class));
 			//			aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveBeforeAndOnRelations.class));
 		}
-		//		aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNonContainsRelations.class));
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(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));
 		
 		//add unlabeled nearby system events as potential links: 
@@ -335,7 +359,7 @@ EvaluationOfTemporalRelations_ImplBase{
 		}
 
 		//    HideOutput hider = new HideOutput();
-		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"),"-w2","13","-w3","86","-c", optArray[1]);//"-w2","12","-w3","102",//"-w1","29","-w3","12","-w4","80","-w5","228","-w6","79","-w7","49","-w8","157","-w9","553","-w10","384",//"-w1","29","-w3","12","-w4","79","-w5","255","-w6","75","-w7","50","-w8","144","-w9","544","-w10","384",//"-w1","25","-w3","9","-w4","79","-w5","267","-w6","89","-w7","60","-w8","152","-w9","615","-w10","404",//"-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();
@@ -344,6 +368,7 @@ EvaluationOfTemporalRelations_ImplBase{
 	@Override
 	protected AnnotationStatistics<String> test(CollectionReader collectionReader, File directory)
 			throws Exception {
+		this.useClosure=false;
 		AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
 		aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class, TimeMention.class));
 
@@ -353,12 +378,11 @@ EvaluationOfTemporalRelations_ImplBase{
 				CAS.NAME_DEFAULT_SOFA,
 				RemoveCrossSentenceRelations.PARAM_RELATION_VIEW,
 				GOLD_VIEW_NAME));
-
+		
 		aggregateBuilder.add(
 				AnalysisEngineFactory.createEngineDescription(PreserveEventEventRelations.class),
 				CAS.NAME_DEFAULT_SOFA,
 				GOLD_VIEW_NAME);
-		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveNonUMLSEvents.class));
 
 		if (!recallModeEvaluation && this.useClosure) { //closure for gold
 			aggregateBuilder.add(
@@ -366,10 +390,19 @@ EvaluationOfTemporalRelations_ImplBase{
 					CAS.NAME_DEFAULT_SOFA,
 					GOLD_VIEW_NAME);
 		}
+		
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveNonContainsRelations.class),
+				CAS.NAME_DEFAULT_SOFA,
+				GOLD_VIEW_NAME);
+		
+//		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveNonUMLSEvents.class));
 
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveRelations.class));
 		aggregateBuilder.add(this.baseline ? RecallBaselineEventTimeRelationAnnotator.createAnnotatorDescription(directory) :
 			EventEventRelationAnnotator.createAnnotatorDescription(new File(directory,"event-event")));
+		
+		//count how many system predicted relations, their arguments are close to each other, without any other event in between
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(CountCloseRelation.class));
 
 		if(this.i2b2Output != null){
 			aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(WriteI2B2XML.class, WriteI2B2XML.PARAM_OUTPUT_DIR, this.i2b2Output), "TimexView", CAS.NAME_DEFAULT_SOFA);
@@ -464,6 +497,66 @@ EvaluationOfTemporalRelations_ImplBase{
 		outDrop.close();
 		return stats;
 	}
+	
+	public static class CountCloseRelation extends JCasAnnotator_ImplBase {
+
+		private String systemViewName = CAS.NAME_DEFAULT_SOFA;
+		
+		@Override
+		public void process(JCas jCas) throws AnalysisEngineProcessException {
+			JCas systemView, goldView;
+			int sizeLimit = 6;
+			try {
+				systemView = jCas.getView(this.systemViewName);
+				goldView = jCas.getView(GOLD_VIEW_NAME);
+			} catch (CASException e) {
+				throw new AnalysisEngineProcessException(e);
+			}
+
+			//count how many sentences have timex, and how many sentences have only one timex
+			for (TemporalTextRelation relation : JCasUtil.select(systemView, TemporalTextRelation.class)) {
+				sysRelationCount ++;
+				Annotation arg1 = relation.getArg1().getArgument();
+				Annotation arg2 = relation.getArg2().getArgument();
+				if( arg1.getBegin()> arg2.getBegin()){
+					Annotation temp = arg1;
+					arg1 = arg2;
+					arg2 = temp;
+				}
+				List<WordToken> words = JCasUtil.selectBetween(systemView, WordToken.class, arg1, arg2);
+				if(words.size()<sizeLimit){
+					closeRelationCount++;
+				}
+			}
+			
+			Map<List<Annotation>, TemporalTextRelation> relationLookup = new HashMap<>();
+			for (TemporalTextRelation relation : Lists.newArrayList(JCasUtil.select(goldView, TemporalTextRelation.class))) {
+				Annotation arg1 = relation.getArg1().getArgument();
+				Annotation arg2 = relation.getArg2().getArgument();
+				// 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)){
+					relationLookup.put(key, relation);
+				}
+			}
+
+			//count how many sentences have timex, and how many sentences have only one timex
+			for (TemporalTextRelation relation : relationLookup.values()) {
+				goldRelationCount ++;
+				Annotation arg1 = relation.getArg1().getArgument();
+				Annotation arg2 = relation.getArg2().getArgument();
+				if( arg1.getBegin()> arg2.getBegin()){
+					Annotation temp = arg1;
+					arg1 = arg2;
+					arg2 = temp;
+				}
+				List<WordToken> words = JCasUtil.selectBetween(systemView, WordToken.class, arg1, arg2);
+				if(words.size()<sizeLimit){
+					closeGoldRelationCount++;
+				}
+			}
+		}
+	}
 
 	public static class RemoveNonUMLSEvents extends org.apache.uima.fit.component.JCasAnnotator_ImplBase {
 		public static final String PARAM_GOLD_VIEW = "GoldView";
@@ -523,6 +616,8 @@ EvaluationOfTemporalRelations_ImplBase{
 				throw new AnalysisEngineProcessException(e);
 			}
 
+			Set<List<EventMention>> relationLookup = new HashSet<>();
+			
 			Map<EventMention, Collection<EventMention>> coveringMap =
 					  JCasUtil.indexCovering(relationView, EventMention.class, EventMention.class);
 			for(TemporalTextRelation relation : Lists.newArrayList(JCasUtil.select(relationView, TemporalTextRelation.class))){
@@ -532,19 +627,42 @@ EvaluationOfTemporalRelations_ImplBase{
 					EventMention event1 = (EventMention) arg1;
 					EventMention event2 = (EventMention) arg2;
 					for(EventMention covEventA : coveringMap.get(event1)){
+						List<EventMention> key = Arrays.asList(covEventA, event2);
+						if(!relationLookup.contains(key) && !hasOverlap(covEventA,event2)){
+							relationLookup.add(key);
+							createRelation(relationView, covEventA, event2, relation.getCategory());
+						}
 						for(EventMention covEventB : coveringMap.get(event2)){
-							createRelation(relationView, covEventA, covEventB, relation.getCategory());
+							key = Arrays.asList(covEventA, covEventB);
+							if(!relationLookup.contains(key) && !hasOverlap(covEventA,covEventB)){
+								relationLookup.add(key);
+								createRelation(relationView, covEventA, covEventB, relation.getCategory());
+							}
 						}
-						createRelation(relationView, covEventA, event2, relation.getCategory());
 					}
 					for(EventMention covEventB : coveringMap.get(event2)){
-						createRelation(relationView, event1, covEventB, relation.getCategory());
+						List<EventMention> key = Arrays.asList(event1, covEventB);
+						if(!relationLookup.contains(key) && !hasOverlap(event1,covEventB)){
+							relationLookup.add(key);
+							createRelation(relationView, event1, covEventB, relation.getCategory());
+						}
 					}
 				}
 			}
 
 		}
 
+
+		private static boolean hasOverlap(Annotation event1, Annotation event2) {
+			if(event1.getEnd()>=event2.getBegin()&&event1.getEnd()<=event2.getEnd()){
+				return true;
+			}
+			if(event2.getEnd()>=event1.getBegin()&&event2.getEnd()<=event1.getEnd()){
+				return true;
+			}
+			return false;
+		}
+
 		private static void createRelation(JCas jCas, Annotation arg1,
 				Annotation arg2, String category) {
 			RelationArgument relArg1 = new RelationArgument(jCas);

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventProperties.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventProperties.java?rev=1677203&r1=1677202&r2=1677203&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventProperties.java (original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventProperties.java Fri May  1 18:30:30 2015
@@ -218,8 +218,8 @@ Evaluation_ImplBase<Map<String, Annotati
 							EventMention event = goldEvents.get(i);
 							int begin = event.getBegin();
 							int end = event.getEnd();
-							int windowBegin = Math.max(0, begin - 50);
-							int windowEnd = Math.min(text.length(), end + 50);
+							int windowBegin = Math.max(0, begin - 100);
+							int windowEnd = Math.min(text.length(), end + 100);
 							if (!goldOutcome.equals(systemOutcome)) {
 								this.loggers.get(name).fine(String.format(
 										"%s was %s but should be %s, in  ...%s[!%s!:%d-%d]%s...",

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=1677203&r1=1677202&r2=1677203&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 Fri May  1 18:30:30 2015
@@ -41,7 +41,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.EvaluationOfTemporalRelations_ImplBase.RemoveNonContainsRelations.RemoveGoldAttributes;
+import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations_ImplBase.RemoveGoldAttributes;
 //import org.apache.ctakes.temporal.eval.Evaluation_ImplBase.WriteI2B2XML;
 //import org.apache.ctakes.temporal.eval.Evaluation_ImplBase.XMLFormat;
 import org.apache.ctakes.temporal.utils.AnnotationIdCollection;
@@ -49,6 +49,7 @@ import org.apache.ctakes.temporal.utils.
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
 import org.apache.ctakes.typesystem.type.relation.RelationArgument;
 import org.apache.ctakes.typesystem.type.relation.TemporalTextRelation;
+import org.apache.ctakes.typesystem.type.syntax.WordToken;
 //import org.apache.ctakes.typesystem.type.relation.TemporalTextRelation;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
@@ -127,8 +128,18 @@ EvaluationOfTemporalRelations_ImplBase{
 	protected static ParameterSettings ftParams = new ParameterSettings(DEFAULT_BOTH_DIRECTIONS, DEFAULT_DOWNSAMPLE, "tk", 
 			1.0, 0.1, "radial basis function", ComboOperator.SUM, 0.5, 0.5);
 	private static Boolean recallModeEvaluation = true;
+	
+	static int sysRelationCount;
+	static int closeRelationCount;
+	static int goldRelationCount;
+	static int closeGoldRelationCount;
 
 	public static void main(String[] args) throws Exception {
+		sysRelationCount = 0;
+		closeRelationCount = 0;
+		goldRelationCount = 0;
+		closeGoldRelationCount = 0;
+		
 		TempRelOptions options = CliFactory.parseArguments(TempRelOptions.class, args);
 		List<Integer> trainItems = null;
 		List<Integer> devItems = null;
@@ -191,26 +202,31 @@ EvaluationOfTemporalRelations_ImplBase{
 				evaluation.prepareXMIsFor(patientSets);
 			}
 
+			evaluation.printErrors = true;
 			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("No closure on gold::Closure on System::Recall Mode");
 			System.err.println(params.stats);
 
+			System.err.println("System predict relations #: "+ sysRelationCount);
+			System.err.println("# of system relations whose arguments are close: "+ closeRelationCount);
+			System.err.println("Gold relations #: "+ goldRelationCount);
+			System.err.println("# of gold relations whose arguments are close: "+ closeGoldRelationCount);
 			//do closure on gold, but not on system, to calculate precision
-			evaluation.skipTrain = true;
-			recallModeEvaluation = false;
-			params.stats = evaluation.trainAndTest(training, testing);//training);//
-			//      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;
-			params.stats = evaluation.trainAndTest(training, testing);//training);//
-			//      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);
+//			evaluation.skipTrain = true;
+//			recallModeEvaluation = false;
+//			params.stats = evaluation.trainAndTest(training, testing);//training);//
+//			//      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;
+//			params.stats = evaluation.trainAndTest(training, testing);//training);//
+//			//      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 
@@ -294,6 +310,9 @@ EvaluationOfTemporalRelations_ImplBase{
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(Overlap2Contains.class));
 
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveEventEventRelations.class));
+		
+		//count how many sentences have timex, and how many sentences have only one timex
+		//aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(CountSentenceContainsTimes.class));
 
 		//add unlabeled nearby system events as potential links: 
 		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(AddPotentialRelations.class));
@@ -345,6 +364,7 @@ EvaluationOfTemporalRelations_ImplBase{
 	@Override
 	protected AnnotationStatistics<String> test(CollectionReader collectionReader, File directory)
 			throws Exception {
+		this.useClosure=false;//don't do closure for test
 		AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
 		aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class, TimeMention.class));
 
@@ -367,10 +387,13 @@ EvaluationOfTemporalRelations_ImplBase{
 				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) :
 			EventTimeSelfRelationAnnotator.createEngineDescription(new File(directory,"event-time")));
+		
+		//count how many system predicted relations, their arguments are close to each other, without any other event in between
+		aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(CountCloseRelation.class));
 
 		if(this.i2b2Output != null){
 			aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(WriteI2B2XML.class, WriteI2B2XML.PARAM_OUTPUT_DIR, this.i2b2Output), "TimexView", CAS.NAME_DEFAULT_SOFA);
@@ -791,7 +814,102 @@ EvaluationOfTemporalRelations_ImplBase{
 			}
 		}
 	}
+	/**
+	public static class CountSentenceContainsTimes extends JCasAnnotator_ImplBase {
+
+		public static final String PARAM_SENTENCE_VIEW = "SentenceView";
+
+		@ConfigurationParameter(name = PARAM_SENTENCE_VIEW,mandatory=false)
+		private String sentenceViewName = CAS.NAME_DEFAULT_SOFA;
+
+		public static final String PARAM_RELATION_VIEW = "RelationView";
+
+		@ConfigurationParameter(name = PARAM_RELATION_VIEW,mandatory=false)
+		private String relationViewName = CAS.NAME_DEFAULT_SOFA;
+
+		@Override
+		public void process(JCas jCas) throws AnalysisEngineProcessException {
+			JCas sentenceView, relationView;
+			try {
+				sentenceView = jCas.getView(this.sentenceViewName);
+				relationView = jCas.getView(this.relationViewName);
+			} catch (CASException e) {
+				throw new AnalysisEngineProcessException(e);
+			}
+
+			//count how many sentences have timex, and how many sentences have only one timex
+			for (Sentence sentence : JCasUtil.select(sentenceView, Sentence.class)) {
+				List<TimeMention> tmentions = JCasUtil.selectCovered(relationView, TimeMention.class, sentence);
+				int timeCount = tmentions==null? 0: tmentions.size();
+				if(timeCount > 0){
+					sentHasTimeCount ++;
+					if(timeCount == 1){
+						sentHasOneTimeCount ++;
+					}
+				}
+			}
+		}
+	}*/
+	
+	public static class CountCloseRelation extends JCasAnnotator_ImplBase {
+
+		private String systemViewName = CAS.NAME_DEFAULT_SOFA;
+		
+		@Override
+		public void process(JCas jCas) throws AnalysisEngineProcessException {
+			JCas systemView, goldView;
+			int sizeLimit = 6;
+			try {
+				systemView = jCas.getView(this.systemViewName);
+				goldView = jCas.getView(GOLD_VIEW_NAME);
+			} catch (CASException e) {
+				throw new AnalysisEngineProcessException(e);
+			}
+
+			//count how many sentences have timex, and how many sentences have only one timex
+			for (TemporalTextRelation relation : JCasUtil.select(systemView, TemporalTextRelation.class)) {
+				sysRelationCount ++;
+				Annotation arg1 = relation.getArg1().getArgument();
+				Annotation arg2 = relation.getArg2().getArgument();
+				if( arg1.getBegin()> arg2.getBegin()){
+					Annotation temp = arg1;
+					arg1 = arg2;
+					arg2 = temp;
+				}
+				List<WordToken> words = JCasUtil.selectBetween(systemView, WordToken.class, arg1, arg2);
+				if(words.size()<sizeLimit){
+					closeRelationCount++;
+				}
+			}
+			
+			Map<List<Annotation>, TemporalTextRelation> relationLookup = new HashMap<>();
+			for (TemporalTextRelation relation : Lists.newArrayList(JCasUtil.select(goldView, TemporalTextRelation.class))) {
+				Annotation arg1 = relation.getArg1().getArgument();
+				Annotation arg2 = relation.getArg2().getArgument();
+				// 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)){
+					relationLookup.put(key, relation);
+				}
+			}
 
+			//count how many sentences have timex, and how many sentences have only one timex
+			for (TemporalTextRelation relation : relationLookup.values()) {
+				goldRelationCount ++;
+				Annotation arg1 = relation.getArg1().getArgument();
+				Annotation arg2 = relation.getArg2().getArgument();
+				if( arg1.getBegin()> arg2.getBegin()){
+					Annotation temp = arg1;
+					arg1 = arg2;
+					arg2 = temp;
+				}
+				List<WordToken> words = JCasUtil.selectBetween(systemView, WordToken.class, arg1, arg2);
+				if(words.size()<sizeLimit){
+					closeGoldRelationCount++;
+				}
+			}
+		}
+	}
 
 	public static class RemoveRelations extends JCasAnnotator_ImplBase {
 		@Override
@@ -1027,12 +1145,23 @@ EvaluationOfTemporalRelations_ImplBase{
 	 *
 	 */
 	public static class Overlap2Contains extends JCasAnnotator_ImplBase {
+		
+		public static final String PARAM_RELATION_VIEW = "RelationView";
+
+		@ConfigurationParameter(name = PARAM_RELATION_VIEW,mandatory=false)
+		private String relationViewName = CAS.NAME_DEFAULT_SOFA;
 
 		@Override
 		public void process(JCas jCas) throws AnalysisEngineProcessException {
+			JCas relationView;
+			try {
+				relationView = jCas.getView(this.relationViewName);
+			} catch (CASException e) {
+				throw new AnalysisEngineProcessException(e);
+			}
 			Map<List<Annotation>, BinaryTextRelation> relationLookup;
 			relationLookup = new HashMap<>();
-			for (BinaryTextRelation relation : JCasUtil.select(jCas, BinaryTextRelation.class)) {
+			for (BinaryTextRelation relation : Lists.newArrayList(JCasUtil.select(relationView, BinaryTextRelation.class))) {
 				Annotation arg1 = relation.getArg1().getArgument();
 				Annotation arg2 = relation.getArg2().getArgument();
 				String relationType = relation.getCategory();
@@ -1042,16 +1171,39 @@ EvaluationOfTemporalRelations_ImplBase{
 					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") ){
+						if(relationType.startsWith("OVERLAP") ){//current relation is too general, remove it
+							relation.getArg1().removeFromIndexes();
+							relation.getArg2().removeFromIndexes();
+							relation.removeFromIndexes();
+						}else if( reln.startsWith("OVERLAP") ){//stored relation is too general, remove it
 							//remove duplicate:
-							storedRel.setCategory(relationType);
+							storedRel.getArg1().removeFromIndexes();
+							storedRel.getArg2().removeFromIndexes();
+							storedRel.removeFromIndexes();
+							relationLookup.put(key, relation);
+						}else if(relationType.startsWith("CONTAINS")){//contain is dominant
+							storedRel.getArg1().removeFromIndexes();
+							storedRel.getArg2().removeFromIndexes();
+							storedRel.removeFromIndexes(jCas);
+							relationLookup.put(key, relation);
+						}else if(reln.startsWith("CONTAINS")){
+							relation.getArg1().removeFromIndexes();
+							relation.getArg2().removeFromIndexes();
+							relation.removeFromIndexes(jCas);
+						}else{
+							relation.getArg1().removeFromIndexes();
+							relation.getArg2().removeFromIndexes();
+							relation.removeFromIndexes();
 						}
+					}else{//if there is no conflicting, remove duplicating relations
+						relation.getArg1().removeFromIndexes();
+						relation.getArg2().removeFromIndexes();
+						relation.removeFromIndexes(jCas);
 					}
+				}else{//if the relation is new, then added it to lookup
+					relationLookup.put(key, relation);
 				}
-				relationLookup.put(key, relation);
+				
 			}
 
 		}

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfI2B2TemporalRelations.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfI2B2TemporalRelations.java?rev=1677203&r1=1677202&r2=1677203&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfI2B2TemporalRelations.java (original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfI2B2TemporalRelations.java Fri May  1 18:30:30 2015
@@ -46,7 +46,7 @@ import org.apache.ctakes.temporal.ae.bas
 import org.apache.ctakes.temporal.eval.EvaluationOfEventEventThymeRelations.AddEEPotentialRelations;
 import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.AddPotentialRelations;
 import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.ParameterSettings;
-import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations_ImplBase.RemoveNonContainsRelations.RemoveGoldAttributes;
+import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations_ImplBase.RemoveGoldAttributes;
 import org.apache.ctakes.temporal.utils.AnnotationIdCollection;
 import org.apache.ctakes.temporal.utils.TLinkTypeArray2;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfSelfEventTimeRelations.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfSelfEventTimeRelations.java?rev=1677203&r1=1677202&r2=1677203&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfSelfEventTimeRelations.java (original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfSelfEventTimeRelations.java Fri May  1 18:30:30 2015
@@ -43,7 +43,7 @@ import org.apache.ctakes.temporal.ae.Eve
 //import org.apache.ctakes.temporal.ae.EventEventRelationAnnotator;
 import org.apache.ctakes.temporal.ae.baselines.RecallBaselineEventTimeRelationAnnotator;
 import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.ParameterSettings;
-import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations_ImplBase.RemoveNonContainsRelations.RemoveGoldAttributes;
+import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations_ImplBase.RemoveGoldAttributes;
 //import org.apache.ctakes.temporal.eval.Evaluation_ImplBase.WriteI2B2XML;
 //import org.apache.ctakes.temporal.eval.Evaluation_ImplBase.XMLFormat;
 import org.apache.ctakes.temporal.utils.AnnotationIdCollection;

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java?rev=1677203&r1=1677202&r2=1677203&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java (original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java Fri May  1 18:30:30 2015
@@ -128,30 +128,32 @@ Evaluation_ImplBase<AnnotationStatistics
 			for (BinaryTextRelation relation : Lists.newArrayList(JCasUtil.select(
 					relationView,
 					BinaryTextRelation.class))) {
-				if (!relation.getCategory().startsWith("CONTAINS")) {
+				RelationArgument arg1 = relation.getArg1();
+				RelationArgument arg2 = relation.getArg2();
+				if (arg1.getArgument()instanceof EventMention && arg2.getArgument()instanceof EventMention && !relation.getCategory().startsWith("CONTAINS")) {
 					relation.getArg1().removeFromIndexes();
 					relation.getArg2().removeFromIndexes();
 					relation.removeFromIndexes();
 				}
 			}
 		}
-
-		public static class RemoveGoldAttributes extends JCasAnnotator_ImplBase {
-			@Override
-			public void process(JCas jCas) throws AnalysisEngineProcessException {
-				for(EventMention event : JCasUtil.select(jCas, EventMention.class)){
-					if(event.getEvent() != null && event.getEvent().getProperties() != null){
-						event.getEvent().getProperties().setContextualAspect("UNK");
-						event.getEvent().getProperties().setContextualModality("UNK");
-					}
-				}
-				for(TimeMention timex : JCasUtil.select(jCas, TimeMention.class)){
-					timex.setTimeClass("UNK");
+	}
+	public static class RemoveGoldAttributes extends JCasAnnotator_ImplBase {
+		@Override
+		public void process(JCas jCas) throws AnalysisEngineProcessException {
+			for(EventMention event : JCasUtil.select(jCas, EventMention.class)){
+				if(event.getEvent() != null && event.getEvent().getProperties() != null){
+					event.getEvent().getProperties().setContextualAspect("UNK");
+					event.getEvent().getProperties().setContextualModality("UNK");
 				}
 			}
+			for(TimeMention timex : JCasUtil.select(jCas, TimeMention.class)){
+				timex.setTimeClass("UNK");
+			}
 		}
 	}
 
+
 	protected static Collection<BinaryTextRelation> correctArgOrder(
 			Collection<BinaryTextRelation> systemRelations,
 			Collection<BinaryTextRelation> goldRelations) {



Mime
View raw message