ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1627792 [1/2] - in /ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2: ae/ concept/ consumer/ dictionary/ util/collection/
Date Fri, 26 Sep 2014 14:20:36 GMT
Author: seanfinan
Date: Fri Sep 26 14:20:36 2014
New Revision: 1627792

URL: http://svn.apache.org/r1627792
Log:
Apparently I dreamed up a checkin a few days ago ...
Add another type parameter to CollectionMap so that I could
Add new EnumCollectionMap
 fixed .dictionary. missing in path of cTakesHsql.xml
 Removing old DictionaryFactory as it no longer applies to new dictionary format

Removed:
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/DictionaryFactory.java
Modified:
    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/DefaultJCasTermAnnotator.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/OverlapJCasTermAnnotator.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/WindowProcessor.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/concept/Concept.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/JdbcConceptFactory.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/AbstractTermConsumer.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultTermConsumer.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/PrecisionTermConsumer.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/TermConsumer.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-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/MemRareWordDictionary.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/RareWordTermMapCreator.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ArrayListMap.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/CollectionMap.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/HashSetMap.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/collection/ImmutableCollectionMap.java

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=1627792&r1=1627791&r2=1627792&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 Fri Sep 26 14:20:36 2014
@@ -36,6 +36,7 @@ import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 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.jcas.JCas;
 import org.apache.uima.jcas.JFSIndexRepository;
@@ -58,7 +59,7 @@ abstract public class AbstractJCasTermAn
       implements JCasTermAnnotator, WindowProcessor {
 
    // LOG4J logger based on interface name
-   final private Logger _logger = Logger.getLogger( "AbstractJCasTermAnnotator" );
+   final static private Logger LOGGER = Logger.getLogger( "AbstractJCasTermAnnotator" );
 
    /**
     * specifies the type of window to use for lookup
@@ -73,6 +74,11 @@ abstract public class AbstractJCasTermAn
     */
    static private final String MIN_SPAN_PRP_KEY = "minimumSpan";
 
+
+   static private final String DEFAULT_LOOKUP_WINDOW = "org.apache.ctakes.typesystem.type.textspan.Sentence";
+   static private final String DEFAULT_EXCLUSION_TAGS
+         = "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;
 
    // type of lookup window to use, typically "LookupWindowAnnotation" or "Sentence"
@@ -89,32 +95,36 @@ abstract public class AbstractJCasTermAn
    public void initialize( final UimaContext uimaContext ) throws ResourceInitializationException {
       super.initialize( uimaContext );
       try {
-         final String windowClassName = (String)uimaContext.getConfigParameterValue( WINDOW_ANNOT_PRP_KEY );
-         _logger.info( "Using dictionary lookup window type: " + windowClassName );
+         String windowClassName = (String)uimaContext.getConfigParameterValue( WINDOW_ANNOT_PRP_KEY );
+         if ( windowClassName == null || windowClassName.isEmpty() ) {
+            windowClassName = DEFAULT_LOOKUP_WINDOW;
+         }
+         LOGGER.info( "Using dictionary lookup window type: " + windowClassName );
          _lookupWindowType = JCasUtil.getType( windowClassName );
-
          // optional exclusion POS tags
-         final String exclusionTags = (String)uimaContext.getConfigParameterValue( EXC_TAGS_PRP_KEY );
-         if ( exclusionTags != null ) {
-            final String[] tagArr = exclusionTags.split( "," );
-            for ( String tag : tagArr ) {
-               _exclusionPartsOfSpeech.add( tag.toUpperCase() );
-            }
-            final List<String> posList = new ArrayList<>( _exclusionPartsOfSpeech );
-            Collections.sort( posList );
-            final StringBuilder sb = new StringBuilder();
-            for ( String pos : posList ) {
-               sb.append( pos ).append( " " );
-            }
-            _logger.info( "Exclusion tagset loaded: " + sb.toString() );
+         String exclusionTags = (String)uimaContext.getConfigParameterValue( EXC_TAGS_PRP_KEY );
+         if ( exclusionTags == null ) {
+            // Notice that exclusion tags can be set to empty on purpose
+            exclusionTags = DEFAULT_EXCLUSION_TAGS;
+         }
+         final String[] tagArr = exclusionTags.split( "," );
+         for ( String tag : tagArr ) {
+            _exclusionPartsOfSpeech.add( tag.toUpperCase() );
          }
+         final List<String> posList = new ArrayList<>( _exclusionPartsOfSpeech );
+         Collections.sort( posList );
+         final StringBuilder sb = new StringBuilder();
+         for ( String pos : posList ) {
+            sb.append( pos ).append( " " );
+         }
+         LOGGER.info( "Exclusion tagset loaded: " + sb.toString() );
 
          // optional minimum span, default is 3
          final Object minimumSpan = uimaContext.getConfigParameterValue( MIN_SPAN_PRP_KEY );
          if ( minimumSpan != null ) {
             _minimumLookupSpan = parseInt( minimumSpan, MIN_SPAN_PRP_KEY, _minimumLookupSpan );
          }
-         _logger.info( "Using minimum lookup token span: " + _minimumLookupSpan );
+         LOGGER.info( "Using minimum lookup token span: " + _minimumLookupSpan );
          final FileResource fileResource = (FileResource)uimaContext.getResourceObject( DICTIONARY_DESCRIPTOR_KEY );
          final File descriptorFile = fileResource.getFile();
          _dictionarySpec = DictionaryDescriptorParser.parseDescriptor( descriptorFile, uimaContext );
@@ -124,22 +134,21 @@ abstract public class AbstractJCasTermAn
    }
 
 
-
    /**
     * {@inheritDoc}
     */
    @Override
    public void process( final JCas jcas ) throws AnalysisEngineProcessException {
-      _logger.debug( "Starting processing" );
+      LOGGER.debug( "Starting processing" );
       final JFSIndexRepository indexes = jcas.getJFSIndexRepository();
       final AnnotationIndex<Annotation> lookupWindows = indexes.getAnnotationIndex( _lookupWindowType );
       if ( lookupWindows == null ) {  // I don't trust AnnotationIndex.size(), so don't check
          return;
       }
-      final Map<RareWordDictionary, CollectionMap<TextSpan, Long>> dictionaryTermsMap
+      final Map<RareWordDictionary, CollectionMap<TextSpan, Long, ? extends Collection<Long>>> dictionaryTermsMap
             = new HashMap<>( getDictionaries().size() );
       for ( RareWordDictionary dictionary : getDictionaries() ) {
-         final CollectionMap<TextSpan, Long> textSpanCuis = new HashSetMap<>();
+         final CollectionMap<TextSpan, Long, ? extends Collection<Long>> textSpanCuis = new HashSetMap<>();
          dictionaryTermsMap.put( dictionary, textSpanCuis );
       }
       try {
@@ -150,27 +159,29 @@ abstract public class AbstractJCasTermAn
          }
       } catch ( ArrayIndexOutOfBoundsException iobE ) {
          // JCasHashMap will throw this every once in a while.  Assume the windows are done and move on
-         _logger.warn( iobE.getMessage() );
+         LOGGER.warn( iobE.getMessage() );
       }
       // Let the consumer handle uniqueness and ordering - some may not care
       final Collection<Long> allDictionaryCuis = new HashSet<>();
-      for ( Map.Entry<RareWordDictionary, CollectionMap<TextSpan, Long>> dictionaryCuis : dictionaryTermsMap.entrySet() ) {
+      final CollectionMap<Long, Concept, ? extends Collection<Concept>> allConceptsMap = new HashSetMap<>();
+      for ( Map.Entry<RareWordDictionary, CollectionMap<TextSpan, Long, ? extends Collection<Long>>> dictionaryCuis : dictionaryTermsMap
+            .entrySet() ) {
          allDictionaryCuis.clear();
          final RareWordDictionary dictionary = dictionaryCuis.getKey();
-         final CollectionMap<TextSpan, Long> textSpanCuis = dictionaryCuis.getValue();
+         final CollectionMap<TextSpan, Long, ? extends Collection<Long>> textSpanCuis = dictionaryCuis.getValue();
          for ( Collection<Long> cuiCodes : textSpanCuis.getAllCollections() ) {
             allDictionaryCuis.addAll( cuiCodes );
          }
          final Collection<ConceptFactory> conceptFactories
                = _dictionarySpec.getPairedConceptFactories( dictionary.getName() );
-         final CollectionMap<Long, Concept> allConceptsMap = new HashSetMap<>();
+         allConceptsMap.clear();
          for ( ConceptFactory conceptFactory : conceptFactories ) {
             final Map<Long, Concept> conceptMap = conceptFactory.createConcepts( allDictionaryCuis );
             allConceptsMap.placeMap( conceptMap );
          }
          _dictionarySpec.getConsumer().consumeHits( jcas, dictionary, textSpanCuis, allConceptsMap );
       }
-      _logger.debug( "Finished processing" );
+      LOGGER.debug( "Finished processing" );
    }
 
 
@@ -200,7 +211,7 @@ abstract public class AbstractJCasTermAn
     */
    @Override
    public void processWindow( final JCas jcas, final Annotation window,
-                              final Map<RareWordDictionary, CollectionMap<TextSpan, Long>> dictionaryTerms ) {
+                              final Map<RareWordDictionary, CollectionMap<TextSpan, Long, ? extends Collection<Long>>> dictionaryTerms ) {
       final List<FastLookupToken> allTokens = new ArrayList<>();
       final List<Integer> lookupTokenIndices = new ArrayList<>();
       getAnnotationsInWindow( jcas, window, allTokens, lookupTokenIndices );
@@ -215,28 +226,16 @@ abstract public class AbstractJCasTermAn
     * @param lookupTokenIndices -
     * @param dictionaryTermsMap -
     */
-   private void findTerms( final Collection<RareWordDictionary> dictionaries,
+   private void findTerms( final Iterable<RareWordDictionary> dictionaries,
                            final List<FastLookupToken> allTokens, final List<Integer> lookupTokenIndices,
-                           final Map<RareWordDictionary, CollectionMap<TextSpan, Long>> dictionaryTermsMap ) {
+                           final Map<RareWordDictionary, CollectionMap<TextSpan, Long, ? extends Collection<Long>>> dictionaryTermsMap ) {
       for ( RareWordDictionary dictionary : dictionaries ) {
-         CollectionMap<TextSpan, Long> termsFromDictionary = dictionaryTermsMap.get( dictionary );
+         CollectionMap<TextSpan, Long, ? extends Collection<Long>> termsFromDictionary = dictionaryTermsMap
+               .get( dictionary );
          findTerms( dictionary, allTokens, lookupTokenIndices, termsFromDictionary );
       }
    }
 
-   /**
-    * Given a dictionary, tokens, and lookup token indices, populate a terms collection with discovered terms
-    *
-    * @param dictionary          -
-    * @param allTokens           -
-    * @param lookupTokenIndices  -
-    * @param termsFromDictionary -
-    */
-   abstract void findTerms( RareWordDictionary dictionary,
-                            List<FastLookupToken> allTokens,
-                            List<Integer> lookupTokenIndices,
-                            CollectionMap<TextSpan, Long> termsFromDictionary );
-
 
    /**
     * For the given lookup window fills two collections with 1) All tokens in the window,
@@ -247,10 +246,11 @@ abstract public class AbstractJCasTermAn
     * @param allTokens          filled with all tokens, including punctuation, etc.
     * @param lookupTokenIndices filled with indices of tokens to use for lookup
     */
-   protected void getAnnotationsInWindow( final JCas jcas, final Annotation window,
+   protected void getAnnotationsInWindow( final JCas jcas, final AnnotationFS window,
                                           final List<FastLookupToken> allTokens,
-                                          final List<Integer> lookupTokenIndices ) {
-      final List<BaseToken> allBaseTokens = org.apache.uima.fit.util.JCasUtil.selectCovered( jcas, BaseToken.class, window );
+                                          final Collection<Integer> lookupTokenIndices ) {
+      final List<BaseToken> allBaseTokens = org.apache.uima.fit.util.JCasUtil
+            .selectCovered( jcas, BaseToken.class, window );
       for ( BaseToken baseToken : allBaseTokens ) {
          if ( baseToken instanceof NewlineToken ) {
             continue;
@@ -273,17 +273,17 @@ abstract public class AbstractJCasTermAn
    }
 
 
-   protected int parseInt( final Object value, final String name, final int defaultValue ) {
+   static protected int parseInt( final Object value, final String name, final int defaultValue ) {
       if ( value instanceof Integer ) {
          return (Integer)value;
       } else if ( value instanceof String ) {
          try {
             return Integer.parseInt( (String)value );
          } catch ( NumberFormatException nfE ) {
-            _logger.warn( "Could not parse " + name + " " + value + " as an integer" );
+            LOGGER.warn( "Could not parse " + name + " " + value + " as an integer" );
          }
       } else {
-         _logger.warn( "Could not parse " + name + " " + value + " as an integer" );
+         LOGGER.warn( "Could not parse " + name + " " + value + " as an integer" );
       }
       return defaultValue;
    }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DefaultJCasTermAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DefaultJCasTermAnnotator.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DefaultJCasTermAnnotator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DefaultJCasTermAnnotator.java Fri Sep 26 14:20:36 2014
@@ -44,7 +44,7 @@ final public class DefaultJCasTermAnnota
    public void findTerms( final RareWordDictionary dictionary,
                           final List<FastLookupToken> allTokens,
                           final List<Integer> lookupTokenIndices,
-                          final CollectionMap<TextSpan, Long> termsFromDictionary ) {
+                          final CollectionMap<TextSpan, Long, ? extends Collection<Long>> termsFromDictionary ) {
       Collection<RareWordTerm> rareWordHits;
       for ( Integer lookupTokenIndex : lookupTokenIndices ) {
          final FastLookupToken lookupToken = allTokens.get( lookupTokenIndex );

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java Fri Sep 26 14:20:36 2014
@@ -19,9 +19,13 @@
 package org.apache.ctakes.dictionary.lookup2.ae;
 
 import org.apache.ctakes.dictionary.lookup2.dictionary.RareWordDictionary;
+import org.apache.ctakes.dictionary.lookup2.textspan.TextSpan;
+import org.apache.ctakes.dictionary.lookup2.util.FastLookupToken;
+import org.apache.ctakes.dictionary.lookup2.util.collection.CollectionMap;
 import org.apache.uima.analysis_component.AnalysisComponent;
 
 import java.util.Collection;
+import java.util.List;
 
 /**
  * An annotator that looks up dictionary terms in text using
@@ -40,4 +44,17 @@ public interface JCasTermAnnotator exten
     */
    public Collection<RareWordDictionary> getDictionaries();
 
+   /**
+    * Given a dictionary, tokens, and lookup token indices, populate a terms collection with discovered terms
+    *
+    * @param dictionary          -
+    * @param allTokens           -
+    * @param lookupTokenIndices  -
+    * @param termsFromDictionary -
+    */
+   void findTerms( RareWordDictionary dictionary,
+                   List<FastLookupToken> allTokens,
+                   List<Integer> lookupTokenIndices,
+                   CollectionMap<TextSpan, Long, ? extends Collection<Long>> termsFromDictionary );
+
 }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/OverlapJCasTermAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/OverlapJCasTermAnnotator.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/OverlapJCasTermAnnotator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/OverlapJCasTermAnnotator.java Fri Sep 26 14:20:36 2014
@@ -85,7 +85,7 @@ final public class OverlapJCasTermAnnota
    public void findTerms( final RareWordDictionary dictionary,
                           final List<FastLookupToken> allTokens,
                           final List<Integer> lookupTokenIndices,
-                          final CollectionMap<TextSpan, Long> termsFromDictionary ) {
+                          final CollectionMap<TextSpan, Long, ? extends Collection<Long>> termsFromDictionary ) {
       Collection<RareWordTerm> rareWordHits;
       for ( Integer lookupTokenIndex : lookupTokenIndices ) {
          final FastLookupToken lookupToken = allTokens.get( lookupTokenIndex );
@@ -138,8 +138,8 @@ final public class OverlapJCasTermAnnota
       } else {
          int nextRareWordIndex = rareWordHit.getRareWordIndex() - 1;
          for ( int allTokensIndex = lookupTokenIndex - 1; allTokensIndex >= 0; allTokensIndex-- ) {
-            if ( rareWordTokens[nextRareWordIndex].equals( allTokens.get( allTokensIndex ).getText() )
-                 || rareWordTokens[nextRareWordIndex].equals( allTokens.get( allTokensIndex ).getVariant() ) ) {
+            if ( rareWordTokens[ nextRareWordIndex ].equals( allTokens.get( allTokensIndex ).getText() )
+                 || rareWordTokens[ nextRareWordIndex ].equals( allTokens.get( allTokensIndex ).getVariant() ) ) {
                nextRareWordIndex--;
                if ( nextRareWordIndex < 0 ) {
                   firstWordIndex = allTokensIndex;
@@ -172,8 +172,8 @@ final public class OverlapJCasTermAnnota
          consecutiveSkips = 0;
          int nextRareWordIndex = rareWordHit.getRareWordIndex() + 1;
          for ( int allTokensIndex = lookupTokenIndex + 1; allTokensIndex < allTokens.size(); allTokensIndex++ ) {
-            if ( rareWordTokens[nextRareWordIndex].equals( allTokens.get( allTokensIndex ).getText() )
-                 || rareWordTokens[nextRareWordIndex].equals( allTokens.get( allTokensIndex ).getVariant() ) ) {
+            if ( rareWordTokens[ nextRareWordIndex ].equals( allTokens.get( allTokensIndex ).getText() )
+                 || rareWordTokens[ nextRareWordIndex ].equals( allTokens.get( allTokensIndex ).getVariant() ) ) {
                nextRareWordIndex++;
                if ( nextRareWordIndex >= rareWordHit.getTokenCount() ) {
                   lastWordIndex = allTokensIndex;
@@ -206,18 +206,18 @@ final public class OverlapJCasTermAnnota
 
 
    static private String[] fastSplit( final String line, final int tokenCount ) {
-      final String[] tokens = new String[tokenCount];
+      final String[] tokens = new String[ tokenCount ];
       int tokenIndex = 0;
       int previousSpaceIndex = -1;
       int spaceIndex = line.indexOf( ' ' );
       while ( spaceIndex > 0 && tokenIndex < tokenCount ) {
-         tokens[tokenIndex] = line.substring( previousSpaceIndex + 1, spaceIndex );
+         tokens[ tokenIndex ] = line.substring( previousSpaceIndex + 1, spaceIndex );
          tokenIndex++;
          previousSpaceIndex = spaceIndex;
          spaceIndex = line.indexOf( ' ', previousSpaceIndex + 1 );
       }
       if ( previousSpaceIndex + 1 < line.length() ) {
-         tokens[tokenCount - 1] = line.substring( previousSpaceIndex + 1 );
+         tokens[ tokenCount - 1 ] = line.substring( previousSpaceIndex + 1 );
       }
       return tokens;
    }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/WindowProcessor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/WindowProcessor.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/WindowProcessor.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/WindowProcessor.java Fri Sep 26 14:20:36 2014
@@ -24,6 +24,7 @@ import org.apache.ctakes.dictionary.look
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.tcas.Annotation;
 
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -47,13 +48,13 @@ public interface WindowProcessor {
    /**
     * Processes a window of annotations for dictionary terms
     *
-    * @param jcas              -
-    * @param window            annotation in which to search for terms
+    * @param jcas            -
+    * @param window          annotation in which to search for terms
     * @param dictionaryTerms map of entity types and terms for those types in the window
     */
    void processWindow( JCas jcas,
                        Annotation window,
-                       Map<RareWordDictionary, CollectionMap<TextSpan, Long>> dictionaryTerms );
+                       Map<RareWordDictionary, CollectionMap<TextSpan, Long, ? extends Collection<Long>>> dictionaryTerms );
 
 
 }

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=1627792&r1=1627791&r2=1627792&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 Fri Sep 26 14:20:36 2014
@@ -4,7 +4,7 @@ import org.apache.ctakes.dictionary.look
 import org.apache.ctakes.dictionary.lookup2.util.LookupUtil;
 import org.apache.ctakes.dictionary.lookup2.util.TuiCodeUtil;
 import org.apache.ctakes.dictionary.lookup2.util.collection.CollectionMap;
-import org.apache.ctakes.dictionary.lookup2.util.collection.HashSetMap;
+import org.apache.ctakes.dictionary.lookup2.util.collection.EnumSetMap;
 import org.apache.log4j.Logger;
 import org.apache.uima.UimaContext;
 
@@ -14,8 +14,6 @@ import java.io.FileReader;
 import java.io.IOException;
 import java.util.*;
 
-import static org.apache.ctakes.dictionary.lookup2.concept.ConceptCode.TUI;
-
 /**
  * Author: SPF
  * Affiliation: CHIP-NLP
@@ -35,15 +33,16 @@ final public class BsvConceptFactory imp
       this( name, properties.getProperty( BSV_FILE_PATH ) );
    }
 
-   public BsvConceptFactory( final String name,  final String bsvFilePath ) {
+   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 );
-      final Map<Long,Concept> conceptMap = new HashMap<>( cuiTuiTerms.size() );
+      final Map<Long, Concept> conceptMap = new HashMap<>( cuiTuiTerms.size() );
       for ( CuiTuiTerm cuiTuiTerm : cuiTuiTerms ) {
-         final CollectionMap<ConceptCode,String> codes = new HashSetMap<>( 1 );
+         final CollectionMap<ConceptCode, String, ? extends Collection<String>> codes
+               = new EnumSetMap<>( ConceptCode.class );
          codes.placeValue( ConceptCode.TUI, TuiCodeUtil.getAsTui( cuiTuiTerm.getTui() ) );
          conceptMap.put( CuiCodeUtil.getCuiCode( cuiTuiTerm.getCui() ),
                new Concept( cuiTuiTerm.getCui(), cuiTuiTerm.getPrefTerm(), codes ) );
@@ -51,29 +50,26 @@ final public class BsvConceptFactory imp
       _delegateFactory = new MemConceptFactory( name, conceptMap );
    }
 
-
    /**
-    * The Type identifier and Name are used to maintain a collection of dictionaries,
-    * so the combination of Type and Name should be unique for each dictionary if possible.
-    *
-    * @return simple name for the dictionary
+    * {@inheritDoc}
     */
+   @Override
    public String getName() {
       return _delegateFactory.getName();
    }
 
    /**
-    * @param cuiCode concept unique identifier
-    * @return the information about the concept that exists in the repository.
+    * {@inheritDoc}
     */
-   public Concept createConcept( final Long cuiCode )  {
+   @Override
+   public Concept createConcept( final Long cuiCode ) {
       return _delegateFactory.createConcept( cuiCode );
    }
 
    /**
-    * @param cuiCodes concept unique identifiers
-    * @return the information about the concepts that exist in the repository.
+    * {@inheritDoc}
     */
+   @Override
    public Map<Long, Concept> createConcepts( final Collection<Long> cuiCodes ) {
       return _delegateFactory.createConcepts( cuiCodes );
    }
@@ -100,8 +96,7 @@ final public class BsvConceptFactory imp
     */
    static private Collection<CuiTuiTerm> parseBsvFile( final File bsvFile ) {
       final Collection<CuiTuiTerm> cuiTuiTerms = new ArrayList<>();
-      try {
-         final BufferedReader reader = new BufferedReader( new FileReader( bsvFile ) );
+      try ( final BufferedReader reader = new BufferedReader( new FileReader( bsvFile ) ) ) {
          String line = reader.readLine();
          while ( line != null ) {
             if ( line.startsWith( "//" ) || line.startsWith( "#" ) ) {
@@ -128,7 +123,7 @@ final public class BsvConceptFactory imp
     * @param columns two or three columns representing CUI,Text or CUI,TUI,Text respectively
     * @return a term created from the columns or null if the columns are malformed
     */
-   static private CuiTuiTerm createCuiTuiTerm( final String[] columns ) {
+   static private CuiTuiTerm createCuiTuiTerm( final String... columns ) {
       if ( columns.length < 2 ) {
          return null;
       }
@@ -139,13 +134,13 @@ final public class BsvConceptFactory imp
          // third column is text, fourth column is preferred term text
          termIndex = 3;
       }
-      if ( columns[cuiIndex].trim().isEmpty() || columns[tuiIndex].trim().isEmpty() ) {
+      if ( columns[ cuiIndex ].trim().isEmpty() || columns[ tuiIndex ].trim().isEmpty() ) {
          return null;
       }
-      final String cui = columns[cuiIndex];
+      final String cui = columns[ cuiIndex ];
       // default for an empty tui column is tui 0 = unknown
-      final String tui = (columns[tuiIndex].trim().isEmpty()) ? "T000" : columns[tuiIndex].trim();
-      final String term = (termIndex < 0 || columns[termIndex].trim().isEmpty()) ? "" : columns[termIndex].trim();
+      final String tui = (columns[ tuiIndex ].trim().isEmpty()) ? "T000" : columns[ tuiIndex ].trim();
+      final String term = (termIndex < 0 || columns[ termIndex ].trim().isEmpty()) ? "" : columns[ termIndex ].trim();
       return new CuiTuiTerm( cui, tui, term );
    }
 

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java Fri Sep 26 14:20:36 2014
@@ -2,7 +2,7 @@ package org.apache.ctakes.dictionary.loo
 
 import org.apache.ctakes.dictionary.lookup2.util.SemanticUtil;
 import org.apache.ctakes.dictionary.lookup2.util.collection.CollectionMap;
-import org.apache.ctakes.dictionary.lookup2.util.collection.HashSetMap;
+import org.apache.ctakes.dictionary.lookup2.util.collection.EnumSetMap;
 import org.apache.ctakes.dictionary.lookup2.util.collection.ImmutableCollectionMap;
 import org.apache.ctakes.typesystem.type.constants.CONST;
 
@@ -23,7 +23,7 @@ final public class Concept {
 
    final private String _cui;
    final private String _preferredText;
-   final private CollectionMap<ConceptCode, String> _codes;
+   final private CollectionMap<ConceptCode, String, ? extends Collection<String>> _codes;
    final private Collection<Integer> _ctakesSemantics;
 
    final private int _hashcode;
@@ -33,10 +33,11 @@ final public class Concept {
    }
 
    public Concept( final String cui, final String preferredText ) {
-      this( cui, preferredText, new HashSetMap<ConceptCode, String>( 0 ) );
+      this( cui, preferredText, new EnumSetMap<ConceptCode, String>( ConceptCode.class ) );
    }
 
-   public Concept( final String cui, final String preferredText, final CollectionMap<ConceptCode, String> codes ) {
+   public Concept( final String cui, final String preferredText,
+                   final CollectionMap<ConceptCode, String, ? extends Collection<String>> codes ) {
       _cui = cui;
       _preferredText = preferredText;
       _codes = new ImmutableCollectionMap<>( codes );

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/JdbcConceptFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/JdbcConceptFactory.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/JdbcConceptFactory.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/JdbcConceptFactory.java Fri Sep 26 14:20:36 2014
@@ -3,7 +3,7 @@ package org.apache.ctakes.dictionary.loo
 import org.apache.ctakes.dictionary.lookup2.util.CuiCodeUtil;
 import org.apache.ctakes.dictionary.lookup2.util.TuiCodeUtil;
 import org.apache.ctakes.dictionary.lookup2.util.collection.CollectionMap;
-import org.apache.ctakes.dictionary.lookup2.util.collection.HashSetMap;
+import org.apache.ctakes.dictionary.lookup2.util.collection.EnumSetMap;
 import org.apache.log4j.Logger;
 import org.apache.uima.UimaContext;
 
@@ -103,7 +103,8 @@ public class JdbcConceptFactory extends 
    @Override
    public Concept createConcept( final Long cuiCode ) {
       final String prefTerm = (_selectPrefTermCall == null) ? null : getPreferredTerm( cuiCode );
-      final CollectionMap<ConceptCode, String> codes = new HashSetMap<>( 5 );
+      final CollectionMap<ConceptCode, String, ? extends Collection<String>> codes
+            = new EnumSetMap<>( ConceptCode.class );
       if ( _selectTuiCall != null ) {
          codes.addAllValues( TUI, getTuis( cuiCode ) );
       }
@@ -210,11 +211,10 @@ public class JdbcConceptFactory extends 
     * @param cuiCode -
     * @throws SQLException if the {@code PreparedStatement} could not be created or changed
     */
-   private void fillSelectCall( final PreparedStatement selectCall, final Long cuiCode ) throws SQLException {
+   static private void fillSelectCall( final PreparedStatement selectCall, final Long cuiCode ) throws SQLException {
       selectCall.clearParameters();
       selectCall.setLong( 1, cuiCode );
    }
 
 
-
 }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/AbstractTermConsumer.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/AbstractTermConsumer.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/AbstractTermConsumer.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/AbstractTermConsumer.java Fri Sep 26 14:20:36 2014
@@ -47,36 +47,22 @@ abstract public class AbstractTermConsum
       _codingScheme = properties.getProperty( CODING_SCHEME_PRP_KEY );
    }
 
-
-
-   /**
-    * @param jcas           -
-    * @param codingScheme   -
-    * @param cTakesSemantic cTakes IdentifiedAnnotation only accepts an integer as a typeId
-    * @param textSpanCuis  map of spans to terms for those spans
-    * @param cuiConcepts     -
-    * @throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
-    */
-   abstract protected void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
-                                              final CollectionMap<TextSpan, Long> textSpanCuis,
-                                              final CollectionMap<Long, Concept> cuiConcepts )
-         throws AnalysisEngineProcessException;
-
    /**
     * {@inheritDoc}
     */
    @Override
    public void consumeHits( final JCas jcas,
                             final RareWordDictionary dictionary,
-                            final CollectionMap<TextSpan, Long> textSpanCuis,
-                            final CollectionMap<Long, Concept> cuiConcepts )
+                            final CollectionMap<TextSpan, Long, ? extends Collection<Long>> textSpanCuis,
+                            final CollectionMap<Long, Concept, ? extends Collection<Concept>> cuiConcepts )
          throws AnalysisEngineProcessException {
       final String codingScheme = getCodingScheme();
       final Collection<Integer> usedcTakesSemantics = getUsedcTakesSemantics( cuiConcepts );
       // The dictionary may have more than one type, create a map of types to terms and use them all
+      final CollectionMap<TextSpan, Long, ? extends Collection<Long>> semanticCuis = new HashSetMap<>();
       for ( Integer cTakesSemantic : usedcTakesSemantics ) {
-         final CollectionMap<TextSpan, Long> semanticCuis = new HashSetMap<>();
-         for ( Map.Entry<TextSpan, Collection<Long>> spanCuis : textSpanCuis ) {
+         semanticCuis.clear();
+         for ( Map.Entry<TextSpan, ? extends Collection<Long>> spanCuis : textSpanCuis ) {
             for ( Long cuiCode : spanCuis.getValue() ) {
                final Collection<Concept> concepts = cuiConcepts.getCollection( cuiCode );
                if ( hascTakesSemantic( cTakesSemantic, concepts ) ) {
@@ -93,8 +79,8 @@ abstract public class AbstractTermConsum
    }
 
 
-
-   static protected Collection<Integer> getUsedcTakesSemantics( final CollectionMap<Long, Concept> cuiConcepts ) {
+   static protected Collection<Integer> getUsedcTakesSemantics(
+         final CollectionMap<Long, Concept, ? extends Collection<Concept>> cuiConcepts ) {
       final Collection<Integer> usedSemanticTypes = new HashSet<>();
       for ( Collection<Concept> concepts : cuiConcepts.getAllCollections() ) {
          for ( Concept concept : concepts ) {
@@ -105,7 +91,7 @@ abstract public class AbstractTermConsum
    }
 
    static private boolean hascTakesSemantic( final Integer cTakesSemantic,
-                                             final Collection<Concept> concepts  ) {
+                                             final Collection<Concept> concepts ) {
       for ( Concept concept : concepts ) {
          if ( concept.getCtakesSemantics().contains( cTakesSemantic ) ) {
             return true;

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultTermConsumer.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultTermConsumer.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultTermConsumer.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultTermConsumer.java Fri Sep 26 14:20:36 2014
@@ -34,14 +34,7 @@ import org.apache.uima.jcas.cas.FSArray;
 
 import java.util.*;
 
-import static org.apache.ctakes.typesystem.type.constants.CONST.NE_TYPE_ID_DRUG;
-import static org.apache.ctakes.typesystem.type.constants.CONST.NE_TYPE_ID_ANATOMICAL_SITE;
-import static org.apache.ctakes.typesystem.type.constants.CONST.NE_TYPE_ID_DISORDER;
-import static org.apache.ctakes.typesystem.type.constants.CONST.NE_TYPE_ID_FINDING;
-import static org.apache.ctakes.typesystem.type.constants.CONST.NE_TYPE_ID_LAB;
-import static org.apache.ctakes.typesystem.type.constants.CONST.NE_TYPE_ID_PROCEDURE;
-
-
+import static org.apache.ctakes.typesystem.type.constants.CONST.*;
 
 
 /**
@@ -58,19 +51,17 @@ final public class DefaultTermConsumer e
 
 
    /**
-    * @param jcas           -
-    * @param codingScheme   -
-    * @param cTakesSemantic cTakes IdentifiedAnnotation only accepts an integer as a cTakesSemantic
-    * @throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
+    * {@inheritDoc}
     */
-   protected void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
-                                     final CollectionMap<TextSpan, Long> textSpanCuis,
-                                     final CollectionMap<Long, Concept> cuiConcepts )
+   @Override
+   public void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
+                                  final CollectionMap<TextSpan, Long, ? extends Collection<Long>> textSpanCuis,
+                                  final CollectionMap<Long, Concept, ? extends Collection<Concept>> cuiConcepts )
          throws AnalysisEngineProcessException {
       // Collection of UmlsConcept objects
       final Collection<UmlsConcept> umlsConceptList = new ArrayList<>();
       try {
-         for ( Map.Entry<TextSpan, Collection<Long>> spanCuis : textSpanCuis ) {
+         for ( Map.Entry<TextSpan, ? extends Collection<Long>> spanCuis : textSpanCuis ) {
             umlsConceptList.clear();
             for ( Long cuiCode : spanCuis.getValue() ) {
                umlsConceptList.addAll( createUmlsConcepts( jcas, codingScheme, cTakesSemantic, cuiCode, cuiConcepts ) );
@@ -97,7 +88,7 @@ final public class DefaultTermConsumer e
    }
 
    static private IdentifiedAnnotation createSemanticAnnotation( final JCas jcas, final int cTakesSemantic ) {
-      switch( cTakesSemantic ) {
+      switch ( cTakesSemantic ) {
          case NE_TYPE_ID_DRUG: {
             return new MedicationMention( jcas );
          }
@@ -125,7 +116,7 @@ final public class DefaultTermConsumer e
                                                               final String codingScheme,
                                                               final int cTakesSemantic,
                                                               final Long cui,
-                                                              final CollectionMap<Long, Concept> conceptMap ) {
+                                                              final CollectionMap<Long, Concept, ? extends Collection<Concept>> conceptMap ) {
       final Collection<Concept> concepts = conceptMap.getCollection( cui );
       if ( concepts == null || concepts.isEmpty() ) {
          return Arrays.asList( createUmlsConcept( jcas, codingScheme, cui, null, null, null ) );

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/PrecisionTermConsumer.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/PrecisionTermConsumer.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/PrecisionTermConsumer.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/PrecisionTermConsumer.java Fri Sep 26 14:20:36 2014
@@ -39,7 +39,7 @@ import java.util.*;
  */
 final public class PrecisionTermConsumer extends AbstractTermConsumer {
 
-   private final AbstractTermConsumer _idHitConsumer;
+   private final TermConsumer _idHitConsumer;
 
    public PrecisionTermConsumer( final UimaContext uimaContext, final Properties properties ) {
       super( uimaContext, properties );
@@ -52,11 +52,12 @@ final public class PrecisionTermConsumer
     * {@inheritDoc}
     */
    @Override
-   protected void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
-                                     final CollectionMap<TextSpan, Long> semanticTerms,
-                                     final CollectionMap<Long, Concept> conceptMap )
+   public void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
+                                  final CollectionMap<TextSpan, Long, ? extends Collection<Long>> semanticTerms,
+                                  final CollectionMap<Long, Concept, ? extends Collection<Concept>> conceptMap )
          throws AnalysisEngineProcessException {
-      final CollectionMap<TextSpan, Long> preciseTerms = createPreciseTerms( semanticTerms );
+      final CollectionMap<TextSpan, Long, ? extends Collection<Long>> preciseTerms
+            = createPreciseTerms( semanticTerms );
       _idHitConsumer.consumeTypeIdHits( jcas, codingScheme, cTakesSemantic, preciseTerms, conceptMap );
    }
 
@@ -68,8 +69,8 @@ final public class PrecisionTermConsumer
     * @param semanticTerms terms in the dictionary
     * @return terms with the longest spans
     */
-   static private CollectionMap<TextSpan, Long> createPreciseTerms(
-         final CollectionMap<TextSpan, Long> semanticTerms ) {
+   static private CollectionMap<TextSpan, Long, ? extends Collection<Long>> createPreciseTerms(
+         final CollectionMap<TextSpan, Long, ? extends Collection<Long>> semanticTerms ) {
       final Collection<TextSpan> discardSpans = new HashSet<>();
       final List<TextSpan> textSpans = new ArrayList<>( semanticTerms.keySet() );
       final int count = textSpans.size();
@@ -125,8 +126,9 @@ final public class PrecisionTermConsumer
             }
          }
       }
-      final CollectionMap<TextSpan, Long> preciseHitMap = new HashSetMap<>( textSpans.size() - discardSpans.size() );
-      for ( Map.Entry<TextSpan, Collection<Long>> entry : semanticTerms ) {
+      final CollectionMap<TextSpan, Long, ? extends Collection<Long>> preciseHitMap = new HashSetMap<>(
+            textSpans.size() - discardSpans.size() );
+      for ( Map.Entry<TextSpan, ? extends Collection<Long>> entry : semanticTerms ) {
          if ( !discardSpans.contains( entry.getKey() ) ) {
             preciseHitMap.addAllValues( entry.getKey(), entry.getValue() );
          }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/TermConsumer.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/TermConsumer.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/TermConsumer.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/TermConsumer.java Fri Sep 26 14:20:36 2014
@@ -25,6 +25,8 @@ import org.apache.ctakes.dictionary.look
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.jcas.JCas;
 
+import java.util.Collection;
+
 /**
  * Stores terms in the cas
  * Author: SPF
@@ -35,17 +37,27 @@ public interface TermConsumer {
 
 
    /**
-    * @param jcas            -
-    * @param dictionary      the dictionary: Anatomical Site, Disease/Disorder, Drug, combination, etc.
+    * @param jcas         -
+    * @param dictionary   the dictionary: Anatomical Site, Disease/Disorder, Drug, combination, etc.
     * @param textSpanCuis collection of discovered terms
-    * @param cuiConcepts      map of cuis to concepts
+    * @param cuiConcepts  map of cuis to concepts
     * @throws AnalysisEngineProcessException
     */
    void consumeHits( final JCas jcas,
                      final RareWordDictionary dictionary,
-                     final CollectionMap<TextSpan, Long> textSpanCuis,
-                     final CollectionMap<Long, Concept> cuiConcepts )
+                     final CollectionMap<TextSpan, Long, ? extends Collection<Long>> textSpanCuis,
+                     final CollectionMap<Long, Concept, ? extends Collection<Concept>> cuiConcepts )
          throws AnalysisEngineProcessException;
 
+   /**
+    * @param jcas           -
+    * @param codingScheme   -
+    * @param cTakesSemantic cTakes IdentifiedAnnotation only accepts an integer as a cTakesSemantic
+    * @throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
+    */
+   void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
+                           final CollectionMap<TextSpan, Long, ? extends Collection<Long>> textSpanCuis,
+                           final CollectionMap<Long, Concept, ? extends Collection<Concept>> cuiConcepts )
+         throws AnalysisEngineProcessException;
 
 }

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=1627792&r1=1627791&r2=1627792&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 Fri Sep 26 14:20:36 2014
@@ -33,6 +33,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Properties;
 
+import static org.apache.ctakes.dictionary.lookup2.dictionary.RareWordTermMapCreator.CuiTerm;
+
 /**
  * A RareWordDictionary created from a bar-separated value (BSV) file.  The file can have 2 or 3 columns,
  * in the format CUI|TEXT or CUI|TUI|TEXT.  The text will be tokenized and rare word indexing done automatically for
@@ -61,8 +63,8 @@ final public class BsvRareWordDictionary
    }
 
    public BsvRareWordDictionary( final String name, final File bsvFile ) {
-      final Collection<RareWordTermMapCreator.CuiTerm> cuiTerms = parseBsvFile( bsvFile );
-      final CollectionMap<String, RareWordTerm> rareWordTermMap
+      final Collection<CuiTerm> cuiTerms = parseBsvFile( bsvFile );
+      final CollectionMap<String, RareWordTerm, ? extends Collection<RareWordTerm>> rareWordTermMap
             = RareWordTermMapCreator.createRareWordTermMap( cuiTerms );
       _delegateDictionary = new MemRareWordDictionary( name, rareWordTermMap );
    }
@@ -111,17 +113,16 @@ final public class BsvRareWordDictionary
     * @param bsvFile file containing term rows and bsv columns
     * @return collection of all valid terms read from the bsv file
     */
-   static private Collection<RareWordTermMapCreator.CuiTerm> parseBsvFile( final File bsvFile ) {
-      final Collection<RareWordTermMapCreator.CuiTerm> cuiTerms = new ArrayList<>();
-      try {
-         final BufferedReader reader = new BufferedReader( new FileReader( bsvFile ) );
+   static private Collection<CuiTerm> parseBsvFile( final File bsvFile ) {
+      final Collection<CuiTerm> cuiTerms = new ArrayList<>();
+      try ( final BufferedReader reader = new BufferedReader( new FileReader( bsvFile ) ) ) {
          String line = reader.readLine();
          while ( line != null ) {
             if ( line.startsWith( "//" ) || line.startsWith( "#" ) ) {
                continue;
             }
             final String[] columns = LookupUtil.fastSplit( line, '|' );
-            final RareWordTermMapCreator.CuiTerm cuiTerm = createCuiTuiTerm( columns );
+            final CuiTerm cuiTerm = createCuiTuiTerm( columns );
             if ( cuiTerm != null ) {
                // Add to the dictionary
                cuiTerms.add( cuiTerm );
@@ -141,7 +142,7 @@ final public class BsvRareWordDictionary
     * @param columns two or three columns representing CUI,Text or CUI,TUI,Text respectively
     * @return a term created from the columns or null if the columns are malformed
     */
-   static private RareWordTermMapCreator.CuiTerm createCuiTuiTerm( final String[] columns ) {
+   static private CuiTerm createCuiTuiTerm( final String... columns ) {
       if ( columns.length < 2 ) {
          return null;
       }
@@ -151,12 +152,12 @@ final public class BsvRareWordDictionary
          // second column is a tui, so text is in the third column
          termIndex = 2;
       }
-      if ( columns[cuiIndex].trim().isEmpty() || columns[termIndex].trim().isEmpty() ) {
+      if ( columns[ cuiIndex ].trim().isEmpty() || columns[ termIndex ].trim().isEmpty() ) {
          return null;
       }
-      final String cui = columns[cuiIndex];
-      final String term = columns[termIndex].trim().toLowerCase();
-      return new RareWordTermMapCreator.CuiTerm( cui, term );
+      final String cui = columns[ cuiIndex ];
+      final String term = columns[ termIndex ].trim().toLowerCase();
+      return new CuiTerm( cui, term );
    }
 
 }

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=1627792&r1=1627791&r2=1627792&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 Fri Sep 26 14:20:36 2014
@@ -44,12 +44,7 @@ import java.util.*;
  * If there is a problem with the descriptor then the whole pipeline goes down, so care must be taken by the User
  * and any messages (logged or otherwise) produced by this class should be as specific as possible.  Devs take notice.
  * <p/>
- * TODO
- * This parser can create a RareWordDictionary by wrapping the older Jdbc, Lucene, StringTable (CSV) descriptors.
- * However, to prevent the dependency upon the current Dictionary-Lookup module and its "Dictionary" interface,
- * all such code has been commented out.  Uncommenting, linking, and rebuilding is possible if use of an older dictionary
- * resource is required.
- * TODO
+ * <p/>
  * Author: SPF
  * Affiliation: CHIP-NLP
  * Date: 11/20/13
@@ -65,83 +60,43 @@ final public class DictionaryDescriptorP
    private DictionaryDescriptorParser() {
    }
 
+
+   static private final Object[] EMPTY_OBJECT_ARRAY = new Object[ 0 ];
+
    /**
     * XML keys specifying the main sections that define dictionaries, concept factories, and the pairing of the two
     */
    static private final String DICTIONARIES_KEY = "dictionaries";
    static private final String CONCEPT_FACTORIES_KEY = "conceptFactories";
    static private final String PAIRS_KEY = "dictionaryConceptPairs";
-
-
    /**
-    * Each {@link RareWordDictionary} should have an id that specifies a unique name for that dictionary
+    * XML key specifying the section that defines the single
+    * {@link org.apache.ctakes.dictionary.lookup2.consumer.TermConsumer} that should be used to consume discovered terms.
     */
-   static private final String NAME_ID = "id";
+   static private final String CONSUMER_KEY = "rareWordConsumer";
+
    /**
-    * Each {@link RareWordDictionary} must have an external resource specified by the
-    * {@code configurableDataResourceSpecifier} in the XML descriptor for the Rare Word Term Lookup Annotator
-    * {@link org.apache.ctakes.dictionary.lookup2.ae.DefaultJCasTermAnnotator}.
-    * The external resource <i>does not</i> need to be unique for each dictionary.
-    */
-   static private final String EXTERNAL_RESOURCE = "externalResourceKey";
-   /**
-    * Each {@link RareWordDictionary} can utilize or ignore the case of terms.   In most situations case sensitivity
-    * is not beneficial, but it may be for some.  For instance, if it is an acronym dictionary then differentiating
-    * between "WHO" (World Health Organization) and "who" is important.
-    * The {@link org.apache.ctakes.dictionary.lookup2.ae.DefaultJCasTermAnnotator}
-    * does ignores case and ignores this setting
-    */
-   static private final String CASE_SENSITIVE = "caseSensitive";
-   /**
-    * Each {@link RareWordDictionary} should have a numerical {@code typeId} that indicates the semantic group
-    * to which the terms in the dictionary belong.  The standard cTakes type ids are numerical and listed in
-    * {*link org.apache.ctakes.typesystem.type.constants.CONST} as
-    * <ul>
-    * <li>0  Unknown</li>
-    * <li>1  Medication / Drug</li>
-    * <li>2  Disease / Disorder</li>
-    * <li>3  Sign / Symptom (Finding)</li>
-    * <li>4  <i>Not Defined</i></li>
-    * <li>5  Procedure</li>
-    * <li>6  Anatomical Site</li>
-    * <li>7  Clinical Attribute</li>
-    * <li>8  Device</li>
-    * <li>9  Lab</li>
-    * <li>10 Phenomena</li>
-    * </ul>
-    * In truth, any coding scheme (Numerical or otherwise) can be used as long as a {@link org.apache.ctakes.dictionary.lookup2.consumer.TermConsumer}
-    * is created to use it. That being said ...
-    */
-   private static final String TYPE_ID = "typeId";
-   /**
-    * Each {@link RareWordDictionary} must have a java implementation.
-    * It is best if this is a {@link RareWordDictionary},
-    * but it can also be an older org apache ctakes dictionary lookup Dictionary, in which case a
-    * org apache ctakes dictionary lookup2 dictionary RareWordDictionaryWrapper will be used.
-    * <p>The available implementation keys are:</p>
-    * <ul>
-    * <li>rareWordJdbc</li>
-    * <li>rareWordUmls</li>
-    * <li>rareWordBsv</li>
-    * <li>luceneImpl</li>
-    * <li>jdbcImpl</li>
-    * <li>csvImpl</li>
-    * </ul>
+    * Each dictionary, concept factory, pairing and term consumer should have a unique name
     */
-   private static final String IMPLEMENTATION = "implementation";
+   static private final String NAME_KEY = "name";
 
    /**
-    * XML key specifying the section that defines the single
-    * {@link org.apache.ctakes.dictionary.lookup2.concept.ConceptFactory} that should be used to create concepts for discovered terms.
+    * Each {@link org.apache.ctakes.dictionary.lookup2.dictionary.RareWordDictionary},
+    * {@link org.apache.ctakes.dictionary.lookup2.concept.ConceptFactory},
+    * and {@link org.apache.ctakes.dictionary.lookup2.consumer.TermConsumer} must have a java implementation.
     */
-   static private final String CONCEPTS_KEY = "conceptFactory";
+   private static final String IMPLEMENTATION_KEY = "implementationName";
 
+   /**
+    * pairings must have specified dictionaries and concept factories
+    */
+   static private final String PAIR_DICTIONARY_NAME = "dictionaryName";
+   static private final String PAIR_CONCEPT_FACTORY_NAME = "conceptFactoryName";
 
    /**
-    * XML key specifying the section that defines the single {@link org.apache.ctakes.dictionary.lookup2.consumer.TermConsumer} that should be used to
-    * consume discovered terms.
+    * everything else is implementation-specific and therefore optional and therefore set as a property
     */
-   static private final String CONSUMER_KEY = "rareWordConsumer";
+   static private final String PROPERTIES_KEY = "properties";
 
    // Added 'maxListSize'.  Size equals max int by default  - used for lucene dictionaries
    private static int MAX_LIST_SIZE = Integer.MAX_VALUE; //ohnlp-Bugs-3296301
@@ -165,16 +120,17 @@ final public class DictionaryDescriptorP
       try {
          doc = saxBuilder.build( descriptorFile );
       } catch ( JDOMException | IOException jdomioE ) {
-         throw new AnnotatorContextException( "Could not parse " + descriptorFile.getPath(), new Object[ 0 ], jdomioE );
+         throw new AnnotatorContextException(
+               "Could not parse " + descriptorFile.getPath(), EMPTY_OBJECT_ARRAY, jdomioE );
       }
       final Map<String, RareWordDictionary> dictionaries
             = parseDictionaries( uimaContext, doc.getRootElement().getChild( DICTIONARIES_KEY ) );
       final Map<String, ConceptFactory> conceptFactories
             = parseConceptFactories( uimaContext, doc.getRootElement().getChild( CONCEPT_FACTORIES_KEY ) );
       final Map<String, String> pairDictionaryNames
-            = parsePairingNames( doc.getRootElement().getChild( PAIRS_KEY ), "dictionaryName" );
+            = parsePairingNames( doc.getRootElement().getChild( PAIRS_KEY ), PAIR_DICTIONARY_NAME );
       final Map<String, String> pairConceptFactoryNames
-            = parsePairingNames( doc.getRootElement().getChild( PAIRS_KEY ), "conceptFactoryName" );
+            = parsePairingNames( doc.getRootElement().getChild( PAIRS_KEY ), PAIR_CONCEPT_FACTORY_NAME );
       final TermConsumer consumer = parseConsumerXml( uimaContext, doc.getRootElement().getChild( CONSUMER_KEY ) );
       return new DefaultDictionarySpec( pairDictionaryNames, pairConceptFactoryNames, dictionaries, conceptFactories,
             consumer );
@@ -219,17 +175,17 @@ final public class DictionaryDescriptorP
       final Class[] constructionArgs = { String.class, UimaContext.class, Properties.class };
 
       final String name = getName( "Dictionary Name", dictionaryElement );
-      final String className = dictionaryElement.getChildText( "implementationName" );
-      final Element propertiesElement = dictionaryElement.getChild( "properties" );
+      final String className = dictionaryElement.getChildText( IMPLEMENTATION_KEY );
+      final Element propertiesElement = dictionaryElement.getChild( PROPERTIES_KEY );
       final Properties properties = parsePropertiesXml( propertiesElement );
       Class dictionaryClass;
       try {
          dictionaryClass = Class.forName( className );
       } catch ( ClassNotFoundException cnfE ) {
-         throw new AnnotatorContextException( "Unknown class " + className, new Object[ 0 ], cnfE );
+         throw new AnnotatorContextException( "Unknown class " + className, EMPTY_OBJECT_ARRAY, cnfE );
       }
       if ( !RareWordDictionary.class.isAssignableFrom( dictionaryClass ) ) {
-         throw new AnnotatorContextException( className + " is not a Rare Word Dictionary", new Object[ 0 ] );
+         throw new AnnotatorContextException( className + " is not a Rare Word Dictionary", EMPTY_OBJECT_ARRAY );
       }
       final Constructor[] constructors = dictionaryClass.getConstructors();
       for ( Constructor constructor : constructors ) {
@@ -239,10 +195,10 @@ final public class DictionaryDescriptorP
                return (RareWordDictionary)constructor.newInstance( args );
             }
          } catch ( InstantiationException | IllegalAccessException | InvocationTargetException iniaitE ) {
-            throw new AnnotatorContextException( "Could not construct " + className, new Object[ 0 ], iniaitE );
+            throw new AnnotatorContextException( "Could not construct " + className, EMPTY_OBJECT_ARRAY, iniaitE );
          }
       }
-      throw new AnnotatorContextException( "No Constructor for " + className, new Object[ 0 ] );
+      throw new AnnotatorContextException( "No Constructor for " + className, EMPTY_OBJECT_ARRAY );
    }
 
 
@@ -284,17 +240,17 @@ final public class DictionaryDescriptorP
          throws AnnotatorContextException {
       final Class[] constructionArgs = { String.class, UimaContext.class, Properties.class };
       final String name = getName( "Concept Factory Name", conceptFactoryElement );
-      final String className = conceptFactoryElement.getChildText( "implementationName" );
-      final Element propertiesElement = conceptFactoryElement.getChild( "properties" );
+      final String className = conceptFactoryElement.getChildText( IMPLEMENTATION_KEY );
+      final Element propertiesElement = conceptFactoryElement.getChild( PROPERTIES_KEY );
       final Properties properties = parsePropertiesXml( propertiesElement );
       Class conceptFactoryClass;
       try {
          conceptFactoryClass = Class.forName( className );
       } catch ( ClassNotFoundException cnfE ) {
-         throw new AnnotatorContextException( "Unknown class " + className, new Object[ 0 ], cnfE );
+         throw new AnnotatorContextException( "Unknown class " + className, EMPTY_OBJECT_ARRAY, cnfE );
       }
       if ( !ConceptFactory.class.isAssignableFrom( conceptFactoryClass ) ) {
-         throw new AnnotatorContextException( className + " is not a Concept Factory", new Object[ 0 ] );
+         throw new AnnotatorContextException( className + " is not a Concept Factory", EMPTY_OBJECT_ARRAY );
       }
       final Constructor[] constructors = conceptFactoryClass.getConstructors();
       for ( Constructor constructor : constructors ) {
@@ -304,10 +260,10 @@ final public class DictionaryDescriptorP
                return (ConceptFactory)constructor.newInstance( args );
             }
          } catch ( InstantiationException | IllegalAccessException | InvocationTargetException iniaitE ) {
-            throw new AnnotatorContextException( "Could not construct " + className, new Object[ 0 ], iniaitE );
+            throw new AnnotatorContextException( "Could not construct " + className, EMPTY_OBJECT_ARRAY, iniaitE );
          }
       }
-      throw new AnnotatorContextException( "No Constructor for " + className, new Object[ 0 ] );
+      throw new AnnotatorContextException( "No Constructor for " + className, EMPTY_OBJECT_ARRAY );
    }
 
 
@@ -332,101 +288,13 @@ final public class DictionaryDescriptorP
    }
 
    static private String getName( final String elementName, final Element element ) throws AnnotatorContextException {
-      final String name = element.getChildText( "name" );
+      final String name = element.getChildText( NAME_KEY );
       if ( name == null || name.isEmpty() ) {
-         throw new AnnotatorContextException( "Missing name for " + elementName, new Object[ 0 ] );
+         throw new AnnotatorContextException( "Missing name for " + elementName, EMPTY_OBJECT_ARRAY );
       }
       return name;
    }
 
-
-//
-//
-//
-//
-//   /**
-//    * Creates a dictionary by parsing each child element of {@link this.DICTIONARIES_KEY}
-//    *
-//    * @param uimaContext       -
-//    * @param dictionaryElement contains the definition of a single dictionary
-//    * @return a dictionary or null if there is a problem
-//    * @throws AnnotatorContextException if any of a dozen things goes wrong
-//    */
-//   private static RareWordDictionary parseDictionaryXml( final UimaContext uimaContext,
-//                                                         final Element dictionaryElement )
-//         throws AnnotatorContextException {
-//      final String externalResourceKey = dictionaryElement.getAttributeValue( EXTERNAL_RESOURCE );
-//      final Boolean keepCase = Boolean.valueOf( dictionaryElement.getAttributeValue( CASE_SENSITIVE ) );
-//      final String entityTypeId = dictionaryElement.getAttributeValue( TYPE_ID );
-//      Object externalResource;
-//      try {
-//         externalResource = uimaContext.getResourceObject( externalResourceKey );
-//      } catch ( ResourceAccessException raE ) {
-//         throw new AnnotatorContextException( "Could not access external resource " + externalResourceKey,
-//                                              new Object[0], raE );
-//      }
-//      if ( externalResource == null ) {
-//         throw new AnnotatorContextException( "Could not find external resource " + externalResourceKey,
-//                                              new Object[0] );
-//      }
-//      RareWordDictionary dictionary = null;
-//      final Element implementationElement = (Element) dictionaryElement.getChild( IMPLEMENTATION ).getChildren().get( 0 );
-//      final String implementationName = implementationElement.getName();
-//      if ( implementationName.equals( "rareWordJdbc" ) ) {
-//         dictionary = DictionaryFactory.createRareWordJdbc( implementationElement,
-//                                                            externalResource,
-//                                                            entityTypeId );
-//      } else if ( implementationName.equals( "rareWordUmls" ) ) {
-//         // TODO move umls info to the dictionary descriptor and parse parameter values here
-//         // final String externalResourceKey = dictionaryElement.getAttributeValue( EXTERNAL_RESOURCE );
-//         // TODO eventually move the umls dictionary download to a secure server with password protection
-//         try {
-//            // TODO attempt user etc. fetch from uimaContext.  If empty, attempt fetch from dictionaryElement
-//            UmlsUserApprover.validateUMLSUser( uimaContext );
-//            dictionary = DictionaryFactory.createRareWordJdbc( implementationElement,
-//                                                               externalResource,
-//                                                               entityTypeId );
-//         } catch ( ResourceInitializationException riE ) {
-//            throw new AnnotatorContextException( riE );
-//         }
-//      } else if ( implementationName.equals( "rareWordBsv" ) ) {
-//         dictionary = DictionaryFactory.createRareWordBsv( externalResourceKey, externalResource, entityTypeId );
-////      } else if ( implementationName.equals( "luceneImpl" ) ) {
-////         dictionary = DictionaryFactory.createWrappedLucene( dictionaryElement,
-////                                                                     externalResourceKey,
-////                                                                     externalResource,
-////                                                                     entityTypeId );
-////      } else if ( implementationName.equals( "jdbcImpl" ) ) {
-////         dictionary = DictionaryFactory.createWrappedJdbc( dictionaryElement,
-////                                                                   implementationElement,
-////                                                                   externalResourceKey,
-////                                                                   externalResource,
-////                                                                   entityTypeId );
-////      } else if ( implementationName.equals( "csvImp" ) ) {
-////         dictionary = DictionaryFactory.createWrappedCsv( dictionaryElement,
-////                                                                  implementationElement,
-////                                                                  externalResourceKey,
-////                                                                  externalResource,
-////                                                                  entityTypeId );
-//      } else {
-//         throw new AnnotatorContextException( "Unsupported dictionary implementation " + implementationName,
-//                                              new Object[0] );
-//      }
-//      if ( dictionary == null ) {
-//         throw new AnnotatorContextException( "No appropriate dictionary defined", new Object[0] );
-//      }
-//      // Deprecated -
-////      if ( dictionary instanceof Dictionary ) {
-////         final Collection metaFields = dictionaryElement.getChild( "metaFields" ).getChildren();
-////         for ( Object value : metaFields ) {
-////            String metaFieldName = ((Element) value).getAttributeValue( "fieldName" );
-////            ((Dictionary) dictionary).retainMetaData( metaFieldName );
-////         }
-////      }
-//      return dictionary;
-//   }
-
-
    /**
     * Creates a term consumer by parsing section defined by {@link this.CONSUMER_KEY}
     *
@@ -441,18 +309,17 @@ final public class DictionaryDescriptorP
       Class[] constrArgsConsum = { UimaContext.class, Properties.class, int.class };//ohnlp-Bugs-3296301
       Class[] constrArgsConsumB = { UimaContext.class, Properties.class };
 
-      String consumerClassName = lookupConsumerElement.getChildText( "implementationName" );
-      Element consumerPropertiesElement = lookupConsumerElement.getChild( "properties" );
+      String consumerClassName = lookupConsumerElement.getChildText( IMPLEMENTATION_KEY );
+      Element consumerPropertiesElement = lookupConsumerElement.getChild( PROPERTIES_KEY );
       Properties consumerProperties = parsePropertiesXml( consumerPropertiesElement );
       Class consumerClass;
       try {
          consumerClass = Class.forName( consumerClassName );
       } catch ( ClassNotFoundException cnfE ) {
-         throw new AnnotatorContextException( "Unknown class " + consumerClassName, new Object[ 0 ], cnfE );
+         throw new AnnotatorContextException( "Unknown class " + consumerClassName, EMPTY_OBJECT_ARRAY, cnfE );
       }
       if ( !TermConsumer.class.isAssignableFrom( consumerClass ) ) {
-         throw new AnnotatorContextException( consumerClassName + " is not a TermConsumer",
-               new Object[ 0 ] );
+         throw new AnnotatorContextException( consumerClassName + " is not a TermConsumer", EMPTY_OBJECT_ARRAY );
       }
       final Constructor[] constructors = consumerClass.getConstructors();
       for ( Constructor constructor : constructors ) {
@@ -466,10 +333,11 @@ final public class DictionaryDescriptorP
                return (TermConsumer)constructor.newInstance( args );
             }
          } catch ( InstantiationException | IllegalAccessException | InvocationTargetException multE ) {
-            throw new AnnotatorContextException( "Could not construct " + consumerClassName, new Object[ 0 ], multE );
+            throw new AnnotatorContextException(
+                  "Could not construct " + consumerClassName, EMPTY_OBJECT_ARRAY, multE );
          }
       }
-      throw new AnnotatorContextException( "No Constructor for " + consumerClassName, new Object[ 0 ] );
+      throw new AnnotatorContextException( "No Constructor for " + consumerClassName, EMPTY_OBJECT_ARRAY );
    }
 
    /**

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/MemRareWordDictionary.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/MemRareWordDictionary.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/MemRareWordDictionary.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/MemRareWordDictionary.java Fri Sep 26 14:20:36 2014
@@ -33,7 +33,7 @@ import java.util.Collection;
 final public class MemRareWordDictionary extends AbstractRareWordDictionary {
 
    // Map of rare tokens to terms that contain those tokens.  Used like "First Word Token Lookup" but faster
-   final private CollectionMap<String, RareWordTerm> _rareWordTermMap;
+   final private CollectionMap<String, RareWordTerm, ? extends Collection<RareWordTerm>> _rareWordTermMap;
 
    /**
     * {@inheritDoc}
@@ -41,7 +41,7 @@ final public class MemRareWordDictionary
     * @param rareWordTermMap Map with a Rare Word (tokens) as key, and RareWordTerm Collection as value
     */
    public MemRareWordDictionary( final String name,
-                                 final CollectionMap<String, RareWordTerm> rareWordTermMap ) {
+                                 final CollectionMap<String, RareWordTerm, ? extends Collection<RareWordTerm>> rareWordTermMap ) {
       super( name );
       _rareWordTermMap = rareWordTermMap;
    }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/RareWordTermMapCreator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/RareWordTermMapCreator.java?rev=1627792&r1=1627791&r2=1627792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/RareWordTermMapCreator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/dictionary/RareWordTermMapCreator.java Fri Sep 26 14:20:36 2014
@@ -21,11 +21,13 @@ package org.apache.ctakes.dictionary.loo
 import org.apache.ctakes.dictionary.lookup2.term.RareWordTerm;
 import org.apache.ctakes.dictionary.lookup2.util.CuiCodeUtil;
 import org.apache.ctakes.dictionary.lookup2.util.LookupUtil;
-import org.apache.ctakes.dictionary.lookup2.util.TuiCodeUtil;
 import org.apache.ctakes.dictionary.lookup2.util.collection.ArrayListMap;
 import org.apache.ctakes.dictionary.lookup2.util.collection.CollectionMap;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.logging.Logger;
 
 /**
@@ -147,8 +149,9 @@ final public class RareWordTermMapCreato
          "how", "where", "when", "however", "wherever", "whenever",
    };
 
-   static public CollectionMap<String, RareWordTerm> createRareWordTermMap( final Collection<CuiTerm> cuiTerms ) {
-      final CollectionMap<String, RareWordTerm> rareWordTermMap = new ArrayListMap<>();
+   static public CollectionMap<String, RareWordTerm, List<RareWordTerm>> createRareWordTermMap(
+         final Iterable<CuiTerm> cuiTerms ) {
+      final CollectionMap<String, RareWordTerm, List<RareWordTerm>> rareWordTermMap = new ArrayListMap<>();
       final Map<String, Integer> tokenCountMap = createTokenCountMap( cuiTerms );
       for ( CuiTerm cuiTerm : cuiTerms ) {
          final String rareWord = getRareWord( cuiTerm.getTerm(), tokenCountMap );
@@ -164,7 +167,7 @@ final public class RareWordTermMapCreato
       return rareWordTermMap;
    }
 
-   static private Map<String, Integer> createTokenCountMap( final Collection<CuiTerm> cuiTerms ) {
+   static private Map<String, Integer> createTokenCountMap( final Iterable<CuiTerm> cuiTerms ) {
       final Map<String, Integer> tokenCountMap = new HashMap<>();
       for ( CuiTerm cuiTerm : cuiTerms ) {
          final String[] tokens = LookupUtil.fastSplit( cuiTerm.getTerm(), ' ' );
@@ -185,9 +188,9 @@ final public class RareWordTermMapCreato
    static private String getRareWord( final String tokenizedTerm, final Map<String, Integer> tokenCountMap ) {
       final String[] tokens = LookupUtil.fastSplit( tokenizedTerm, ' ' );
       if ( tokens.length == 1 ) {
-         return tokens[0];
+         return tokens[ 0 ];
       }
-      String bestWord = tokens[0];
+      String bestWord = tokens[ 0 ];
       int bestCount = Integer.MAX_VALUE;
       for ( String token : tokens ) {
          if ( isRarableToken( token ) ) {



Mime
View raw message