ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1560833 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines: EventAndTimeExtractionPipeline.java EventExtractionPipeline.java EventPrintingPipeline.java TimeExtractionPipeline.java
Date Thu, 23 Jan 2014 22:31:36 GMT
Author: tmill
Date: Thu Jan 23 22:31:35 2014
New Revision: 1560833

URL: http://svn.apache.org/r1560833
Log:
Addresses CTAKES-258: Fixes options in ctakes-temporal pipelines.

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventAndTimeExtractionPipeline.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventExtractionPipeline.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventPrintingPipeline.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/TimeExtractionPipeline.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventAndTimeExtractionPipeline.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventAndTimeExtractionPipeline.java?rev=1560833&r1=1560832&r2=1560833&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventAndTimeExtractionPipeline.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventAndTimeExtractionPipeline.java
Thu Jan 23 22:31:35 2014
@@ -50,8 +50,6 @@ import org.apache.ctakes.typesystem.type
 import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.collection.CollectionReader;
-import org.cleartk.util.Options_ImplBase;
-import org.kohsuke.args4j.Option;
 import org.uimafit.component.xwriter.XWriter;
 import org.uimafit.factory.AggregateBuilder;
 import org.uimafit.factory.AnalysisEngineFactory;
@@ -61,6 +59,9 @@ import org.uimafit.factory.TypePrioritie
 import org.uimafit.factory.TypeSystemDescriptionFactory;
 import org.uimafit.pipeline.SimplePipeline;
 
+import com.lexicalscope.jewel.cli.CliFactory;
+import com.lexicalscope.jewel.cli.Option;
+
 /**
  * Given a trained event extraction model, run the event extractor on files in a directory.
  * Save the resulting annotations in XMI files. 
@@ -69,51 +70,44 @@ import org.uimafit.pipeline.SimplePipeli
  */
 public class EventAndTimeExtractionPipeline {
   
-  public static class Options extends Options_ImplBase {
-
-    @Option(
-        name = "--input-dir",
-        usage = "specify the path to the directory containing the clinical notes to be processed",
-        required = true)
-    public String inputDirectory;
-    
-    @Option(
-        name = "--output-dir",
-        usage = "specify the path to the directory where the output xmi files are to be saved",
-        required = true)
-    public String outputDirectory;
+  static interface Options {
+    // FYI: Command should say -i or --inputDirectory now
+    @Option(shortName="i",
+        description = "specify the path to the directory containing the clinical notes to
be processed")
+    public String getInputDirectory();
+    
+    @Option(shortName = "o",
+        description = "specify the path to the directory where the output xmi files are to
be saved")
+    public String getOutputDirectory();
     
     @Option(
-        name = "--event-model-dir",
-        usage = "specify the path to the directory where the trained event model is located",
-        required = false)
-    public String eventModelDirectory = "target/eval/event-spans/train_and_test/";
+        description = "specify the path to the directory where the trained event model is
located",
+        defaultValue="target/eval/event-spans/train_and_test/")
+    public String getEventModelDirectory();
     
     @Option(
-        name = "--time-model-dir",
-        usage = "specify the path to the directory where the trained event model is located",
-        required = false)
-    public String timeModelDirectory = "target/eval/time-spans/train_and_test/seq/";
+        description = "specify the path to the directory where the trained event model is
located",
+        defaultValue="target/eval/time-spans/train_and_test/seq/")
+    public String getTimeModelDirectory();
   }
   
 	public static void main(String[] args) throws Exception {
 		
-		Options options = new Options();
-		options.parseOptions(args);
+		Options options = CliFactory.parseArguments(Options.class, args);
 
 		CollectionReader collectionReader = CollectionReaderFactory.createCollectionReaderFromPath(
 				"../ctakes-core/desc/collection_reader/FilesInDirectoryCollectionReader.xml",
 				FilesInDirectoryCollectionReader.PARAM_INPUTDIR,
-				options.inputDirectory);
+				options.getInputDirectory());
 
 		AggregateBuilder aggregateBuilder = getPreprocessorAggregateBuilder();
-		aggregateBuilder.add(EventAnnotator.createAnnotatorDescription(new File(options.eventModelDirectory)));
-		aggregateBuilder.add(TimeAnnotator.createAnnotatorDescription(new File(options.timeModelDirectory)));
+		aggregateBuilder.add(EventAnnotator.createAnnotatorDescription(new File(options.getEventModelDirectory())));
+		aggregateBuilder.add(TimeAnnotator.createAnnotatorDescription(new File(options.getTimeModelDirectory())));
 		
     AnalysisEngine xWriter = AnalysisEngineFactory.createPrimitive(
         XWriter.class,
         XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
-        options.outputDirectory);
+        options.getOutputDirectory());
 		
     SimplePipeline.runPipeline(
         collectionReader,

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventExtractionPipeline.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventExtractionPipeline.java?rev=1560833&r1=1560832&r2=1560833&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventExtractionPipeline.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventExtractionPipeline.java
Thu Jan 23 22:31:35 2014
@@ -49,8 +49,6 @@ import org.apache.ctakes.typesystem.type
 import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.collection.CollectionReader;
-import org.cleartk.util.Options_ImplBase;
-import org.kohsuke.args4j.Option;
 import org.uimafit.component.xwriter.XWriter;
 import org.uimafit.factory.AggregateBuilder;
 import org.uimafit.factory.AnalysisEngineFactory;
@@ -60,6 +58,9 @@ import org.uimafit.factory.TypePrioritie
 import org.uimafit.factory.TypeSystemDescriptionFactory;
 import org.uimafit.pipeline.SimplePipeline;
 
+import com.lexicalscope.jewel.cli.CliFactory;
+import com.lexicalscope.jewel.cli.Option;
+
 /**
  * Given a trained event extraction model, run the event extractor on files in a directory.
  * Save the resulting annotations in XMI files. 
@@ -68,44 +69,40 @@ import org.uimafit.pipeline.SimplePipeli
  */
 public class EventExtractionPipeline {
   
-  public static class Options extends Options_ImplBase {
-
+  static interface Options {
+    // FYI -- command line should use -i or --inputDirectory now
     @Option(
-        name = "--input-dir",
-        usage = "specify the path to the directory containing the clinical notes to be processed",
-        required = true)
-    public String inputDirectory;
+        shortName = "i",
+        description = "specify the path to the directory containing the clinical notes to
be processed")
+    public String getInputDirectory();
     
     @Option(
-        name = "--output-dir",
-        usage = "specify the path to the directory where the output xmi files are to be saved",
-        required = true)
-    public String outputDirectory;
+        shortName = "o",
+        description = "specify the path to the directory where the output xmi files are to
be saved")
+    public String getOutputDirectory();
     
     @Option(
-        name = "--model-dir",
-        usage = "specify the path to the directory where the trained model is located",
-        required = false)
-    public String modelDirectory = "target/eval/event-spans/train_and_test/";
+        description = "specify the path to the directory where the trained model is located",
+        defaultValue="target/eval/event-spans/train_and_test/")
+    public String getModelDirectory();
   }
   
 	public static void main(String[] args) throws Exception {
 		
-		Options options = new Options();
-		options.parseOptions(args);
+		Options options = CliFactory.parseArguments(Options.class, args);
 
 		CollectionReader collectionReader = CollectionReaderFactory.createCollectionReaderFromPath(
 				"../ctakes-core/desc/collection_reader/FilesInDirectoryCollectionReader.xml",
 				FilesInDirectoryCollectionReader.PARAM_INPUTDIR,
-				options.inputDirectory);
+				options.getInputDirectory());
 
 		AggregateBuilder aggregateBuilder = getPreprocessorAggregateBuilder();
-		aggregateBuilder.add(EventAnnotator.createAnnotatorDescription(new File(options.modelDirectory)));
+		aggregateBuilder.add(EventAnnotator.createAnnotatorDescription(new File(options.getModelDirectory())));
 		
     AnalysisEngine xWriter = AnalysisEngineFactory.createPrimitive(
         XWriter.class,
         XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
-        options.outputDirectory);
+        options.getOutputDirectory());
 		
     SimplePipeline.runPipeline(
         collectionReader,

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventPrintingPipeline.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventPrintingPipeline.java?rev=1560833&r1=1560832&r2=1560833&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventPrintingPipeline.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/EventPrintingPipeline.java
Thu Jan 23 22:31:35 2014
@@ -30,14 +30,15 @@ import org.apache.uima.analysis_engine.A
 import org.apache.uima.collection.CollectionReader;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
-import org.cleartk.util.Options_ImplBase;
-import org.kohsuke.args4j.Option;
 import org.uimafit.component.JCasAnnotator_ImplBase;
 import org.uimafit.factory.AnalysisEngineFactory;
 import org.uimafit.factory.CollectionReaderFactory;
 import org.uimafit.pipeline.SimplePipeline;
 import org.uimafit.util.JCasUtil;
 
+import com.lexicalscope.jewel.cli.CliFactory;
+import com.lexicalscope.jewel.cli.Option;
+
 /**
  * Print event annotations and their context.
  *  
@@ -46,22 +47,20 @@ import org.uimafit.util.JCasUtil;
  */
 public class EventPrintingPipeline {
 
-  public static class Options extends Options_ImplBase {
+  static interface Options {
 
     @Option(
-        name = "--input-dir",
-        usage = "specify the path to the directory containing xmi files containing event
annotations",
-        required = true)
-    public File inputDirectory;
+        shortName = "i",
+        description = "specify the path to the directory containing xmi files containing
event annotations")
+    public File getInputDirectory();
   }
   
 	public static void main(String[] args) throws Exception {
 		
-		Options options = new Options();
-		options.parseOptions(args);
+		Options options = CliFactory.parseArguments(Options.class, args);
 
 		SimplePipeline.runPipeline(
-		    getCollectionReader(Arrays.asList(options.inputDirectory.listFiles())), 
+		    getCollectionReader(Arrays.asList(options.getInputDirectory().listFiles())), 
 		    PrintEventAnnotations.getDescription());
 	}
 	

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/TimeExtractionPipeline.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/TimeExtractionPipeline.java?rev=1560833&r1=1560832&r2=1560833&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/TimeExtractionPipeline.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/pipelines/TimeExtractionPipeline.java
Thu Jan 23 22:31:35 2014
@@ -49,8 +49,6 @@ import org.apache.ctakes.typesystem.type
 import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.collection.CollectionReader;
-import org.cleartk.util.Options_ImplBase;
-import org.kohsuke.args4j.Option;
 import org.uimafit.component.xwriter.XWriter;
 import org.uimafit.factory.AggregateBuilder;
 import org.uimafit.factory.AnalysisEngineFactory;
@@ -60,6 +58,9 @@ import org.uimafit.factory.TypePrioritie
 import org.uimafit.factory.TypeSystemDescriptionFactory;
 import org.uimafit.pipeline.SimplePipeline;
 
+import com.lexicalscope.jewel.cli.CliFactory;
+import com.lexicalscope.jewel.cli.Option;
+
 /**
  * Given a temporal expression extraction model, run the time expression extractor 
  * on files in a directory of notes. Save the resulting annotations in XMI files. 
@@ -68,44 +69,38 @@ import org.uimafit.pipeline.SimplePipeli
  */
 public class TimeExtractionPipeline {
   
-  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 String inputDirectory;
+        description = "specify the path to the directory containing the clinical notes to
be processed")
+    public String getInputDirectory();
     
     @Option(
-        name = "--output-dir",
-        usage = "specify the path to the directory where the output xmi files are to be saved",
-        required = true)
-    public String outputDirectory;
+        description = "specify the path to the directory where the output xmi files are to
be saved")
+    public String getOutputDirectory();
         
     @Option(
-        name = "--time-model-dir",
-        usage = "specify the path to the directory where the temporal expression model is
located",
-        required = false)
-    public String timeModelDirectory = "target/eval/time-spans/train_and_test/BackwardsTimeAnnotator/";
+        description = "specify the path to the directory where the temporal expression model
is located",
+        defaultValue="target/eval/time-spans/train_and_test/BackwardsTimeAnnotator/")
+    public String getTimeModelDirectory();
   }
   
 	public static void main(String[] args) throws Exception {
 		
-		Options options = new Options();
-		options.parseOptions(args);
+		Options options = CliFactory.parseArguments(Options.class, args);
 
 		CollectionReader collectionReader = CollectionReaderFactory.createCollectionReaderFromPath(
 				"../ctakes-core/desc/collection_reader/FilesInDirectoryCollectionReader.xml",
 				FilesInDirectoryCollectionReader.PARAM_INPUTDIR,
-				options.inputDirectory);
+				options.getInputDirectory());
 
 		AggregateBuilder aggregateBuilder = getPreprocessorAggregateBuilder();
-		aggregateBuilder.add(BackwardsTimeAnnotator.createAnnotatorDescription(new File(options.timeModelDirectory)));
+		aggregateBuilder.add(BackwardsTimeAnnotator.createAnnotatorDescription(new File(options.getTimeModelDirectory())));
 		
     AnalysisEngine xWriter = AnalysisEngineFactory.createPrimitive(
         XWriter.class,
         XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
-        options.outputDirectory);
+        options.getOutputDirectory());
 		
     SimplePipeline.runPipeline(
         collectionReader,



Mime
View raw message