incubator-ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevenbeth...@apache.org
Subject svn commit: r1424651 - /incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEKnowtatorXMLReader.java
Date Thu, 20 Dec 2012 19:41:31 GMT
Author: stevenbethard
Date: Thu Dec 20 19:41:30 2012
New Revision: 1424651

URL: http://svn.apache.org/viewvc?rev=1424651&view=rev
Log:
Adds a main method to THYMEKnowtatorXMLReader for easy testing of data for annotation errors.

Modified:
    incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEKnowtatorXMLReader.java

Modified: incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEKnowtatorXMLReader.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEKnowtatorXMLReader.java?rev=1424651&r1=1424650&r2=1424651&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEKnowtatorXMLReader.java
(original)
+++ incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEKnowtatorXMLReader.java
Thu Dec 20 19:41:30 2012
@@ -20,17 +20,27 @@ package org.apache.ctakes.temporal.ae;
 
 import java.io.File;
 import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.ctakes.core.ae.SHARPKnowtatorXMLReader;
+import org.apache.ctakes.temporal.eval.CommandLine;
+import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.collection.CollectionReader;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.cleartk.util.ViewURIUtil;
+import org.cleartk.util.cr.UriCollectionReader;
 import org.uimafit.descriptor.ConfigurationParameter;
 import org.uimafit.factory.AnalysisEngineFactory;
+import org.uimafit.pipeline.SimplePipeline;
+
+import com.lexicalscope.jewel.cli.CliFactory;
+import com.lexicalscope.jewel.cli.Option;
 
 public class THYMEKnowtatorXMLReader extends SHARPKnowtatorXMLReader {
 
@@ -71,4 +81,35 @@ public class THYMEKnowtatorXMLReader ext
     return new String[] { "consensus set annotator team", "consensus set_rel annotator team"
};
   }
 
+  private static interface Options {
+
+    @Option(longName = "text")
+    public File getRawTextDirectory();
+
+    @Option(longName = "xml")
+    public File getKnowtatorXMLDirectory();
+
+    @Option(longName = "patients")
+    public CommandLine.IntegerRanges getPatients();
+  }
+
+  /**
+   * Just runs reader over files. Useful primarily for debugging annotations.
+   */
+  public static void main(String[] args) throws Exception {
+    Options options = CliFactory.parseArguments(Options.class, args);
+    List<File> files = new ArrayList<File>();
+    for (Integer set : options.getPatients().getList()) {
+      File setTextDirectory = new File(options.getRawTextDirectory(), "doc" + set);
+      for (File file : setTextDirectory.listFiles()) {
+        files.add(file);
+      }
+    }
+    CollectionReader reader = UriCollectionReader.getCollectionReaderFromFiles(files);
+    AnalysisEngine engine = AnalysisEngineFactory.createPrimitive(
+        THYMEKnowtatorXMLReader.class,
+        THYMEKnowtatorXMLReader.PARAM_KNOWTATOR_XML_DIRECTORY,
+        options.getKnowtatorXMLDirectory());
+    SimplePipeline.runPipeline(reader, engine);
+  }
 }



Mime
View raw message