ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chen...@apache.org
Subject svn commit: r1714695 - /ctakes/trunk/ctakes-lvg/src/main/java/org/apache/ctakes/lvg/ae/LvgAnnotator.java
Date Mon, 16 Nov 2015 22:20:17 GMT
Author: chenpei
Date: Mon Nov 16 22:20:16 2015
New Revision: 1714695

URL: http://svn.apache.org/viewvc?rev=1714695&view=rev
Log:
CTAKES-385 - Thanks Lewis John McGibbney for the Patch.

Modified:
    ctakes/trunk/ctakes-lvg/src/main/java/org/apache/ctakes/lvg/ae/LvgAnnotator.java

Modified: ctakes/trunk/ctakes-lvg/src/main/java/org/apache/ctakes/lvg/ae/LvgAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-lvg/src/main/java/org/apache/ctakes/lvg/ae/LvgAnnotator.java?rev=1714695&r1=1714694&r2=1714695&view=diff
==============================================================================
--- ctakes/trunk/ctakes-lvg/src/main/java/org/apache/ctakes/lvg/ae/LvgAnnotator.java (original)
+++ ctakes/trunk/ctakes-lvg/src/main/java/org/apache/ctakes/lvg/ae/LvgAnnotator.java Mon Nov
16 22:20:16 2015
@@ -29,7 +29,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.net.URISyntaxException;
+import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -40,6 +40,7 @@ import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.ctakes.core.util.ListFactory;
 import org.apache.ctakes.lvg.resource.LvgCmdApiResource;
 import org.apache.ctakes.lvg.resource.LvgCmdApiResourceImpl;
@@ -560,30 +561,31 @@ public class LvgAnnotator extends JCasAn
 		}
 	}
 
-	public static AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException
{
-	  try {
-      return AnalysisEngineFactory.createEngineDescription(LvgAnnotator.class,
-          LvgAnnotator.PARAM_USE_CMD_CACHE,
-          false,
-          LvgAnnotator.PARAM_USE_LEMMA_CACHE,
-          false,
-          LvgAnnotator.PARAM_USE_SEGMENTS,
-          false,
-          LvgAnnotator.PARAM_LEMMA_CACHE_FREQUENCY_CUTOFF,
-          20,
-          LvgAnnotator.PARAM_LEMMA_FREQ_CUTOFF,
-          20,
-          LvgAnnotator.PARAM_POST_LEMMAS,
-          false,
-          LvgAnnotator.PARAM_LVGCMDAPI_RESRC_KEY,
-          ExternalResourceFactory.createExternalResourceDescription(
-              LvgCmdApiResourceImpl.class,
-              new File(LvgCmdApiResourceImpl.class.getResource(
-                  "/org/apache/ctakes/lvg/data/config/lvg.properties").toURI()))
-          );
-    } catch (URISyntaxException e) {
-      throw new ResourceInitializationException(e);
+	@SuppressWarnings("resource")
+  public static AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException,
MalformedURLException {
+    InputStream lvgStream = LvgAnnotator.class.getClassLoader().getResourceAsStream("org/apache/ctakes/lvg/data/config/lvg.properties");
+    File lvgFile = new File("/tmp/lvg.properties");
+    try {
+      FileUtils.copyInputStreamToFile(lvgStream, lvgFile);
+    } catch (IOException e) {
+      throw new RuntimeException("Error copying temporary InpuStream org/apache/ctakes/lvg/data/config/lvg.properties
to /tmp/lvg.properties.", e);
     }
+    return AnalysisEngineFactory.createEngineDescription(LvgAnnotator.class,
+        LvgAnnotator.PARAM_USE_CMD_CACHE,
+        false,
+        LvgAnnotator.PARAM_USE_LEMMA_CACHE,
+        false,
+        LvgAnnotator.PARAM_USE_SEGMENTS,
+        false,
+        LvgAnnotator.PARAM_LEMMA_CACHE_FREQUENCY_CUTOFF,
+        20,
+        LvgAnnotator.PARAM_LEMMA_FREQ_CUTOFF,
+        20,
+        LvgAnnotator.PARAM_POST_LEMMAS,
+        false,
+        LvgAnnotator.PARAM_LVGCMDAPI_RESRC_KEY,
+        ExternalResourceFactory.createExternalResourceDescription(
+            LvgCmdApiResourceImpl.class, lvgFile.toURI().toURL()));
 	}
 	
 	/**



Mime
View raw message