Return-Path: X-Original-To: apmail-ctakes-commits-archive@www.apache.org Delivered-To: apmail-ctakes-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0312318870 for ; Mon, 16 Nov 2015 22:37:53 +0000 (UTC) Received: (qmail 62814 invoked by uid 500); 16 Nov 2015 22:37:52 -0000 Delivered-To: apmail-ctakes-commits-archive@ctakes.apache.org Received: (qmail 62775 invoked by uid 500); 16 Nov 2015 22:37:52 -0000 Mailing-List: contact commits-help@ctakes.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ctakes.apache.org Delivered-To: mailing list commits@ctakes.apache.org Received: (qmail 62766 invoked by uid 99); 16 Nov 2015 22:37:52 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Nov 2015 22:37:52 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 66F97C141C for ; Mon, 16 Nov 2015 22:37:52 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.991 X-Spam-Level: X-Spam-Status: No, score=0.991 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id LAq78xxnz77P for ; Mon, 16 Nov 2015 22:37:46 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id 946CB20C64 for ; Mon, 16 Nov 2015 22:37:45 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id CDE83E03E8 for ; Mon, 16 Nov 2015 22:37:44 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id B305A3A071E for ; Mon, 16 Nov 2015 22:37:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1714700 - /ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java Date: Mon, 16 Nov 2015 22:37:44 -0000 To: commits@ctakes.apache.org From: chenpei@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151116223744.B305A3A071E@svn01-us-west.apache.org> Author: chenpei Date: Mon Nov 16 22:37:44 2015 New Revision: 1714700 URL: http://svn.apache.org/viewvc?rev=1714700&view=rev Log: CTAKES-388 - Thanks Lewis John McGibbney for the Patch. Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java Modified: ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java?rev=1714700&r1=1714699&r2=1714700&view=diff ============================================================================== --- ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java (original) +++ ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java Mon Nov 16 22:37:44 2015 @@ -18,7 +18,7 @@ */ package org.apache.ctakes.dictionary.lookup.ae; -import org.apache.ctakes.core.resource.FileLocator; +import org.apache.commons.io.FileUtils; import org.apache.ctakes.core.resource.FileResourceImpl; import org.apache.ctakes.core.resource.JdbcConnectionResourceImpl; import org.apache.ctakes.utils.env.EnvironmentVariable; @@ -30,9 +30,12 @@ import org.apache.uima.fit.factory.Exter import org.apache.uima.resource.ResourceInitializationException; import java.io.BufferedReader; -import java.io.FileNotFoundException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; @@ -113,48 +116,51 @@ public class UmlsDictionaryLookupAnnotat } } - public static AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException { + @SuppressWarnings("resource") + public static AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException, MalformedURLException { + InputStream lookUpStream = UmlsDictionaryLookupAnnotator.class.getClassLoader().getResourceAsStream("org/apache/ctakes/dictionary/lookup/LookupDesc_Db.xml"); + File lookupFile = new File("/tmp/LookupDesc_Db.xml"); try { - return AnalysisEngineFactory.createEngineDescription( UmlsDictionaryLookupAnnotator.class, - UMLSADDR_PARAM, - "https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser", - UMLSVENDOR_PARAM, - "NLM-6515182895", - "LookupDescriptor", - ExternalResourceFactory.createExternalResourceDescription( - FileResourceImpl.class, - FileLocator.locateFile( "org/apache/ctakes/dictionary/lookup/LookupDesc_Db.xml" ) ), - "DbConnection", - ExternalResourceFactory.createExternalResourceDescription( - JdbcConnectionResourceImpl.class, - "", - JdbcConnectionResourceImpl.PARAM_DRIVER_CLASS, - "org.hsqldb.jdbcDriver", - JdbcConnectionResourceImpl.PARAM_URL, - // Should be the following but it's WAY too slow - "jdbc:hsqldb:res:/org/apache/ctakes/dictionary/lookup/umls2011ab/umls" ), - //"jdbc:hsqldb:file:target/unpacked/org/apache/ctakes/dictionary/lookup/umls2011ab/umls"), - "RxnormIndexReader", - ExternalResourceFactory.createExternalResourceDescription( - JdbcConnectionResourceImpl.class, - "", - JdbcConnectionResourceImpl.PARAM_DRIVER_CLASS, - "org.hsqldb.jdbcDriver", - JdbcConnectionResourceImpl.PARAM_URL, - "jdbc:hsqldb:res:/org/apache/ctakes/dictionary/lookup/rxnorm-hsqldb/umls" ), - "OrangeBookIndexReader", - ExternalResourceFactory.createExternalResourceDescription( - JdbcConnectionResourceImpl.class, - "", - JdbcConnectionResourceImpl.PARAM_DRIVER_CLASS, - "org.hsqldb.jdbcDriver", - JdbcConnectionResourceImpl.PARAM_URL, - "jdbc:hsqldb:res:/org/apache/ctakes/dictionary/lookup/orange_book_hsqldb/umls" ) - ); - } catch ( FileNotFoundException e ) { - e.printStackTrace(); - throw new ResourceInitializationException( e ); + FileUtils.copyInputStreamToFile(lookUpStream, lookupFile); + } catch (IOException e) { + throw new RuntimeException("Error copying temporary InpuStream org/apache/ctakes/dictionary/lookup/LookupDesc_Db.xml to /tmp/LookupDesc_Db.xml.", e); } + return AnalysisEngineFactory.createEngineDescription( UmlsDictionaryLookupAnnotator.class, + UMLSADDR_PARAM, + "https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser", + UMLSVENDOR_PARAM, + "NLM-6515182895", + "LookupDescriptor", + ExternalResourceFactory.createExternalResourceDescription( + FileResourceImpl.class, + lookupFile.toURI().toURL() ), + "DbConnection", + ExternalResourceFactory.createExternalResourceDescription( + JdbcConnectionResourceImpl.class, + "", + JdbcConnectionResourceImpl.PARAM_DRIVER_CLASS, + "org.hsqldb.jdbcDriver", + JdbcConnectionResourceImpl.PARAM_URL, + // Should be the following but it's WAY too slow + "jdbc:hsqldb:res:/org/apache/ctakes/dictionary/lookup/umls2011ab/umls" ), + //"jdbc:hsqldb:file:target/unpacked/org/apache/ctakes/dictionary/lookup/umls2011ab/umls"), + "RxnormIndexReader", + ExternalResourceFactory.createExternalResourceDescription( + JdbcConnectionResourceImpl.class, + "", + JdbcConnectionResourceImpl.PARAM_DRIVER_CLASS, + "org.hsqldb.jdbcDriver", + JdbcConnectionResourceImpl.PARAM_URL, + "jdbc:hsqldb:res:/org/apache/ctakes/dictionary/lookup/rxnorm-hsqldb/umls" ), + "OrangeBookIndexReader", + ExternalResourceFactory.createExternalResourceDescription( + JdbcConnectionResourceImpl.class, + "", + JdbcConnectionResourceImpl.PARAM_DRIVER_CLASS, + "org.hsqldb.jdbcDriver", + JdbcConnectionResourceImpl.PARAM_URL, + "jdbc:hsqldb:res:/org/apache/ctakes/dictionary/lookup/orange_book_hsqldb/umls" ) + ); } }