ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevenbeth...@apache.org
Subject svn commit: r1563350 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal: ae/THYMEAnaforaXMLReader.java eval/EvaluationOfEventEventRelations.java eval/Evaluation_ImplBase.java
Date Fri, 31 Jan 2014 23:54:34 GMT
Author: stevenbethard
Date: Fri Jan 31 23:54:34 2014
New Revision: 1563350

URL: http://svn.apache.org/r1563350
Log:
Modifies temporal Evaluation_ImplBase so that the text directory does not need to be specified
when Anafora format is used. (The text will be taken from the Anafora directories.)

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEAnaforaXMLReader.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/Evaluation_ImplBase.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEAnaforaXMLReader.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEAnaforaXMLReader.java?rev=1563350&r1=1563349&r2=1563350&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEAnaforaXMLReader.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEAnaforaXMLReader.java
Fri Jan 31 23:54:34 2014
@@ -55,6 +55,8 @@ public class THYMEAnaforaXMLReader exten
       description = "list of suffixes that might be added to a file name to identify the
Anafora "
           + "XML annotations file; only the first suffix corresponding to a file will be
used")
   private String[] anaforaXMLSuffixes = new String[] {
+      ".Gold_Temporal_Entities.xml",
+      ".Gold_Temporal_Relations.xml",
       ".temporal.Temporal-Adjudication.gold.completed.xml",
       ".temporal.Temporal-Entities.gold.completed.xml",
       ".Temporal-Entity.gold.completed.xml",

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=1563350&r1=1563349&r2=1563350&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
Fri Jan 31 23:54:34 2014
@@ -12,7 +12,6 @@ import org.apache.ctakes.relationextract
 import org.apache.ctakes.temporal.ae.EventEventRelationAnnotator;
 import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.ParameterSettings;
 import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.RemoveCrossSentenceRelations;
-import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.RemoveNonContainsRelations;
 import org.apache.ctakes.temporal.eval.EvaluationOfEventTimeRelations.RemoveRelations;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;

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=1563350&r1=1563349&r2=1563350&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
Fri Jan 31 23:54:34 2014
@@ -24,8 +24,9 @@ import java.io.FileOutputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -60,6 +61,7 @@ import org.apache.ctakes.typesystem.type
 import org.apache.ctakes.typesystem.type.textspan.LookupWindowAnnotation;
 import org.apache.ctakes.typesystem.type.textspan.Segment;
 import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import org.apache.log4j.Logger;
 import org.apache.uima.UIMAException;
 import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_engine.AnalysisEngine;
@@ -100,13 +102,15 @@ import com.lexicalscope.jewel.cli.Option
 public abstract class Evaluation_ImplBase<STATISTICS_TYPE> extends
     org.cleartk.eval.Evaluation_ImplBase<Integer, STATISTICS_TYPE> {
 
+  private static Logger LOGGER = Logger.getLogger(Evaluation_ImplBase.class);
+
   public static final String GOLD_VIEW_NAME = "GoldView";
   
   enum XMLFormat { Knowtator, Anafora }
 
   static interface Options {
 
-    @Option(longName = "text")
+    @Option(longName = "text", defaultToNull = true)
     public File getRawTextDirectory();
 
     @Option(longName = "xml")
@@ -194,10 +198,28 @@ public abstract class Evaluation_ImplBas
   }
   
   private List<File> getFilesFor(List<Integer> patientSets) {
-	  if ( !rawTextDirectory.exists() ) {
-		  return Collections.emptyList();
-	  }
 	  List<File> files = new ArrayList<File>();
+		if (this.rawTextDirectory == null
+				&& this.xmlFormat == XMLFormat.Anafora) {
+			for (File dir : this.xmlDirectory.listFiles()) {
+        Set<String> ids = new HashSet<String>();
+        for (Integer set : patientSets) {
+          ids.add(String.format("ID%03d", set));
+        }
+				if (dir.isDirectory()) {
+          if (ids.contains(dir.getName().substring(0, 5))) {
+            File file = new File(dir, dir.getName());
+            if (file.exists()) {
+              files.add(file);
+            } else {
+              LOGGER.warn("Missing note: " + file);
+            }
+          } else {
+            LOGGER.info("Skipping note: " + dir);
+          }
+				}
+			}
+		} else {
 	  for (Integer set : patientSets) {
 		  final int setNum = set;
 		  for (File file : rawTextDirectory.listFiles(new FilenameFilter(){
@@ -221,7 +243,8 @@ public abstract class Evaluation_ImplBas
 			  } 
 		  }
 	  }
-	  return files;
+    }
+    return files;
   }
 
   @Override



Mime
View raw message