ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chen...@apache.org
Subject svn commit: r1696831 - in /ctakes/trunk: ctakes-clinical-pipeline/src/main/java/org/apache/ctakes/clinicalpipeline/ ctakes-dictionary-lookup-fast/ ctakes-dictionary-lookup-fast/desc/analysis_engine/ ctakes-dictionary-lookup-fast/src/main/java/org/apach...
Date Thu, 20 Aug 2015 17:56:31 GMT
Author: chenpei
Date: Thu Aug 20 17:56:31 2015
New Revision: 1696831

URL: http://svn.apache.org/r1696831
Log:
CTAKES-364 - Allow Dictionary lookup fast to read in resources from InputStream instead of
File (allow reading within a jar).  
Done for BSV resources and config.
Added junit test case to ensure resources are loaded properly.

Added:
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/java/org/apache/ctakes/dictionary/lookup2/ae/
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/java/org/apache/ctakes/dictionary/lookup2/ae/TestDictionaryLoadResources.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/ctakes/
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/ctakes/dictionary/
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/ctakes/dictionary/lookup/
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/ctakes/dictionary/lookup/fast/
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/ctakes/dictionary/lookup/fast/TestcTakesHsql.xml
Modified:
    ctakes/trunk/ctakes-clinical-pipeline/src/main/java/org/apache/ctakes/clinicalpipeline/ClinicalPipelineFactory.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/   (props changed)
    ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsLookupAnnotator.xml
    ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsOverlapLookupAnnotator.xml
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DictionaryLookupFactory.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/BsvConceptFactory.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/BsvRareWordDictionary.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/DictionaryDescriptorParser.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java

Modified: ctakes/trunk/ctakes-clinical-pipeline/src/main/java/org/apache/ctakes/clinicalpipeline/ClinicalPipelineFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-clinical-pipeline/src/main/java/org/apache/ctakes/clinicalpipeline/ClinicalPipelineFactory.java?rev=1696831&r1=1696830&r2=1696831&view=diff
==============================================================================
--- ctakes/trunk/ctakes-clinical-pipeline/src/main/java/org/apache/ctakes/clinicalpipeline/ClinicalPipelineFactory.java
(original)
+++ ctakes/trunk/ctakes-clinical-pipeline/src/main/java/org/apache/ctakes/clinicalpipeline/ClinicalPipelineFactory.java
Thu Aug 20 17:56:31 2015
@@ -86,19 +86,11 @@ final public class ClinicalPipelineFacto
    public static AnalysisEngineDescription getFastPipeline() throws ResourceInitializationException
{
       AggregateBuilder builder = new AggregateBuilder();
       builder.add( getTokenProcessingPipeline() );
-      try {
-         builder.add( AnalysisEngineFactory.createEngineDescription( DefaultJCasTermAnnotator.class,
-               AbstractJCasTermAnnotator.PARAM_WINDOW_ANNOT_PRP,
-               "org.apache.ctakes.typesystem.type.textspan.Sentence",
-               JCasTermAnnotator.DICTIONARY_DESCRIPTOR_KEY,
-               ExternalResourceFactory.createExternalResourceDescription(
-                     FileResourceImpl.class,
-                     FileLocator.locateFile( "org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml"
) )
-         ) );
-      } catch ( FileNotFoundException e ) {
-         e.printStackTrace();
-         throw new ResourceInitializationException( e );
-      }
+      builder.add( AnalysisEngineFactory.createEngineDescription( DefaultJCasTermAnnotator.class,
+	       AbstractJCasTermAnnotator.PARAM_WINDOW_ANNOT_PRP,
+	       "org.apache.ctakes.typesystem.type.textspan.Sentence",
+	       JCasTermAnnotator.DICTIONARY_DESCRIPTOR_KEY,"org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml"
)
+	 );
       builder.add( ClearNLPDependencyParserAE.createAnnotatorDescription() );
       builder.add( PolarityCleartkAnalysisEngine.createAnnotatorDescription() );
       builder.add( UncertaintyCleartkAnalysisEngine.createAnnotatorDescription() );

Propchange: ctakes/trunk/ctakes-dictionary-lookup-fast/
------------------------------------------------------------------------------
--- svn:global-ignores (added)
+++ svn:global-ignores Thu Aug 20 17:56:31 2015
@@ -0,0 +1 @@
+target

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsLookupAnnotator.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsLookupAnnotator.xml?rev=1696831&r1=1696830&r2=1696831&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsLookupAnnotator.xml
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsLookupAnnotator.xml
Thu Aug 20 17:56:31 2015
@@ -54,6 +54,13 @@
             <multiValued>false</multiValued>
             <mandatory>false</mandatory>
          </configurationParameter>
+         <configurationParameter>
+            <name>DictionaryDescriptor</name>
+            <description>Path to Dictionary spec xml</description>
+            <type>String</type>
+            <multiValued>false</multiValued>
+            <mandatory>false</mandatory>
+         </configurationParameter>         
       </configurationParameters>
 
       <configurationParameterSettings>
@@ -78,6 +85,12 @@
                <string>3</string>
             </value>
          </nameValuePair>
+         <nameValuePair>
+            <name>DictionaryDescriptor</name>
+            <value>
+               <string>org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml</string>
+            </value>
+         </nameValuePair>         
       </configurationParameterSettings>
 
       <typeSystemDescription>
@@ -105,36 +118,4 @@
          <outputsNewCASes>false</outputsNewCASes>
       </operationalProperties>
    </analysisEngineMetaData>
-
-   <externalResourceDependencies>
-      <!-- DictionaryDescriptor is a relatively poorly-named xml that contains parms for
dictionary files, dbs, etc. -->
-      <!-- why aren't such things just defined here?  The obvious answer is -->
-      <externalResourceDependency>
-         <key>DictionaryDescriptor</key>
-         <description/>
-         <interfaceName>org.apache.ctakes.core.resource.FileResource</interfaceName>
-         <optional>false</optional>
-      </externalResourceDependency>
-   </externalResourceDependencies>
-
-   <resourceManagerConfiguration>
-      <externalResources>
-         <externalResource>
-            <!-- The Binding is below, for DictionaryDescriptor = DictionaryDescriptorFile
-->
-            <name>DictionaryDescriptorFile</name>
-            <description/>
-            <fileResourceSpecifier>
-               <fileUrl>file:org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml</fileUrl>
-            </fileResourceSpecifier>
-            <implementationName>org.apache.ctakes.core.resource.FileResourceImpl</implementationName>
-         </externalResource>
-      </externalResources>
-
-      <externalResourceBindings>
-         <externalResourceBinding>
-            <key>DictionaryDescriptor</key>
-            <resourceName>DictionaryDescriptorFile</resourceName>
-         </externalResourceBinding>
-      </externalResourceBindings>
-   </resourceManagerConfiguration>
 </taeDescription>

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsOverlapLookupAnnotator.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsOverlapLookupAnnotator.xml?rev=1696831&r1=1696830&r2=1696831&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsOverlapLookupAnnotator.xml
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/desc/analysis_engine/UmlsOverlapLookupAnnotator.xml
Thu Aug 20 17:56:31 2015
@@ -68,6 +68,13 @@
             <multiValued>false</multiValued>
             <mandatory>false</mandatory>
          </configurationParameter>
+         <configurationParameter>
+            <name>DictionaryDescriptor</name>
+            <description>Path to Dictionary spec xml</description>
+            <type>String</type>
+            <multiValued>false</multiValued>
+            <mandatory>false</mandatory>
+         </configurationParameter>            
       </configurationParameters>
 
       <configurationParameterSettings>
@@ -104,6 +111,12 @@
                <string>2</string>
             </value>
          </nameValuePair>
+         <nameValuePair>
+            <name>DictionaryDescriptor</name>
+            <value>
+               <string>org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml</string>
+            </value>
+         </nameValuePair>              
       </configurationParameterSettings>
 
       <typeSystemDescription>
@@ -131,36 +144,4 @@
          <outputsNewCASes>false</outputsNewCASes>
       </operationalProperties>
    </analysisEngineMetaData>
-
-   <externalResourceDependencies>
-      <!-- DictionaryDescriptor is a relatively poorly-named xml that contains parms for
dictionary files, dbs, etc. -->
-      <!-- why aren't such things just defined here?  The obvious answer is -->
-      <externalResourceDependency>
-         <key>DictionaryDescriptor</key>
-         <description/>
-         <interfaceName>org.apache.ctakes.core.resource.FileResource</interfaceName>
-         <optional>false</optional>
-      </externalResourceDependency>
-   </externalResourceDependencies>
-
-   <resourceManagerConfiguration>
-      <externalResources>
-         <externalResource>
-            <!-- The Binding is below, for DictionaryDescriptor = DictionaryDescriptorFile
-->
-            <name>DictionaryDescriptorFile</name>
-            <description/>
-            <fileResourceSpecifier>
-               <fileUrl>file:org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml</fileUrl>
-            </fileResourceSpecifier>
-            <implementationName>org.apache.ctakes.core.resource.FileResourceImpl</implementationName>
-         </externalResource>
-      </externalResources>
-
-      <externalResourceBindings>
-         <externalResourceBinding>
-            <key>DictionaryDescriptor</key>
-            <resourceName>DictionaryDescriptorFile</resourceName>
-         </externalResourceBinding>
-      </externalResourceBindings>
-   </resourceManagerConfiguration>
 </taeDescription>

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java?rev=1696831&r1=1696830&r2=1696831&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java
Thu Aug 20 17:56:31 2015
@@ -19,6 +19,7 @@
 package org.apache.ctakes.dictionary.lookup2.ae;
 
 import org.apache.ctakes.core.fsm.token.NumberToken;
+import org.apache.ctakes.core.resource.FileLocator;
 import org.apache.ctakes.core.resource.FileResource;
 import org.apache.ctakes.core.util.JCasUtil;
 import org.apache.ctakes.dictionary.lookup2.concept.Concept;
@@ -38,6 +39,7 @@ import org.apache.uima.analysis_engine.A
 import org.apache.uima.analysis_engine.annotator.AnnotatorContextException;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.fit.descriptor.ConfigurationParameter;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.JFSIndexRepository;
 import org.apache.uima.jcas.tcas.Annotation;
@@ -45,6 +47,8 @@ import org.apache.uima.resource.Resource
 import org.apache.uima.resource.ResourceInitializationException;
 
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
 import java.util.*;
 
 /**
@@ -55,7 +59,7 @@ import java.util.*;
  * Affiliation: CHIP-NLP
  * Date: 12/6/13
  */
-abstract public class AbstractJCasTermAnnotator extends JCasAnnotator_ImplBase
+abstract public class AbstractJCasTermAnnotator extends org.apache.uima.fit.component.JCasAnnotator_ImplBase
       implements JCasTermAnnotator, WindowProcessor {
 
    // LOG4J logger based on interface name
@@ -80,6 +84,9 @@ abstract public class AbstractJCasTermAn
          = "VB,VBD,VBG,VBN,VBP,VBZ,CC,CD,DT,EX,IN,LS,MD,PDT,POS,PP,PP$,PRP,PRP$,RP,TO,WDT,WP,WPS,WRB";
 
    private DictionarySpec _dictionarySpec;
+   
+   @ConfigurationParameter(name = JCasTermAnnotator.DICTIONARY_DESCRIPTOR_KEY, mandatory
= false, description = "Path to Dictionary spec xml")
+   protected String descriptorFilePath;
 
    // type of lookup window to use, typically "LookupWindowAnnotation" or "Sentence"
    private int _lookupWindowType;
@@ -125,10 +132,9 @@ abstract public class AbstractJCasTermAn
             _minimumLookupSpan = parseInt( minimumSpan, PARAM_MIN_SPAN_PRP, _minimumLookupSpan
);
          }
          LOGGER.info( "Using minimum term text span: " + _minimumLookupSpan );
-         final FileResource fileResource = (FileResource)uimaContext.getResourceObject( DICTIONARY_DESCRIPTOR_KEY
);
-         final File descriptorFile = fileResource.getFile();
-         _dictionarySpec = DictionaryDescriptorParser.parseDescriptor( descriptorFile, uimaContext
);
-      } catch ( ResourceAccessException | AnnotatorContextException multE ) {
+         InputStream descriptor = FileLocator.getAsStream(descriptorFilePath);
+         _dictionarySpec = DictionaryDescriptorParser.parseDescriptor( descriptor, uimaContext
);
+      } catch ( FileNotFoundException | AnnotatorContextException multE ) {
          throw new ResourceInitializationException( multE );
       }	   
    }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DictionaryLookupFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DictionaryLookupFactory.java?rev=1696831&r1=1696830&r2=1696831&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DictionaryLookupFactory.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DictionaryLookupFactory.java
Thu Aug 20 17:56:31 2015
@@ -1,5 +1,6 @@
 package org.apache.ctakes.dictionary.lookup2.ae;
 
+import org.apache.ctakes.core.resource.FileLocator;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.fit.factory.AnalysisEngineFactory;
 import org.apache.uima.resource.ResourceInitializationException;
@@ -26,8 +27,8 @@ final public class DictionaryLookupFacto
    }
 
    public static AnalysisEngineDescription createCustomDictionaryLookupDescription( final
String dictionaryDescriptor )
-         throws ResourceInitializationException {
-      if ( !(new File( dictionaryDescriptor )).exists() ) {
+         throws ResourceInitializationException, FileNotFoundException {
+      if ( FileLocator.getAsStream(dictionaryDescriptor) == null ) {
          throw new ResourceInitializationException( new FileNotFoundException( dictionaryDescriptor
) );
       }
       return AnalysisEngineFactory.createEngineDescription( DefaultJCasTermAnnotator.class,

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/BsvConceptFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/BsvConceptFactory.java?rev=1696831&r1=1696830&r2=1696831&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/BsvConceptFactory.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/BsvConceptFactory.java
Thu Aug 20 17:56:31 2015
@@ -13,6 +13,8 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.util.*;
 
 /**
@@ -94,15 +96,15 @@ final public class BsvConceptFactory imp
     * @return collection of all valid terms read from the bsv file
     */
    static private Collection<CuiTuiTerm> parseBsvFile( final String bsvFilePath ) {
-      File bsvFile = null;
+      InputStream bsvFile = null;
       try {
-         bsvFile = FileLocator.locateFile( bsvFilePath );
+         bsvFile = FileLocator.getAsStream( bsvFilePath );
       } catch ( IOException ioE ) {
          ioE.getMessage();
          return Collections.emptyList();
       }
       final Collection<CuiTuiTerm> cuiTuiTerms = new ArrayList<>();
-      try ( final BufferedReader reader = new BufferedReader( new FileReader( bsvFile ) )
) {
+      try ( final BufferedReader reader = new BufferedReader( new InputStreamReader( bsvFile
) ) ) {
          String line = reader.readLine();
          while ( line != null ) {
             if ( line.startsWith( "//" ) || line.startsWith( "#" ) ) {
@@ -114,7 +116,7 @@ final public class BsvConceptFactory imp
                // Add to the dictionary
                cuiTuiTerms.add( cuiTuiTerm );
             } else {
-               LOGGER.warn( "Bad BSV line " + line + " in " + bsvFile.getPath() );
+               LOGGER.warn( "Bad BSV line " + line + " in " + bsvFilePath);
             }
             line = reader.readLine();
          }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/BsvRareWordDictionary.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/BsvRareWordDictionary.java?rev=1696831&r1=1696830&r2=1696831&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/BsvRareWordDictionary.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/BsvRareWordDictionary.java
Thu Aug 20 17:56:31 2015
@@ -30,6 +30,8 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -120,15 +122,15 @@ final public class BsvRareWordDictionary
     */
 //   static private Collection<CuiTerm> parseBsvFile( final File bsvFile ) {
    static private Collection<CuiTerm> parseBsvFile( final String bsvFilePath ) {
-      File bsvFile = null;
+      InputStream bsvFile = null;
       try {
-         bsvFile = FileLocator.locateFile( bsvFilePath );
+         bsvFile = FileLocator.getAsStream( bsvFilePath );
       } catch ( IOException ioE ) {
          ioE.getMessage();
          return Collections.emptyList();
       }
       final Collection<CuiTerm> cuiTerms = new ArrayList<>();
-      try ( final BufferedReader reader = new BufferedReader( new FileReader( bsvFile ) )
) {
+      try ( final BufferedReader reader = new BufferedReader( new InputStreamReader( bsvFile
) ) ) {
          String line = reader.readLine();
          while ( line != null ) {
             if ( line.startsWith( "//" ) || line.startsWith( "#" ) ) {
@@ -140,7 +142,7 @@ final public class BsvRareWordDictionary
                // Add to the dictionary
                cuiTerms.add( cuiTerm );
             } else {
-               LOGGER.warn( "Bad BSV line " + line + " in " + bsvFile.getPath() );
+               LOGGER.warn( "Bad BSV line " + line + " in " + bsvFilePath );
             }
             line = reader.readLine();
          }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/DictionaryDescriptorParser.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/DictionaryDescriptorParser.java?rev=1696831&r1=1696830&r2=1696831&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/DictionaryDescriptorParser.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/DictionaryDescriptorParser.java
Thu Aug 20 17:56:31 2015
@@ -32,6 +32,7 @@ import org.jdom.input.SAXBuilder;
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.*;
@@ -112,21 +113,16 @@ final public class DictionaryDescriptorP
     * {@code descriptorFile}
     * @throws AnnotatorContextException if the File could not be found/read or the xml could
not be parsed
     */
-   static public DictionarySpec parseDescriptor( final File descriptorFile, final UimaContext
uimaContext )
+   static public DictionarySpec parseDescriptor( final InputStream descriptorFile, final
UimaContext uimaContext )
          throws AnnotatorContextException {
-      LOGGER.info( "Parsing dictionary specifications: " + descriptorFile.getPath() );
-      if ( !descriptorFile.canRead() ) {
-         LOGGER.error( "Missing Dictionary specifications file " + descriptorFile.getPath()
);
-         throw new AnnotatorContextException( "Missing Dictionary specifications file " +
descriptorFile.getPath(),
-               EMPTY_OBJECT_ARRAY );
-      }
+      LOGGER.info( "Parsing dictionary specifications: ");
       final SAXBuilder saxBuilder = new SAXBuilder();
       Document doc;
       try {
          doc = saxBuilder.build( descriptorFile );
       } catch ( JDOMException | IOException jdomioE ) {
          throw new AnnotatorContextException(
-               "Could not parse " + descriptorFile.getPath(), EMPTY_OBJECT_ARRAY, jdomioE
);
+               "Could not parse ", EMPTY_OBJECT_ARRAY, jdomioE );
       }
       final Map<String, RareWordDictionary> dictionaries
             = parseDictionaries( uimaContext, doc.getRootElement().getChild( DICTIONARIES_KEY
) );

Added: ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/java/org/apache/ctakes/dictionary/lookup2/ae/TestDictionaryLoadResources.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/java/org/apache/ctakes/dictionary/lookup2/ae/TestDictionaryLoadResources.java?rev=1696831&view=auto
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/java/org/apache/ctakes/dictionary/lookup2/ae/TestDictionaryLoadResources.java
(added)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/java/org/apache/ctakes/dictionary/lookup2/ae/TestDictionaryLoadResources.java
Thu Aug 20 17:56:31 2015
@@ -0,0 +1,24 @@
+package org.apache.ctakes.dictionary.lookup2.ae;
+
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.fit.factory.JCasFactory;
+import org.apache.uima.fit.factory.TypeSystemDescriptionFactory;
+import org.apache.uima.fit.pipeline.SimplePipeline;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.junit.Test;
+
+public class TestDictionaryLoadResources {
+
+	@Test
+	public void test() throws Exception {
+		TypeSystemDescription typeSystem = TypeSystemDescriptionFactory.createTypeSystemDescription();
	
+		JCas jcas = JCasFactory.createJCas();
+		jcas.setDocumentText("The quick red fox jumped over cTAKES.  Allie had a little lamb; little
lamb.");
+		//Test had to use custom test config otherwise we'll have to save our umls credentials.
+		AnalysisEngineDescription aed = DictionaryLookupFactory
+				.createCustomDictionaryLookupDescription("org/apache/ctakes/dictionary/lookup/fast/TestcTakesHsql.xml");
+		SimplePipeline.runPipeline(jcas,aed);
+	}
+
+}

Added: ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/ctakes/dictionary/lookup/fast/TestcTakesHsql.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/ctakes/dictionary/lookup/fast/TestcTakesHsql.xml?rev=1696831&view=auto
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/ctakes/dictionary/lookup/fast/TestcTakesHsql.xml
(added)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/test/resources/org/apache/ctakes/dictionary/lookup/fast/TestcTakesHsql.xml
Thu Aug 20 17:56:31 2015
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<lookupSpecification>
+
+   <dictionaries>
+      <dictionary>
+         <name>UmlsHsqlRareWord</name>
+         <implementationName>org.apache.ctakes.dictionary.lookup2.dictionary.JdbcRareWordDictionary</implementationName>
+         <properties>
+            <property key="jdbcDriver" value="org.hsqldb.jdbcDriver"/>
+            <!-- urls for hsqldb memory connections must be file types in hsql 1.8.
+            These file urls must be either absolute path or relative to current working directory.
+            They cannot be based upon the classpath.
+            Though JdbcConnectionFactory will attempt to "find" a db based upon the parent
dir of the url
+            for the sake of ide ease-of-use, the user should be aware of these hsql limitations.
+            -->
+            <property key="jdbcUrl"
+                      value="jdbc:hsqldb:file:resources/org/apache/ctakes/dictionary/lookup/fast/ctakessnorx/ctakessnorx"/>
+            <property key="jdbcUser" value="sa"/>
+            <property key="jdbcPass" value=""/>
+            <property key="rareWordTable" value="cui_terms"/>
+            <property key="umlsUrl" value="https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser"/>
+            <property key="umlsVendor" value="NLM-6515182895"/>
+            <property key="umlsUser" value="CHANGEME"/>
+            <property key="umlsPass" value="CHANGEME"/>
+         </properties>
+      </dictionary>
+   </dictionaries>
+
+   <conceptFactories>
+      <conceptFactory>
+         <name>UmlsHsqlCuiTable</name>
+         <implementationName>org.apache.ctakes.dictionary.lookup2.concept.JdbcConceptFactory</implementationName>
+         <properties>
+            <property key="jdbcDriver" value="org.hsqldb.jdbcDriver"/>
+            <property key="jdbcUrl"
+                      value="jdbc:hsqldb:file:resources/org/apache/ctakes/dictionary/lookup/fast/ctakessnorx/ctakessnorx"/>
+            <property key="jdbcUser" value="sa"/>
+            <property key="jdbcPass" value=""/>
+            <property key="tuiTable" value="tui"/>
+            <property key="prefTermTable" value="prefTerm"/>
+            <!-- Optional tables for optional term info.
+            Uncommenting these lines alone may not persist term information;
+            persistence depends upon the TermConsumer.  -->
+            <property key="snomedTable" value="snomedct"/>
+            <property key="rxnormTable" value="rxnorm"/>
+            <!--<property key="icd9Table" value="icd9cm"/>-->
+            <!--<property key="icd10Table" value="icd10pcs"/>-->
+            <property key="umlsUrl" value="https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser"/>
+            <property key="umlsVendor" value="NLM-6515182895"/>
+            <property key="umlsUser" value="CHANGEME"/>
+            <property key="umlsPass" value="CHANGEME"/>
+         </properties>
+      </conceptFactory>
+   </conceptFactories>
+
+   <!--  Defines what terms and concepts will be used  -->
+   <dictionaryConceptPairs>
+      <dictionaryConceptPair>
+         <name>cTakesUmls</name>
+         <dictionaryName>UmlsHsqlRareWord</dictionaryName>
+         <conceptFactoryName>UmlsHsqlCuiTable</conceptFactoryName>
+      </dictionaryConceptPair>
+   </dictionaryConceptPairs>
+
+   <!-- DefaultTermConsumer will persist all spans.
+   PrecisionTermConsumer will only persist only the longest overlapping span of any semantic
group.
+   SemanticCleanupTermConsumer works as Precision** but also removes signs/sympoms contained
within disease/disorder,
+    and (just in case) removes any s/s and d/d that are also (exactly) anatomical sites.
-->
+   <rareWordConsumer>
+      <name>Term Consumer</name>
+      <implementationName>org.apache.ctakes.dictionary.lookup2.consumer.DefaultTermConsumer</implementationName>
+      <!--<implementationName>org.apache.ctakes.dictionary.lookup2.consumer.PrecisionTermConsumer</implementationName>-->
+      <!--<implementationName>org.apache.ctakes.dictionary.lookup2.consumer.SemanticCleanupTermConsumer</implementationName>-->
+      <properties>
+          <!-- Depending upon the consumer, the value of codingScheme may or may not be
used.  With the packaged consumers,
+          codingScheme is a default value used only for cuis that do not have secondary codes
(snomed, rxnorm, etc.)  -->
+         <property key="codingScheme" value="CTAKES"/>
+      </properties>
+   </rareWordConsumer>
+
+</lookupSpecification>

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java?rev=1696831&r1=1696830&r2=1696831&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
Thu Aug 20 17:56:31 2015
@@ -529,11 +529,8 @@ org.cleartk.eval.Evaluation_ImplBase<Int
 			aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(DefaultJCasTermAnnotator.class,
 					AbstractJCasTermAnnotator.PARAM_WINDOW_ANNOT_PRP,
 					"org.apache.ctakes.typesystem.type.textspan.Sentence",
-					JCasTermAnnotator.DICTIONARY_DESCRIPTOR_KEY,
-					ExternalResourceFactory.createExternalResourceDescription(
-							FileResourceImpl.class,
-							FileLocator.locateFile("org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml"))
-					));
+					 JCasTermAnnotator.DICTIONARY_DESCRIPTOR_KEY, "org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml")
+					);
 		} catch (FileNotFoundException e) {
 			e.printStackTrace();
 			throw new ResourceInitializationException(e);



Mime
View raw message