ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1705593 - in /ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2: concept/ consumer/
Date Mon, 28 Sep 2015 02:11:51 GMT
Author: seanfinan
Date: Mon Sep 28 02:11:50 2015
New Revision: 1705593

URL: http://svn.apache.org/viewvc?rev=1705593&view=rev
Log:
CTAKES-382  Adding "Concept Creator", at this time for extensions to UmlsConcept

Added:
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultUmlsConceptCreator.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/UmlsConceptCreator.java
Modified:
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/MemConceptFactory.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

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/MemConceptFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/MemConceptFactory.java?rev=1705593&r1=1705592&r2=1705593&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/MemConceptFactory.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/MemConceptFactory.java
Mon Sep 28 02:11:50 2015
@@ -2,6 +2,7 @@ package org.apache.ctakes.dictionary.loo
 
 import org.apache.ctakes.dictionary.lookup2.util.CuiCodeUtil;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -17,7 +18,7 @@ final public class MemConceptFactory ext
 
    public MemConceptFactory( final String name, final Map<Long, Concept> conceptMap
) {
       super( name );
-      _conceptMap = conceptMap;
+      _conceptMap = new HashMap<>( conceptMap );
    }
 
    /**

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=1705593&r1=1705592&r2=1705593&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
Mon Sep 28 02:11:50 2015
@@ -43,10 +43,12 @@ abstract public class AbstractTermConsum
 
    final private String _codingScheme;
 
+
    public AbstractTermConsumer( final UimaContext uimaContext, final Properties properties
) {
       _codingScheme = properties.getProperty( CODING_SCHEME_PRP_KEY );
    }
 
+
    /**
     * {@inheritDoc}
     */

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=1705593&r1=1705592&r2=1705593&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
Mon Sep 28 02:11:50 2015
@@ -44,9 +44,16 @@ import static org.apache.ctakes.typesyst
  */
 final public class DefaultTermConsumer extends AbstractTermConsumer {
 
+   final private UmlsConceptCreator _umlsConceptCreator;
 
    public DefaultTermConsumer( final UimaContext uimaContext, final Properties properties
) {
+      this( uimaContext, properties, new DefaultUmlsConceptCreator() );
+   }
+
+   public DefaultTermConsumer( final UimaContext uimaContext, final Properties properties,
+                               final UmlsConceptCreator umlsConceptCreator ) {
       super( uimaContext, properties );
+      _umlsConceptCreator = umlsConceptCreator;
    }
 
 
@@ -54,7 +61,7 @@ final public class DefaultTermConsumer e
     * {@inheritDoc}
     */
    @Override
-   public void consumeTypeIdHits( final JCas jcas, final String defaultScheme, final int
cTakesSemantic,
+   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 {
@@ -65,7 +72,7 @@ final public class DefaultTermConsumer e
             umlsConceptList.clear();
             for ( Long cuiCode : spanCuis.getValue() ) {
                umlsConceptList.addAll(
-                     createUmlsConcepts( jcas, defaultScheme, cTakesSemantic, cuiCode, cuiConcepts
) );
+                     createUmlsConcepts( jcas, codingScheme, cTakesSemantic, cuiCode, cuiConcepts
) );
             }
             final FSArray conceptArr = new FSArray( jcas, umlsConceptList.size() );
             int arrIdx = 0;
@@ -111,15 +118,15 @@ final public class DefaultTermConsumer e
       return new EntityMention( jcas );
    }
 
-   static private Collection<UmlsConcept> createUmlsConcepts( final JCas jcas,
-                                                              final String defaultScheme,
-                                                              final int cTakesSemantic,
-                                                              final Long cuiCode,
-                                                              final CollectionMap<Long,
Concept, ? extends Collection<Concept>> conceptMap ) {
+   private Collection<UmlsConcept> createUmlsConcepts( final JCas jcas,
+                                                       final String codingScheme,
+                                                       final int cTakesSemantic,
+                                                       final Long cuiCode,
+                                                       final CollectionMap<Long, Concept,
? extends Collection<Concept>> conceptMap ) {
       final Collection<Concept> concepts = conceptMap.getCollection( cuiCode );
       if ( concepts == null || concepts.isEmpty() ) {
-         return Arrays.asList( createUmlsConcept( jcas, defaultScheme,
-               CuiCodeUtil.getInstance().getAsCui( cuiCode ), null, null, null ) );
+         return Collections.singletonList( createSimpleUmlsConcept( jcas, codingScheme,
+               CuiCodeUtil.getInstance().getAsCui( cuiCode ) ) );
       }
       final Collection<UmlsConcept> umlsConcepts = new HashSet<>();
       for ( Concept concept : concepts ) {
@@ -128,54 +135,62 @@ final public class DefaultTermConsumer e
             for ( String tui : tuis ) {
                // the concept could have tuis outside this cTakes semantic group
                if ( SemanticUtil.getTuiSemanticGroupId( tui ) == cTakesSemantic ) {
-                  umlsConcepts.addAll( createUmlsConcepts( jcas, defaultScheme, tui, concept
) );
+                  umlsConcepts.addAll( _umlsConceptCreator.createUmlsConcepts( jcas, codingScheme,
tui, concept ) );
                }
             }
          } else {
-            umlsConcepts.addAll( createUmlsConcepts( jcas, defaultScheme, null, concept )
);
+            umlsConcepts.addAll( _umlsConceptCreator.createUmlsConcepts( jcas, codingScheme,
null, concept ) );
          }
       }
       return umlsConcepts;
    }
 
-   static private Collection<UmlsConcept> createUmlsConcepts( final JCas jcas, final
String defaultScheme,
-                                                              final String tui, final Concept
concept ) {
-      final Collection<UmlsConcept> concepts = new ArrayList<>();
-      for ( String codeName : concept.getCodeNames() ) {
-         if ( codeName.equals( Concept.TUI ) ) {
-            continue;
-         }
-         final Collection<String> codes = concept.getCodes( codeName );
-         if ( codes == null || codes.isEmpty() ) {
-            continue;
-         }
-         for ( String code : codes ) {
-            concepts.add( createUmlsConcept( jcas, codeName, concept.getCui(), tui,
-                  concept.getPreferredText(), code ) );
-         }
-      }
-      if ( concepts.isEmpty() ) {
-         concepts.add( createUmlsConcept( jcas, defaultScheme, concept.getCui(), tui,
-               concept.getPreferredText(), null ) );
-      }
-      return concepts;
-   }
+//   static private Collection<UmlsConcept> createUmlsConcepts( final JCas jcas, final
String defaultScheme,
+//                                                              final String tui, final Concept
concept ) {
+//      final Collection<UmlsConcept> concepts = new ArrayList<>();
+//      for ( String codeName : concept.getCodeNames() ) {
+//         if ( codeName.equals( Concept.TUI ) ) {
+//            continue;
+//         }
+//         final Collection<String> codes = concept.getCodes( codeName );
+//         if ( codes == null || codes.isEmpty() ) {
+//            continue;
+//         }
+//         for ( String code : codes ) {
+//            concepts.add( createUmlsConcept( jcas, codeName, concept.getCui(), tui,
+//                  concept.getPreferredText(), code ) );
+//         }
+//      }
+//      if ( concepts.isEmpty() ) {
+//         concepts.add( createUmlsConcept( jcas, defaultScheme, concept.getCui(), tui,
+//               concept.getPreferredText(), null ) );
+//      }
+//      return concepts;
+//   }
+
+//   static private UmlsConcept createUmlsConcept( final JCas jcas, final String codingScheme,
+//                                                 final String cui, final String tui,
+//                                                 final String preferredText, final String
code ) {
+//      final UmlsConcept umlsConcept = new UmlsConcept( jcas );
+//      umlsConcept.setCodingScheme( codingScheme );
+//      umlsConcept.setCui( cui );
+//      if ( tui != null ) {
+//         umlsConcept.setTui( tui );
+//      }
+//      if ( preferredText != null && !preferredText.isEmpty() ) {
+//         umlsConcept.setPreferredText( preferredText );
+//      }
+//      if ( code != null ) {
+//         umlsConcept.setCode( code );
+//      }
+//      return umlsConcept;
+//   }
+
 
-   static private UmlsConcept createUmlsConcept( final JCas jcas, final String codingScheme,
-                                                 final String cui, final String tui,
-                                                 final String preferredText, final String
code ) {
+   static private UmlsConcept createSimpleUmlsConcept( final JCas jcas, final String codingScheme,
final String cui ) {
       final UmlsConcept umlsConcept = new UmlsConcept( jcas );
       umlsConcept.setCodingScheme( codingScheme );
       umlsConcept.setCui( cui );
-      if ( tui != null ) {
-         umlsConcept.setTui( tui );
-      }
-      if ( preferredText != null && !preferredText.isEmpty() ) {
-         umlsConcept.setPreferredText( preferredText );
-      }
-      if ( code != null ) {
-         umlsConcept.setCode( code );
-      }
       return umlsConcept;
    }
 

Added: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultUmlsConceptCreator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultUmlsConceptCreator.java?rev=1705593&view=auto
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultUmlsConceptCreator.java
(added)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/DefaultUmlsConceptCreator.java
Mon Sep 28 02:11:50 2015
@@ -0,0 +1,65 @@
+package org.apache.ctakes.dictionary.lookup2.consumer;
+
+import org.apache.ctakes.dictionary.lookup2.concept.Concept;
+import org.apache.ctakes.typesystem.type.refsem.UmlsConcept;
+import org.apache.uima.jcas.JCas;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.logging.Logger;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 9/24/2015
+ */
+final public class DefaultUmlsConceptCreator implements UmlsConceptCreator {
+
+   static private final Logger LOGGER = Logger.getLogger( "DefaultUmlsConceptCreator" );
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Collection<UmlsConcept> createUmlsConcepts( final JCas jcas, final String
codingScheme,
+                                                      final String tui, final Concept concept
) {
+      final Collection<UmlsConcept> concepts = new ArrayList<>();
+      for ( String codeName : concept.getCodeNames() ) {
+         if ( codeName.equals( Concept.TUI ) ) {
+            continue;
+         }
+         final Collection<String> codes = concept.getCodes( codeName );
+         if ( codes == null || codes.isEmpty() ) {
+            continue;
+         }
+         for ( String code : codes ) {
+            concepts.add( createUmlsConcept( jcas, codeName, concept.getCui(), tui,
+                  concept.getPreferredText(), code ) );
+         }
+      }
+      if ( concepts.isEmpty() ) {
+         concepts.add( createUmlsConcept( jcas, codingScheme, concept.getCui(), tui,
+               concept.getPreferredText(), null ) );
+      }
+      return concepts;
+   }
+
+   static private UmlsConcept createUmlsConcept( final JCas jcas, final String codingScheme,
+                                                 final String cui, final String tui,
+                                                 final String preferredText, final String
code ) {
+      final UmlsConcept umlsConcept = new UmlsConcept( jcas );
+      umlsConcept.setCodingScheme( codingScheme );
+      umlsConcept.setCui( cui );
+      if ( tui != null ) {
+         umlsConcept.setTui( tui );
+      }
+      if ( preferredText != null && !preferredText.isEmpty() ) {
+         umlsConcept.setPreferredText( preferredText );
+      }
+      if ( code != null ) {
+         umlsConcept.setCode( code );
+      }
+      return umlsConcept;
+   }
+
+}

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=1705593&r1=1705592&r2=1705593&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
Mon Sep 28 02:11:50 2015
@@ -46,6 +46,12 @@ final public class PrecisionTermConsumer
       _idHitConsumer = new DefaultTermConsumer( uimaContext, properties );
    }
 
+   public PrecisionTermConsumer( final UimaContext uimaContext, final Properties properties,
+                                 final UmlsConceptCreator umlsConceptCreator ) {
+      super( uimaContext, properties );
+      _idHitConsumer = new DefaultTermConsumer( uimaContext, properties, umlsConceptCreator
);
+   }
+
 
    /**
     * Only uses the largest spans for the type

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=1705593&r1=1705592&r2=1705593&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
Mon Sep 28 02:11:50 2015
@@ -51,11 +51,11 @@ public interface TermConsumer {
 
    /**
     * @param jcas           -
-    * @param defaultScheme  - name of the coding scheme to use if no secondary (snomed, rxnorm)
schemes exist
+    * @param codingScheme   - name of the coding scheme to use if no secondary (snomed, rxnorm)
schemes exist
     * @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 defaultScheme, final int cTakesSemantic,
+   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;

Added: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/UmlsConceptCreator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/UmlsConceptCreator.java?rev=1705593&view=auto
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/UmlsConceptCreator.java
(added)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/UmlsConceptCreator.java
Mon Sep 28 02:11:50 2015
@@ -0,0 +1,21 @@
+package org.apache.ctakes.dictionary.lookup2.consumer;
+
+
+import org.apache.ctakes.dictionary.lookup2.concept.Concept;
+import org.apache.ctakes.typesystem.type.refsem.UmlsConcept;
+import org.apache.uima.jcas.JCas;
+
+import java.util.Collection;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 9/24/2015
+ */
+public interface UmlsConceptCreator {
+
+
+   Collection<UmlsConcept> createUmlsConcepts( final JCas jcas, final String codingScheme,
+                                               final String tui, final Concept concept );
+
+}



Mime
View raw message