ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1481308 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal: ae/EventEventRelationAnnotator.java eval/EvaluationOfEventEventRelations.java eval/EvaluationOfTemporalRelations_ImplBase.java
Date Sat, 11 May 2013 12:06:44 GMT
Author: tmill
Date: Sat May 11 12:06:44 2013
New Revision: 1481308

URL: http://svn.apache.org/r1481308
Log:
Uncommented classes and fixed to not depend on outside packages.

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/eval/EvaluationOfEventEventRelations.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/ae/EventEventRelationAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java?rev=1481308&r1=1481307&r2=1481308&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
Sat May 11 12:06:44 2013
@@ -10,7 +10,6 @@ import org.apache.ctakes.relationextract
 import org.apache.ctakes.relationextractor.ae.features.PartOfSpeechFeaturesExtractor;
 import org.apache.ctakes.relationextractor.ae.features.RelationFeaturesExtractor;
 import org.apache.ctakes.relationextractor.ae.features.TokenFeaturesExtractor;
-import org.apache.ctakes.temporal.ae.feature.TemporalAttributeFeatureExtractor;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventRelations.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventRelations.java?rev=1481308&r1=1481307&r2=1481308&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventRelations.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventRelations.java
Sat May 11 12:06:44 2013
@@ -1,4 +1,4 @@
-/*package org.apache.ctakes.temporal.eval;
+package org.apache.ctakes.temporal.eval;
 
 import java.io.File;
 import java.net.URI;
@@ -9,14 +9,9 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.ctakes.relationextractor.eval.RelationExtractorEvaluation.HashableArguments;
+import org.apache.ctakes.relationextractor.eval.RelationExtractorEvaluation.ParameterSettings;
 import org.apache.ctakes.temporal.ae.EventEventRelationAnnotator;
-import org.apache.ctakes.temporal.ae.EventTimeRelationAnnotator;
-import org.apache.ctakes.temporal.ae.baselines.RecallBaselineEventTimeRelationAnnotator;
-import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations.AddTransitiveContainsRelations;
-import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations.ParameterSettings;
-import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations.PreserveEventEventRelations;
 import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations.RemoveCrossSentenceRelations;
-import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations.RemoveEventEventRelations;
 import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations.RemoveNonContainsRelations;
 import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations.RemoveRelations;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
@@ -43,177 +38,170 @@ import com.google.common.collect.Sets;
 import com.lexicalscope.jewel.cli.CliFactory;
 
 public class EvaluationOfEventEventRelations extends
-		EvaluationOfTemporalRelations_ImplBase {
+EvaluationOfTemporalRelations_ImplBase {
 
-	public EvaluationOfEventEventRelations(      
-			  File baseDirectory,
-		      File rawTextDirectory,
-		      File knowtatorXMLDirectory,
-		      File xmiDirectory,
-		      File treebankDirectory,
-		      boolean useClosure,
-		      boolean printErrors,
-		      boolean printRelations,
-		      boolean baseline,
-		      String kernelParams,
-		      ParameterSettings params){
-		super(baseDirectory, rawTextDirectory, knowtatorXMLDirectory, xmiDirectory,
-				treebankDirectory, printErrors, printRelations, params);
-		
-	}
-
-	@Override
-	protected void train(CollectionReader collectionReader, File directory)
-			throws Exception {
-	    AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
-	    aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class, TimeMention.class,
BinaryTextRelation.class));
-//	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(MergeContainsOverlap.class));
-	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNonContainsRelations.class));
-	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveCrossSentenceRelations.class));
-	    // TODO -- see if this applies to this relation:
-//	    if (this.useClosure) {
-//	      aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveContainsRelations.class));
-//	    }
-	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(PreserveEventEventRelations.class));
-	    aggregateBuilder.add(EventEventRelationAnnotator.createDataWriterDescription(
-	                LIBSVMStringOutcomeDataWriter.class,
-//	        TKSVMlightStringOutcomeDataWriter.class,
-	        directory,
-	        params.probabilityOfKeepingANegativeExample));
-	    SimplePipeline.runPipeline(collectionReader, aggregateBuilder.createAggregate());
-
-	    HideOutput hider = new HideOutput();
-	    JarClassifierBuilder.trainAndPackage(directory,  "-t", "2", "-d", "2", "-c", "10");
-	    hider.restoreOutput();
-	    hider.close();
-	}
-
-	@Override
-	protected AnnotationStatistics<String> test(
-			CollectionReader collectionReader, File directory) throws Exception {
-	    AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
-	    aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class, TimeMention.class));
-//	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(MergeContainsOverlap.class,
-//	    		MergeContainsOverlap.PARAM_RELATION_VIEW,
-//	    		GOLD_VIEW_NAME));
-	    aggregateBuilder.add(
-	        AnalysisEngineFactory.createPrimitiveDescription(RemoveNonContainsRelations.class,
-	        RemoveNonContainsRelations.PARAM_RELATION_VIEW,
-	        GOLD_VIEW_NAME));
-	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(
-	        RemoveCrossSentenceRelations.class,
-	        RemoveCrossSentenceRelations.PARAM_SENTENCE_VIEW,
-	        CAS.NAME_DEFAULT_SOFA,
-	        RemoveCrossSentenceRelations.PARAM_RELATION_VIEW,
-	        GOLD_VIEW_NAME));
-	    // TODO - use if relevant.
-//	    if (this.useClosure) {
-//	      aggregateBuilder.add(
-//	          AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveContainsRelations.class),
-//	          CAS.NAME_DEFAULT_SOFA,
-//	          GOLD_VIEW_NAME);
-//	    }
-	    aggregateBuilder.add(
-	        AnalysisEngineFactory.createPrimitiveDescription(PreserveEventEventRelations.class),
-	        CAS.NAME_DEFAULT_SOFA,
-	        GOLD_VIEW_NAME);
-	    		
-	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveRelations.class));
-	    // TODO -- if we implement a baseline
-//	    aggregateBuilder.add(this.baseline ? RecallBaselineEventTimeRelationAnnotator.createAnnotatorDescription(directory)
:
-//	    	EventTimeRelationAnnotator.createAnnotatorDescription(directory));
-	    aggregateBuilder.add(
-	    	EventEventRelationAnnotator.createAnnotatorDescription(directory));
-
-	    Function<BinaryTextRelation, ?> getSpan = new Function<BinaryTextRelation,
HashableArguments>() {
-	      public HashableArguments apply(BinaryTextRelation relation) {
-	        return new HashableArguments(relation);
-	      }
-	    };
-	    Function<BinaryTextRelation, String> getOutcome = AnnotationStatistics.annotationToFeatureValue("category");
-
-	    AnnotationStatistics<String> stats = new AnnotationStatistics<String>();
-	   	JCasIterable jcasIter =new JCasIterable(collectionReader, aggregateBuilder.createAggregate());
-	    JCas jCas = null;
-	   	while(jcasIter.hasNext()) {
-	      jCas = jcasIter.next();
-	      JCas goldView = jCas.getView(GOLD_VIEW_NAME);
-	      JCas systemView = jCas.getView(CAS.NAME_DEFAULT_SOFA);
-	      Collection<BinaryTextRelation> goldRelations = JCasUtil.select(
-	          goldView,
-	          BinaryTextRelation.class);
-	      Collection<BinaryTextRelation> systemRelations = JCasUtil.select(
-	          systemView,
-	          BinaryTextRelation.class);
-	      stats.add(goldRelations, systemRelations, getSpan, getOutcome);
-	      if(this.printRelations){
-	    	  URI uri = ViewURIUtil.getURI(jCas);
-	    	  String[] path = uri.getPath().split("/");
-	    	  printRelationAnnotations(path[path.length - 1], systemRelations);
-	      }
-	      if(this.printErrors){
-	    	  Map<HashableArguments, BinaryTextRelation> goldMap = Maps.newHashMap();
-	    	  for (BinaryTextRelation relation : goldRelations) {
-	    		  goldMap.put(new HashableArguments(relation), relation);
-	    	  }
-	    	  Map<HashableArguments, BinaryTextRelation> systemMap = Maps.newHashMap();
-	    	  for (BinaryTextRelation relation : systemRelations) {
-	    		  systemMap.put(new HashableArguments(relation), relation);
-	    	  }
-	    	  Set<HashableArguments> all = Sets.union(goldMap.keySet(), systemMap.keySet());
-	    	  List<HashableArguments> sorted = Lists.newArrayList(all);
-	    	  Collections.sort(sorted);
-	    	  for (HashableArguments key : sorted) {
-	    		  BinaryTextRelation goldRelation = goldMap.get(key);
-	    		  BinaryTextRelation systemRelation = systemMap.get(key);
-	    		  if (goldRelation == null) {
-	    			  System.out.println("System added: " + formatRelation(systemRelation));
-	    		  } else if (systemRelation == null) {
-	    			  System.out.println("System dropped: " + formatRelation(goldRelation));
-	    		  } else if (!systemRelation.getCategory().equals(goldRelation.getCategory())) {
-	    			  String label = systemRelation.getCategory();
-	    			  System.out.printf("System labeled %s for %s\n", label, formatRelation(goldRelation));
-	    		  } else{
-	    			  System.out.println("Nailed it! " + formatRelation(systemRelation));
-	    		  }
-	    	  }
-	      }
-	    }
-	    return stats;
-	}
-
-	public static void main(String[] args) throws Exception{
-	    TempRelOptions options = CliFactory.parseArguments(TempRelOptions.class, args);
-	    List<Integer> patientSets = options.getPatients().getList();
-	    List<Integer> trainItems = THYMEData.getTrainPatientSets(patientSets);
-	    List<Integer> devItems = THYMEData.getDevPatientSets(patientSets);
-	    List<Integer> testItems = THYMEData.getTestPatientSets(patientSets);
-  	  	File workingDir = new File("target/eval/temporal-relations/event-event/");
-  	  	ParameterSettings params = defaultParams;
-        EvaluationOfEventEventRelations evaluation = new EvaluationOfEventEventRelations(
-  			  workingDir,
-  			  options.getRawTextDirectory(),
-  			  options.getKnowtatorXMLDirectory(),
-  			  options.getXMIDirectory(),
-  			  options.getTreebankDirectory(),
-  			  options.getClosure(),
-  			  options.getPrintErrors(),
-  			  options.getPrintFormattedRelations(),
-  			  options.getBaseline(),
-  			  options.getKernelParams(),
-  			  params);
-  	  evaluation.prepareXMIsFor(patientSets);
-  	  List<Integer> training = trainItems;
-  	  List<Integer> testing = null;
-  	  if(options.getTest()){
-  		  training.addAll(devItems);
-  		  testing = testItems;
-  	  }else{
-  		  testing = devItems;
-  	  }
-  	  params.stats = evaluation.trainAndTest(training, testing);
-	  System.err.println(params.stats);
-	}
+  public EvaluationOfEventEventRelations(      
+      File baseDirectory,
+      File rawTextDirectory,
+      File knowtatorXMLDirectory,
+      File xmiDirectory,
+      File treebankDirectory,
+      boolean printErrors,
+      boolean printRelations,
+      ParameterSettings params){
+    super(baseDirectory, rawTextDirectory, knowtatorXMLDirectory, xmiDirectory,
+        treebankDirectory, printErrors, printRelations, params);
+
+  }
+
+  @Override
+  protected void train(CollectionReader collectionReader, File directory)
+      throws Exception {
+    AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
+    aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class, TimeMention.class,
BinaryTextRelation.class));
+    //	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(MergeContainsOverlap.class));
+    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNonContainsRelations.class));
+    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveCrossSentenceRelations.class));
+    // TODO -- see if this applies to this relation:
+    //	    if (this.useClosure) {
+    //	      aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveContainsRelations.class));
+    //	    }
+    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(PreserveEventEventRelations.class));
+    aggregateBuilder.add(EventEventRelationAnnotator.createDataWriterDescription(
+        LIBSVMStringOutcomeDataWriter.class,
+        //	        TKSVMlightStringOutcomeDataWriter.class,
+        directory,
+        1.0));
+    SimplePipeline.runPipeline(collectionReader, aggregateBuilder.createAggregate());
+
+    HideOutput hider = new HideOutput();
+    JarClassifierBuilder.trainAndPackage(directory,  "-t", "0", "-c", "10");
+    hider.restoreOutput();
+    hider.close();
+  }
+
+  @Override
+  protected AnnotationStatistics<String> test(
+      CollectionReader collectionReader, File directory) throws Exception {
+    AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
+    aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class, TimeMention.class));
+    //	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(MergeContainsOverlap.class,
+    //	    		MergeContainsOverlap.PARAM_RELATION_VIEW,
+    //	    		GOLD_VIEW_NAME));
+    aggregateBuilder.add(
+        AnalysisEngineFactory.createPrimitiveDescription(RemoveNonContainsRelations.class),
+        CAS.NAME_DEFAULT_SOFA,
+        GOLD_VIEW_NAME);
+    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(
+        RemoveCrossSentenceRelations.class,
+        RemoveCrossSentenceRelations.PARAM_SENTENCE_VIEW,
+        CAS.NAME_DEFAULT_SOFA,
+        RemoveCrossSentenceRelations.PARAM_RELATION_VIEW,
+        GOLD_VIEW_NAME));
+    // TODO - use if relevant.
+    //	    if (this.useClosure) {
+    //	      aggregateBuilder.add(
+    //	          AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveContainsRelations.class),
+    //	          CAS.NAME_DEFAULT_SOFA,
+    //	          GOLD_VIEW_NAME);
+    //	    }
+    aggregateBuilder.add(
+        AnalysisEngineFactory.createPrimitiveDescription(PreserveEventEventRelations.class),
+        CAS.NAME_DEFAULT_SOFA,
+        GOLD_VIEW_NAME);
+
+    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveRelations.class));
+    // TODO -- if we implement a baseline
+    //	    aggregateBuilder.add(this.baseline ? RecallBaselineEventTimeRelationAnnotator.createAnnotatorDescription(directory)
:
+    //	    	EventTimeRelationAnnotator.createAnnotatorDescription(directory));
+    aggregateBuilder.add(
+        EventEventRelationAnnotator.createAnnotatorDescription(directory));
+
+    Function<BinaryTextRelation, ?> getSpan = new Function<BinaryTextRelation, HashableArguments>()
{
+      public HashableArguments apply(BinaryTextRelation relation) {
+        return new HashableArguments(relation);
+      }
+    };
+    Function<BinaryTextRelation, String> getOutcome = AnnotationStatistics.annotationToFeatureValue("category");
+
+    AnnotationStatistics<String> stats = new AnnotationStatistics<String>();
+    JCasIterable jcasIter =new JCasIterable(collectionReader, aggregateBuilder.createAggregate());
+    JCas jCas = null;
+    while(jcasIter.hasNext()) {
+      jCas = jcasIter.next();
+      JCas goldView = jCas.getView(GOLD_VIEW_NAME);
+      JCas systemView = jCas.getView(CAS.NAME_DEFAULT_SOFA);
+      Collection<BinaryTextRelation> goldRelations = JCasUtil.select(
+          goldView,
+          BinaryTextRelation.class);
+      Collection<BinaryTextRelation> systemRelations = JCasUtil.select(
+          systemView,
+          BinaryTextRelation.class);
+      stats.add(goldRelations, systemRelations, getSpan, getOutcome);
+      if(this.printRelations){
+        URI uri = ViewURIUtil.getURI(jCas);
+        String[] path = uri.getPath().split("/");
+        printRelationAnnotations(path[path.length - 1], systemRelations);
+      }
+      if(this.printErrors){
+        Map<HashableArguments, BinaryTextRelation> goldMap = Maps.newHashMap();
+        for (BinaryTextRelation relation : goldRelations) {
+          goldMap.put(new HashableArguments(relation), relation);
+        }
+        Map<HashableArguments, BinaryTextRelation> systemMap = Maps.newHashMap();
+        for (BinaryTextRelation relation : systemRelations) {
+          systemMap.put(new HashableArguments(relation), relation);
+        }
+        Set<HashableArguments> all = Sets.union(goldMap.keySet(), systemMap.keySet());
+        List<HashableArguments> sorted = Lists.newArrayList(all);
+        Collections.sort(sorted);
+        for (HashableArguments key : sorted) {
+          BinaryTextRelation goldRelation = goldMap.get(key);
+          BinaryTextRelation systemRelation = systemMap.get(key);
+          if (goldRelation == null) {
+            System.out.println("System added: " + formatRelation(systemRelation));
+          } else if (systemRelation == null) {
+            System.out.println("System dropped: " + formatRelation(goldRelation));
+          } else if (!systemRelation.getCategory().equals(goldRelation.getCategory())) {
+            String label = systemRelation.getCategory();
+            System.out.printf("System labeled %s for %s\n", label, formatRelation(goldRelation));
+          } else{
+            System.out.println("Nailed it! " + formatRelation(systemRelation));
+          }
+        }
+      }
+    }
+    return stats;
+  }
+
+  public static void main(String[] args) throws Exception{
+    TempRelOptions options = CliFactory.parseArguments(TempRelOptions.class, args);
+    List<Integer> patientSets = options.getPatients().getList();
+    List<Integer> trainItems = THYMEData.getTrainPatientSets(patientSets);
+    List<Integer> devItems = THYMEData.getDevPatientSets(patientSets);
+    List<Integer> testItems = THYMEData.getTestPatientSets(patientSets);
+    File workingDir = new File("target/eval/temporal-relations/event-event/");
+    ParameterSettings params = defaultParams;
+    EvaluationOfEventEventRelations evaluation = new EvaluationOfEventEventRelations(
+        workingDir,
+        options.getRawTextDirectory(),
+        options.getKnowtatorXMLDirectory(),
+        options.getXMIDirectory(),
+        options.getTreebankDirectory(),
+        options.getPrintErrors(),
+        options.getPrintFormattedRelations(),
+        params);
+    evaluation.prepareXMIsFor(patientSets);
+    List<Integer> training = trainItems;
+    List<Integer> testing = null;
+    if(options.getTest()){
+      training.addAll(devItems);
+      testing = testItems;
+    }else{
+      testing = devItems;
+    }
+    AnnotationStatistics<String> stats = evaluation.trainAndTest(training, testing);
+    System.err.println(stats);
+  }
 
 }
-*/
\ No newline at end of file

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=1481308&r1=1481307&r2=1481308&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
Sat May 11 12:06:44 2013
@@ -1,15 +1,23 @@
-/*package org.apache.ctakes.temporal.eval;
+package org.apache.ctakes.temporal.eval;
 
 import java.io.File;
 import java.util.Collection;
 
-import org.apache.ctakes.temporal.eval.EvaluationOfTemporalRelations.ParameterSettings;
+import org.apache.ctakes.relationextractor.eval.RelationExtractorEvaluation.ParameterSettings;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
+import org.apache.ctakes.typesystem.type.relation.RelationArgument;
+import org.apache.ctakes.typesystem.type.textsem.EventMention;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.tcas.Annotation;
-import org.cleartk.classifier.tksvmlight.model.CompositeKernel.ComboOperator;
 import org.cleartk.eval.AnnotationStatistics;
+import org.uimafit.component.JCasAnnotator_ImplBase;
+import org.uimafit.descriptor.ConfigurationParameter;
+import org.uimafit.util.JCasUtil;
 
+import com.google.common.collect.Lists;
 import com.lexicalscope.jewel.cli.Option;
 
 public abstract class EvaluationOfTemporalRelations_ImplBase extends
@@ -36,8 +44,8 @@ public abstract class EvaluationOfTempor
 	  protected static double DEFAULT_TK = 0.5;
 	  protected static double DEFAULT_LAMBDA = 0.5;
 	  
-	  protected static ParameterSettings defaultParams = new ParameterSettings(DEFAULT_BOTH_DIRECTIONS,
DEFAULT_DOWNSAMPLE, "linear",
-	  		  DEFAULT_SVM_C, DEFAULT_SVM_G, "polynomial", ComboOperator.SUM, DEFAULT_TK, DEFAULT_LAMBDA);
+	  protected static ParameterSettings defaultParams = null; //new ParameterSettings(DEFAULT_BOTH_DIRECTIONS,
DEFAULT_DOWNSAMPLE, "linear",
+	  		  //DEFAULT_SVM_C, DEFAULT_SVM_G, "polynomial", ComboOperator.SUM, DEFAULT_TK, DEFAULT_LAMBDA);
 
 	  
 	  protected ParameterSettings params = null;
@@ -53,6 +61,28 @@ public abstract class EvaluationOfTempor
 		this.printErrors =  printErrors;
 	}
 
+  public static class PreserveEventEventRelations extends JCasAnnotator_ImplBase {
+    public static final String PARAM_GOLD_VIEW = "GoldView";
+
+    @ConfigurationParameter(name = PARAM_GOLD_VIEW)
+    private String goldViewName = CAS.NAME_DEFAULT_SOFA;
+
+    @Override
+    public void process(JCas jCas) throws AnalysisEngineProcessException {
+      for(BinaryTextRelation relation : Lists.newArrayList(JCasUtil.select(jCas, BinaryTextRelation.class))){
+          RelationArgument arg1 = relation.getArg1();
+          RelationArgument arg2 = relation.getArg2();
+          if(arg1.getArgument() instanceof EventMention && arg2.getArgument() instanceof
EventMention){
+            // these are the kind we keep.
+            continue;
+          }
+          arg1.removeFromIndexes();
+          arg2.removeFromIndexes();
+          relation.removeFromIndexes();
+      }
+    }   
+  }
+
 	  protected static void printRelationAnnotations(String fileName, Collection<BinaryTextRelation>
relations) {
 
 		  for(BinaryTextRelation binaryTextRelation : relations) {
@@ -94,4 +124,3 @@ public abstract class EvaluationOfTempor
 	  }
 
 }
-*/
\ No newline at end of file



Mime
View raw message