ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1643953 - in /ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer: DefaultTermConsumer.java PrecisionTermConsumer.java SemanticCleanupTermConsumer.java TermConsumer.java
Date Mon, 08 Dec 2014 22:54:45 GMT
Author: seanfinan
Date: Mon Dec  8 22:54:44 2014
New Revision: 1643953

URL: http://svn.apache.org/r1643953
Log:
Implemented possible use of secondary coding schemes to add entries to the ontology array.
 For instance, without snomedct the ontology array holds 2 "cancer" entries.  With snomedct
it holds 16, add icd9 and you get 17.

Modified:
    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/SemanticCleanupTermConsumer.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/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=1643953&r1=1643952&r2=1643953&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 Dec  8 22:54:44 2014
@@ -54,7 +54,7 @@ final public class DefaultTermConsumer e
     * {@inheritDoc}
     */
    @Override
-   public void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
+   public void consumeTypeIdHits( final JCas jcas, final String defaultScheme, final int
cTakesSemantic,
                                   final CollectionMap<TextSpan, Long, ? extends Collection<Long>>
textSpanCuis,
                                   final CollectionMap<Long, Concept, ? extends Collection<Concept>>
cuiConcepts )
          throws AnalysisEngineProcessException {
@@ -64,7 +64,7 @@ final public class DefaultTermConsumer e
          for ( Map.Entry<TextSpan, ? extends Collection<Long>> spanCuis : textSpanCuis
) {
             umlsConceptList.clear();
             for ( Long cuiCode : spanCuis.getValue() ) {
-               umlsConceptList.addAll( createUmlsConcepts( jcas, codingScheme, cTakesSemantic,
cuiCode, cuiConcepts ) );
+               umlsConceptList.addAll( createUmlsConcepts( jcas, defaultScheme, cTakesSemantic,
cuiCode, cuiConcepts ) );
             }
             final FSArray conceptArr = new FSArray( jcas, umlsConceptList.size() );
             int arrIdx = 0;
@@ -111,48 +111,61 @@ final public class DefaultTermConsumer e
       return new EntityMention( jcas );
    }
 
-
    static private Collection<UmlsConcept> createUmlsConcepts( final JCas jcas,
-                                                              final String codingScheme,
+                                                              final String defaultScheme,
                                                               final int cTakesSemantic,
-                                                              final Long cui,
+                                                              final Long cuiCode,
                                                               final CollectionMap<Long,
Concept, ? extends Collection<Concept>> conceptMap ) {
-      final Collection<Concept> concepts = conceptMap.getCollection( cui );
+      final Collection<Concept> concepts = conceptMap.getCollection( cuiCode );
       if ( concepts == null || concepts.isEmpty() ) {
-         return Arrays.asList( createUmlsConcept( jcas, codingScheme, cui, null, null, null
) );
+         return Arrays.asList( createUmlsConcept( jcas, defaultScheme,
+               CuiCodeUtil.getAsCui( cuiCode ), null, null, null ) );
       }
       final Collection<UmlsConcept> umlsConcepts = new HashSet<>();
       for ( Concept concept : concepts ) {
-         final String preferredText = concept.getPreferredText();
-         // The cTakes Type System for UmlsConcepts is inadequate.
-         // A single Cui can have multiple Tuis, Snomed and RxNorm and icd codes.
-         // Adding -disconnected- Ontology concepts is not correct, as an ontology concept
such as snomed
-         // is actually connected to a cui, semantic type, preferredTerm - and cannot be
stored alone just for a span
          final Collection<String> tuis = concept.getCodes( ConceptCode.TUI );
          if ( !tuis.isEmpty() ) {
             for ( String tui : tuis ) {
                // the concept could have tuis outside this cTakes semantic group
                if ( SemanticUtil.getTuiSemanticGroupId( tui ) == cTakesSemantic ) {
-                  umlsConcepts.add( createUmlsConcept( jcas, codingScheme, cui, tui, preferredText,
null ) );
+                  umlsConcepts.addAll( createUmlsConcepts( jcas, defaultScheme, tui, concept
) );
                }
             }
          } else {
-            umlsConcepts.add( createUmlsConcept( jcas, codingScheme, cui, null, preferredText,
null ) );
+            umlsConcepts.addAll( createUmlsConcepts( jcas, defaultScheme, 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 ( ConceptCode secondaryScheme : ConceptCode.values() ) {
+         if ( secondaryScheme == ConceptCode.TUI ) {
+            continue;
+         }
+         final Collection<String> codes = concept.getCodes( secondaryScheme );
+         if ( codes == null || codes.isEmpty() ) {
+            continue;
+         }
+         for ( String code : codes ) {
+            concepts.add( createUmlsConcept( jcas, secondaryScheme.name(), concept.getCui(),
tui,
+                  concept.getPreferredText(), code ) );
+         }
+      }
+      if ( concepts.isEmpty() ) {
+         concepts.add( createUmlsConcept( jcas, defaultScheme, concept.getCui(), tui, concept.getPreferredText(),
null ) );
+      }
+      return concepts;
+   }
 
-   // The cTakes Type System UmlsConcepts is inadequate.
-   // A single Cui can have multiple Tuis, Snomed and RxNorm and icd codes.
-   // Propagating a handful of UmlsConcepts for a single Cui with multiple Snomeds creates
bloat
    static private UmlsConcept createUmlsConcept( final JCas jcas, final String codingScheme,
-                                                 final Long cuiCode, final String tui,
+                                                 final String cui, final String tui,
                                                  final String preferredText, final String
code ) {
       final UmlsConcept umlsConcept = new UmlsConcept( jcas );
       umlsConcept.setCodingScheme( codingScheme );
-      umlsConcept.setCui( CuiCodeUtil.getAsCui( cuiCode ) );
+      umlsConcept.setCui( cui );
       if ( tui != null ) {
          umlsConcept.setTui( tui );
       }
@@ -165,5 +178,4 @@ final public class DefaultTermConsumer e
       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=1643953&r1=1643952&r2=1643953&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 Dec  8 22:54:44 2014
@@ -52,13 +52,13 @@ final public class PrecisionTermConsumer
     * {@inheritDoc}
     */
    @Override
-   public void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
+   public void consumeTypeIdHits( final JCas jcas, final String defaultScheme, 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, ? extends Collection<Long>> preciseTerms
             = createPreciseTerms( semanticTerms );
-      _idHitConsumer.consumeTypeIdHits( jcas, codingScheme, cTakesSemantic, preciseTerms,
conceptMap );
+      _idHitConsumer.consumeTypeIdHits( jcas, defaultScheme, cTakesSemantic, preciseTerms,
conceptMap );
    }
 
 

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/SemanticCleanupTermConsumer.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/SemanticCleanupTermConsumer.java?rev=1643953&r1=1643952&r2=1643953&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/SemanticCleanupTermConsumer.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/consumer/SemanticCleanupTermConsumer.java
Mon Dec  8 22:54:44 2014
@@ -120,11 +120,11 @@ public class SemanticCleanupTermConsumer
     * {@inheritDoc}
     */
    @Override
-   public void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
+   public void consumeTypeIdHits( final JCas jcas, final String defaultScheme, final int
cTakesSemantic,
                                   final CollectionMap<TextSpan, Long, ? extends Collection<Long>>
semanticTerms,
                                   final CollectionMap<Long, Concept, ? extends Collection<Concept>>
conceptMap )
          throws AnalysisEngineProcessException {
-      _idHitConsumer.consumeTypeIdHits( jcas, codingScheme, cTakesSemantic, semanticTerms,
conceptMap );
+      _idHitConsumer.consumeTypeIdHits( jcas, defaultScheme, cTakesSemantic, semanticTerms,
conceptMap );
    }
 
 

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=1643953&r1=1643952&r2=1643953&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 Dec  8 22:54:44 2014
@@ -51,11 +51,11 @@ public interface TermConsumer {
 
    /**
     * @param jcas           -
-    * @param codingScheme   -
+    * @param defaultScheme  - 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 codingScheme, final int cTakesSemantic,
+   void consumeTypeIdHits( final JCas jcas, final String defaultScheme, final int cTakesSemantic,
                            final CollectionMap<TextSpan, Long, ? extends Collection<Long>>
textSpanCuis,
                            final CollectionMap<Long, Concept, ? extends Collection<Concept>>
cuiConcepts )
          throws AnalysisEngineProcessException;



Mime
View raw message