ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevenbeth...@apache.org
Subject svn commit: r1393179 - /incubator/ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/ae/ClearParserDependencyParserAE.java
Date Tue, 02 Oct 2012 21:00:13 GMT
Author: stevenbethard
Date: Tue Oct  2 21:00:12 2012
New Revision: 1393179

URL: http://svn.apache.org/viewvc?rev=1393179&view=rev
Log:
Adds parameter to dependency parser for specifying the lemmatizer (instead of always defaulting
to the one that would be on the classpath - which doesn't work now because cTAKES isn't set
up right yet to put resources on the classpath).

Modified:
    incubator/ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/ae/ClearParserDependencyParserAE.java

Modified: incubator/ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/ae/ClearParserDependencyParserAE.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/ae/ClearParserDependencyParserAE.java?rev=1393179&r1=1393178&r2=1393179&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/ae/ClearParserDependencyParserAE.java
(original)
+++ incubator/ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/ae/ClearParserDependencyParserAE.java
Tue Oct  2 21:00:12 2012
@@ -18,32 +18,31 @@
  */
 package org.apache.ctakes.dependency.parser.ae;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.uima.UimaContext;
-import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
-import org.apache.uima.jcas.JCas;
-import org.apache.uima.resource.ResourceInitializationException;
-import org.uimafit.component.JCasAnnotator_ImplBase;
-import org.uimafit.descriptor.ConfigurationParameter;
-import org.uimafit.descriptor.TypeCapability;
-import org.uimafit.util.JCasUtil;
-
-import clear.dep.DepNode;
-import clear.dep.DepTree;
-import clear.morph.MorphEnAnalyzer;
-import clear.parse.AbstractDepParser;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.ctakes.dependency.parser.util.ClearDependencyUtility;
-import org.apache.ctakes.typesystem.type.syntax.BaseToken;
-import org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode;
-import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import org.apache.ctakes.typesystem.type.syntax.BaseToken;
+import org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import org.apache.log4j.Logger;
+import org.apache.uima.UimaContext;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.uimafit.component.JCasAnnotator_ImplBase;
+import org.uimafit.descriptor.ConfigurationParameter;
+import org.uimafit.descriptor.TypeCapability;
+import org.uimafit.util.JCasUtil;
+
+import clear.dep.DepNode;
+import clear.dep.DepTree;
+import clear.morph.MorphEnAnalyzer;
+import clear.parse.AbstractDepParser;
 
 /**
  * <br>
@@ -90,6 +89,14 @@ public class ClearParserDependencyParser
 					      "analysis engine will use a default model from the resources directory")
 	protected String parserModelFileName;
 
+  public static final String PARAM_LEMMATIZER_DATA_FILE = "LemmatizerDataFile";
+
+  @ConfigurationParameter(
+      name = PARAM_LEMMATIZER_DATA_FILE,
+      description = "This parameter provides the data file required for the MorphEnAnalyzer.
If not "
+          + "specified, this analysis engine will use a default model from the resources
directory")
+  protected File lemmatizerDataFile;
+
 	public static final String PARAM_PARSER_ALGORITHM_NAME = "ParserAlgorithmName";
 	@ConfigurationParameter(
 			name = PARAM_PARSER_ALGORITHM_NAME,
@@ -122,7 +129,9 @@ public class ClearParserDependencyParser
 			if (useLemmatizer) {
 				// Note: If lemmatizer data file is not specified, then use lemmas from the BaseToken
normalizedToken field.
 				// Initialize lemmatizer
-				URL lemmatizerDataFileURL = this.getClass().getResource(ENG_LEMMATIZER_DATA_FILE);
+        URL lemmatizerDataFileURL = this.lemmatizerDataFile != null
+            ? this.lemmatizerDataFile.toURI().toURL()
+            : this.getClass().getResource(ENG_LEMMATIZER_DATA_FILE);
 				lemmatizer = new MorphEnAnalyzer(lemmatizerDataFileURL);
 			}
 



Mime
View raw message