ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1560837 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis: EventContextAnalysisPipeline.java EventPrinterPipeline.java
Date Thu, 23 Jan 2014 22:43:00 GMT
Author: tmill
Date: Thu Jan 23 22:43:00 2014
New Revision: 1560837

URL: http://svn.apache.org/r1560837
Log:
CTAKES-280: Fixes option handling for temporal data analysis package.

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventContextAnalysisPipeline.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventPrinterPipeline.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventContextAnalysisPipeline.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventContextAnalysisPipeline.java?rev=1560837&r1=1560836&r2=1560837&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventContextAnalysisPipeline.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventContextAnalysisPipeline.java
Thu Jan 23 22:43:00 2014
@@ -35,8 +35,6 @@ import org.apache.uima.cas.CASException;
 import org.apache.uima.collection.CollectionReader;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.tcas.Annotation;
-import org.cleartk.util.Options_ImplBase;
-import org.kohsuke.args4j.Option;
 import org.uimafit.component.JCasAnnotator_ImplBase;
 import org.uimafit.descriptor.ConfigurationParameter;
 import org.uimafit.factory.AnalysisEngineFactory;
@@ -44,6 +42,9 @@ import org.uimafit.factory.CollectionRea
 import org.uimafit.pipeline.SimplePipeline;
 import org.uimafit.util.JCasUtil;
 
+import com.lexicalscope.jewel.cli.CliFactory;
+import com.lexicalscope.jewel.cli.Option;
+
 /**
  * Print events and tokens with contexts to two separeate files.
  * 
@@ -51,49 +52,41 @@ import org.uimafit.util.JCasUtil;
  */
 public class EventContextAnalysisPipeline {
 
-  public static class Options extends Options_ImplBase {
+  static interface Options {
 
     @Option(
-        name = "--input-dir",
-        usage = "specify the path to the directory containing the clinical notes to be processed",
-        required = true)
-    public File inputDirectory;
+        description = "specify the path to the directory containing the clinical notes to
be processed")
+    public File getInputDirectory();
 
     @Option(
-        name = "--token-output-file",
-        usage = "specify the path to the directory containing the clinical notes to be processed",
-        required = true)
-    public File tokenOutputFile;
+        description = "specify the path to the directory containing the clinical notes to
be processed")
+    public File getTokenOutputFile();
 
     @Option(
-        name = "--event-output-file",
-        usage = "specify the path to the directory containing the clinical notes to be processed",
-        required = true)
-    public File eventOutputFile;
+        description = "specify the path to the directory containing the clinical notes to
be processed")
+    public File getEventOutputFile();
     
     @Option(
-        name = "--context-size",
-        usage = "specify the number of characters to include on both sides",
-        required = false)
-    public int contextSize = 50;
+        description = "specify the number of characters to include on both sides",
+        defaultValue="50")
+    public int getContextSize();
   }
   
 	public static void main(String[] args) throws Exception {
 		
-		Options options = new Options();
-		options.parseOptions(args);
+		Options options = CliFactory.parseArguments(Options.class, args);
 
-		List<File> trainFiles = Arrays.asList(options.inputDirectory.listFiles());
+		List<File> trainFiles = Arrays.asList(options.getInputDirectory().listFiles());
     CollectionReader collectionReader = getCollectionReader(trainFiles);
 		
     AnalysisEngine annotationConsumer = AnalysisEngineFactory.createPrimitive(
     		EventAndTokenContextWriter.class,
     		"TokenOutputFile",
-    		options.tokenOutputFile,
+    		options.getTokenOutputFile(),
     		"EventOutputFile",
-    		options.eventOutputFile,
+    		options.getEventOutputFile(),
     		"ContextSize",
-    		options.contextSize);
+    		options.getContextSize());
     		
 		SimplePipeline.runPipeline(collectionReader, annotationConsumer);
 	}

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventPrinterPipeline.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventPrinterPipeline.java?rev=1560837&r1=1560836&r2=1560837&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventPrinterPipeline.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventPrinterPipeline.java
Thu Jan 23 22:43:00 2014
@@ -32,7 +32,6 @@ import java.util.Map;
 import org.apache.ctakes.relationextractor.eval.XMIReader;
 import org.apache.ctakes.typesystem.type.syntax.TerminalTreebankNode;
 import org.apache.ctakes.typesystem.type.syntax.TreebankNode;
-import org.apache.ctakes.typesystem.type.textsem.EntityMention;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
 import org.apache.uima.analysis_engine.AnalysisEngine;
@@ -40,8 +39,6 @@ import org.apache.uima.analysis_engine.A
 import org.apache.uima.cas.CASException;
 import org.apache.uima.collection.CollectionReader;
 import org.apache.uima.jcas.JCas;
-import org.cleartk.util.Options_ImplBase;
-import org.kohsuke.args4j.Option;
 import org.uimafit.component.JCasAnnotator_ImplBase;
 import org.uimafit.descriptor.ConfigurationParameter;
 import org.uimafit.factory.AnalysisEngineFactory;
@@ -52,6 +49,8 @@ import org.uimafit.util.JCasUtil;
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
 import com.google.common.collect.Ordering;
+import com.lexicalscope.jewel.cli.CliFactory;
+import com.lexicalscope.jewel.cli.Option;
 
 /**
  * Print events of given UMLS semantic type.
@@ -60,41 +59,34 @@ import com.google.common.collect.Orderin
  */
 public class EventPrinterPipeline {
 
-  public static class Options extends Options_ImplBase {
+  static interface Options {
 
     @Option(
-        name = "--input-dir",
-        usage = "specify the path to the directory containing the xmi files",
-        required = true)
-    public File inputDirectory;
+        description = "specify the path to the directory containing the xmi files")
+    public File getInputDirectory();
 
     @Option(
-        name = "--umls-type",
-        usage = "specify the UMLS semantic type (e.g. 5, i.e. procedure)",
-        required = true)
-    public int umlsSemanticType;
+        description = "specify the UMLS semantic type (e.g. 5, i.e. procedure)")
+    public int getUmlsSemanticType();
 
     @Option(
-        name = "--event-output-file",
-        usage = "specify the path to the output file",
-        required = true)
-    public File eventOutputFile;
+        description = "specify the path to the output file")
+    public File getEventOutputFile();
   }
   
 	public static void main(String[] args) throws Exception {
 		
-		Options options = new Options();
-		options.parseOptions(args);
+		Options options = CliFactory.parseArguments(Options.class, args);
 
-		List<File> trainFiles = Arrays.asList(options.inputDirectory.listFiles());
+		List<File> trainFiles = Arrays.asList(options.getInputDirectory().listFiles());
     CollectionReader collectionReader = getCollectionReader(trainFiles);
 		
     AnalysisEngine annotationConsumer = AnalysisEngineFactory.createPrimitive(
     		EventWriter.class,
     		"UmlsSemanticType",
-    		options.umlsSemanticType,
+    		options.getUmlsSemanticType(),
     		"EventOutputFile",
-    		options.eventOutputFile);
+    		options.getEventOutputFile());
     		
 		SimplePipeline.runPipeline(collectionReader, annotationConsumer);
 	}



Mime
View raw message