incubator-ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1401708 - /incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/GoldEntityAndRelationReaderPipeline.java
Date Wed, 24 Oct 2012 14:29:22 GMT
Author: dligach
Date: Wed Oct 24 14:29:22 2012
New Revision: 1401708

URL: http://svn.apache.org/viewvc?rev=1401708&view=rev
Log:
removed hard-coded paths (replaced them with command line options)

Modified:
    incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/GoldEntityAndRelationReaderPipeline.java

Modified: incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/GoldEntityAndRelationReaderPipeline.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/GoldEntityAndRelationReaderPipeline.java?rev=1401708&r1=1401707&r2=1401708&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/GoldEntityAndRelationReaderPipeline.java
(original)
+++ incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/GoldEntityAndRelationReaderPipeline.java
Wed Oct 24 14:29:22 2012
@@ -18,14 +18,17 @@
  */
 package org.apache.ctakes.relationextractor.pipelines;
 
+import java.io.File;
 import java.io.IOException;
 
 import org.apache.ctakes.core.cr.FilesInDirectoryCollectionReader;
 import org.apache.ctakes.relationextractor.cr.GoldEntityAndRelationReader;
+import org.apache.ctakes.relationextractor.eval.PreprocessAndWriteXmi.Options;
 import org.apache.uima.UIMAException;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.collection.CollectionReaderDescription;
 import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.kohsuke.args4j.Option;
 import org.uimafit.component.xwriter.XWriter;
 import org.uimafit.factory.AnalysisEngineFactory;
 import org.uimafit.factory.CollectionReaderFactory;
@@ -42,29 +45,54 @@ import org.uimafit.pipeline.SimplePipeli
  */
 public class GoldEntityAndRelationReaderPipeline {
 
-	public static void main(String[] args) throws UIMAException, IOException {
-		
-		TypeSystemDescription typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
-				"/home/dima/workspaces/ctakes/ctakes-type-system/desc/common_type_system.xml");
-		
-		CollectionReaderDescription collectionReader = CollectionReaderFactory.createDescription(
-				FilesInDirectoryCollectionReader.class,
-				typeSystemDescription,
-				"InputDirectory",
-				"/home/dima/sharp/cloud/sharp/text/train/");
-		
-		AnalysisEngineDescription goldAnnotator = AnalysisEngineFactory.createPrimitiveDescription(
-				GoldEntityAndRelationReader.class,
-				typeSystemDescription,
-				"InputDirectory",
-				"/home/dima/sharp/cloud/sharp/xml/train/");
-
-    AnalysisEngineDescription xWriter = AnalysisEngineFactory.createPrimitiveDescription(
-        XWriter.class,
-        typeSystemDescription,
-        XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
-        "/home/dima/temp/");
-    
-		SimplePipeline.runPipeline(collectionReader, goldAnnotator, xWriter);
+  @Option(name = "-t", 
+      aliases = "--textRoot", 
+      usage = "specify the directory contraining the textFiles (for example /NLP/Corpus/Relations/mipacq/text/train",
+      required = true)
+  public File textRoot;
+
+  @Option(name = "-x",
+      aliases = "--xmlRoot",
+      usage = "specify the directory containing the knowtator xml files (for example: /NLP/Corpus/Relations/mipacq/xml/train",
+      required = true)
+  public File xmlRoot;
+
+  @Option(name = "-o",
+      aliases = "--outputRoot",
+      usage = "specify the directory to write out CAS XMI files",
+      required = false)
+  public File outputRoot = new File("target/out/xmi/");
+
+  public static void main(String[] args) throws UIMAException, IOException {
+	
+    Options options = new Options();
+    options.parseOptions(args);
+  
+    File textRoot = options.textRoot;
+    File xmlRoot = options.xmlRoot;
+    File outputRoot = options.outputRoot;
+
+	  TypeSystemDescription typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
+	      "/home/dima/workspaces/ctakes/ctakes-type-system/desc/common_type_system.xml");
+
+	  CollectionReaderDescription collectionReader = CollectionReaderFactory.createDescription(
+	      FilesInDirectoryCollectionReader.class,
+	      typeSystemDescription,
+	      "InputDirectory",
+	      textRoot.getPath());
+
+	  AnalysisEngineDescription goldAnnotator = AnalysisEngineFactory.createPrimitiveDescription(
+	      GoldEntityAndRelationReader.class,
+	      typeSystemDescription,
+	      "InputDirectory",
+	      xmlRoot.getPath());
+
+	  AnalysisEngineDescription xWriter = AnalysisEngineFactory.createPrimitiveDescription(
+	      XWriter.class,
+	      typeSystemDescription,
+	      XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
+	      outputRoot.getPath());
+
+	  SimplePipeline.runPipeline(collectionReader, goldAnnotator, xWriter);
 	}
 }



Mime
View raw message