ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1849318 - in /ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util: JdbcUtil.java RareWordDbWriter.java
Date Wed, 19 Dec 2018 16:32:25 GMT
Author: seanfinan
Date: Wed Dec 19 16:32:25 2018
New Revision: 1849318

URL: http://svn.apache.org/viewvc?rev=1849318&view=rev
Log:
CTAKES-525 : Fix for vocabularies that have hyphens and/or dots

Modified:
    ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/JdbcUtil.java
    ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/RareWordDbWriter.java

Modified: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/JdbcUtil.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/JdbcUtil.java?rev=1849318&r1=1849317&r2=1849318&view=diff
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/JdbcUtil.java
(original)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/JdbcUtil.java
Wed Dec 19 16:32:25 2018
@@ -61,7 +61,7 @@ final public class JdbcUtil {
    }
 
    static public String createCodeInsertSql( final String vocabulary ) {
-      return createRowInsertSql( vocabulary.toLowerCase().replace( '.', '_' ).replace( '-',
'_' ), "CUI", vocabulary );
+      return createRowInsertSql( vocabulary, "CUI", vocabulary );
    }
 
    static public String createRowInsertSql( final String tableName, final String... fieldNames
) {
@@ -69,7 +69,7 @@ final public class JdbcUtil {
       sb.append( " " ).append( tableName );
       sb.append( " (" );
       for ( String fieldName : fieldNames ) {
-         sb.append( fieldName ).append( ',' );
+         sb.append( fieldName.toUpperCase() ).append( ',' );
       }
       // remove last comma
       sb.setLength( sb.length() - 1 );

Modified: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/RareWordDbWriter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/RareWordDbWriter.java?rev=1849318&r1=1849317&r2=1849318&view=diff
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/RareWordDbWriter.java
(original)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/util/RareWordDbWriter.java
Wed Dec 19 16:32:25 2018
@@ -42,6 +42,9 @@ final public class RareWordDbWriter {
    }
 
 
+   static private final Function<String, String> fixVocabName
+         = v -> v.toLowerCase().replace( '.', '_' ).replace( '-', '_' );
+
    static public boolean writeConcepts( final Connection connection, final Map<Long, Concept>
concepts ) {
       // Get Count of appearance in dictionary per term token
       final Map<String, Long> tokenCounts = RareWordUtil.getTokenCounts( concepts.values()
);
@@ -157,7 +160,7 @@ final public class RareWordDbWriter {
 
    static private Map<String, String> createCodeInsertSqls() {
       return VocabularyStore.getInstance().getAllVocabularies().stream()
-            .collect( Collectors.toMap( Function.identity(), JdbcUtil::createCodeInsertSql
) );
+                            .collect( Collectors.toMap( fixVocabName, JdbcUtil::createCodeInsertSql
) );
    }
 
    static private Map<String, PreparedStatement> createCodeStatements( final Connection
connection,
@@ -172,7 +175,7 @@ final public class RareWordDbWriter {
 
    static private Map<String, Long> createCodeCounts() {
       return VocabularyStore.getInstance().getAllVocabularies().stream()
-            .collect( Collectors.toMap( Function.identity(), v -> 0L ) );
+                            .collect( Collectors.toMap( fixVocabName, v -> 0L ) );
    }
 
    static private void setCodeAppropriately( final PreparedStatement statement, final String
code,



Mime
View raw message