ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1677903 - in /ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2: concept/BsvConceptFactory.java dictionary/BsvRareWordDictionary.java util/JdbcConnectionFactory.java
Date Tue, 05 May 2015 22:41:26 GMT
Author: seanfinan
Date: Tue May  5 22:41:26 2015
New Revision: 1677903

URL: http://svn.apache.org/r1677903
Log:
Use FileLocator to find BSV dictionaries

Modified:
    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/util/JdbcConnectionFactory.java

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=1677903&r1=1677902&r2=1677903&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
Tue May  5 22:41:26 2015
@@ -1,5 +1,6 @@
 package org.apache.ctakes.dictionary.lookup2.concept;
 
+import org.apache.ctakes.core.resource.FileLocator;
 import org.apache.ctakes.dictionary.lookup2.util.CuiCodeUtil;
 import org.apache.ctakes.dictionary.lookup2.util.LookupUtil;
 import org.apache.ctakes.dictionary.lookup2.util.TuiCodeUtil;
@@ -34,11 +35,12 @@ final public class BsvConceptFactory imp
    }
 
    public BsvConceptFactory( final String name, final String bsvFilePath ) {
-      this( name, new File( bsvFilePath ) );
-   }
-
-   public BsvConceptFactory( final String name, final File bsvFile ) {
-      final Collection<CuiTuiTerm> cuiTuiTerms = parseBsvFile( bsvFile );
+//      this( name, new File( bsvFilePath ) );
+//   }
+//
+//   public BsvConceptFactory( final String name, final File bsvFile ) {
+//      final Collection<CuiTuiTerm> cuiTuiTerms = parseBsvFile( bsvFile );
+      final Collection<CuiTuiTerm> cuiTuiTerms = parseBsvFile( bsvFilePath );
       final Map<Long, Concept> conceptMap = new HashMap<>( cuiTuiTerms.size()
);
       for ( CuiTuiTerm cuiTuiTerm : cuiTuiTerms ) {
          final CollectionMap<ConceptCode, String, ? extends Collection<String>>
codes
@@ -90,11 +92,21 @@ final public class BsvConceptFactory imp
     * CUI|TUI|Text|PreferredTerm
     * </p>
     * If the TUI column is omitted then the entityId for the dictionary is used as the TUI
+    * <p/>
+    * //    * @param bsvFile file containing term rows and bsv columns
     *
-    * @param bsvFile file containing term rows and bsv columns
+    * @param bsvFilePath file containing term rows and bsv columns
     * @return collection of all valid terms read from the bsv file
     */
-   static private Collection<CuiTuiTerm> parseBsvFile( final File bsvFile ) {
+//   static private Collection<CuiTuiTerm> parseBsvFile( final File bsvFile ) {
+   static private Collection<CuiTuiTerm> parseBsvFile( final String bsvFilePath ) {
+      File bsvFile = null;
+      try {
+         bsvFile = FileLocator.locateFile( bsvFilePath );
+      } catch ( IOException ioE ) {
+         ioE.getMessage();
+         return Collections.emptyList();
+      }
       final Collection<CuiTuiTerm> cuiTuiTerms = new ArrayList<>();
       try ( final BufferedReader reader = new BufferedReader( new FileReader( bsvFile ) )
) {
          String 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=1677903&r1=1677902&r2=1677903&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
Tue May  5 22:41:26 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.ctakes.dictionary.lookup2.dictionary;
 
+import org.apache.ctakes.core.resource.FileLocator;
 import org.apache.ctakes.dictionary.lookup2.term.RareWordTerm;
 import org.apache.ctakes.dictionary.lookup2.util.FastLookupToken;
 import org.apache.ctakes.dictionary.lookup2.util.LookupUtil;
@@ -31,6 +32,7 @@ import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Properties;
 
 import static org.apache.ctakes.dictionary.lookup2.dictionary.RareWordTermMapCreator.CuiTerm;
@@ -59,11 +61,12 @@ final public class BsvRareWordDictionary
 
 
    public BsvRareWordDictionary( final String name, final String bsvFilePath ) {
-      this( name, new File( bsvFilePath ) );
-   }
-
-   public BsvRareWordDictionary( final String name, final File bsvFile ) {
-      final Collection<CuiTerm> cuiTerms = parseBsvFile( bsvFile );
+//      this( name, new File( bsvFilePath ) );
+//   }
+//
+//   public BsvRareWordDictionary( final String name, final File bsvFile ) {
+//      final Collection<CuiTerm> cuiTerms = parseBsvFile( bsvFile );
+      final Collection<CuiTerm> cuiTerms = parseBsvFile( bsvFilePath );
       final CollectionMap<String, RareWordTerm, ? extends Collection<RareWordTerm>>
rareWordTermMap
             = RareWordTermMapCreator.createRareWordTermMap( cuiTerms );
       _delegateDictionary = new MemRareWordDictionary( name, rareWordTermMap );
@@ -109,11 +112,21 @@ final public class BsvRareWordDictionary
     * CUI|TUI|Text|PreferredTerm
     * </p>
     * If the TUI column is omitted then the entityId for the dictionary is used as the TUI
+    * <p/>
+    * //    * @param bsvFile file containing term rows and bsv columns
     *
-    * @param bsvFile file containing term rows and bsv columns
+    * @param bsvFilePath path to file containing term rows and bsv columns
     * @return collection of all valid terms read from the bsv file
     */
-   static private Collection<CuiTerm> parseBsvFile( final File bsvFile ) {
+//   static private Collection<CuiTerm> parseBsvFile( final File bsvFile ) {
+   static private Collection<CuiTerm> parseBsvFile( final String bsvFilePath ) {
+      File bsvFile = null;
+      try {
+         bsvFile = FileLocator.locateFile( bsvFilePath );
+      } catch ( IOException ioE ) {
+         ioE.getMessage();
+         return Collections.emptyList();
+      }
       final Collection<CuiTerm> cuiTerms = new ArrayList<>();
       try ( final BufferedReader reader = new BufferedReader( new FileReader( bsvFile ) )
) {
          String line = reader.readLine();

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/JdbcConnectionFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/JdbcConnectionFactory.java?rev=1677903&r1=1677902&r2=1677903&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/JdbcConnectionFactory.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/JdbcConnectionFactory.java
Tue May  5 22:41:26 2015
@@ -21,8 +21,6 @@ import java.util.*;
 public enum JdbcConnectionFactory {
    INSTANCE;
 
-   static private final String CTAKES_HOME = "CTAKES_HOME";
-
    static final private Logger LOGGER = Logger.getLogger( "JdbcConnectionFactory" );
    static final private Logger DOT_LOGGER = Logger.getLogger( "ProgressAppender" );
    static final private Logger EOL_LOGGER = Logger.getLogger( "ProgressDone" );



Mime
View raw message