You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by se...@apache.org on 2018/03/28 15:34:24 UTC
svn commit: r1827922 - in /ctakes/trunk:
ctakes-core/src/main/java/org/apache/ctakes/core/ae/LabValueFinder.java
ctakes-regression-test/src/test/java/org/apache/ctakes/core/ae/LabValueFinderTester.java
Author: seanfinan
Date: Wed Mar 28 15:34:24 2018
New Revision: 1827922
URL: http://svn.apache.org/viewvc?rev=1827922&view=rev
Log:
CTAKES - 441 : adding the ability to use drugs in addition to labs.
Modified:
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/LabValueFinder.java
ctakes/trunk/ctakes-regression-test/src/test/java/org/apache/ctakes/core/ae/LabValueFinderTester.java
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/LabValueFinder.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/LabValueFinder.java?rev=1827922&r1=1827921&r2=1827922&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/LabValueFinder.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/LabValueFinder.java Wed Mar 28 15:34:24 2018
@@ -52,6 +52,7 @@ final public class LabValueFinder extend
public static final int DEFAULT_MAX_LINE_COUNT = 2;
public static final String PARAM_LAB_TUIS = "labTUIs";
public static final String PARAM_LAB_X_CUIS = "excludeCUIs";
+ public static final String PARAM_USE_DRUGS = "useDrugs";
static private final String[] REQUIRED_SECTIONS = { "2.16.840.1.113883.10.20.22.2.3.1" };
static private final String[] REQUIRED_VALUE_WORDS = { "positive", "negative", "elevated", "normal", "increased", "decreased" };
@@ -105,6 +106,13 @@ final public class LabValueFinder extend
private String[] _excludeCuis;
private Collection<String> excludeCuis;
+ @ConfigurationParameter( name = PARAM_USE_DRUGS,
+ description = "Use Medications in addition to Labs.",
+ defaultValue = "false",
+ mandatory = false )
+ private String _useDrugsText;
+ private boolean _useDrugs;
+
/**
* {@inheritDoc}
*/
@@ -119,6 +127,7 @@ final public class LabValueFinder extend
valueWords = gatherParameters( REQUIRED_VALUE_WORDS, _valueWords );
labTuis = gatherParameters( REQUIRED_LAB_TUIS, _labTuis );
excludeCuis = gatherParameters( REQUIRED_EXCLUDE_CUIS, _excludeCuis );
+ _useDrugs = Boolean.parseBoolean( _useDrugsText );
LOGGER.debug( PARAM_MAX_NEWLINES + " = " + maxLineCount );
LOGGER.info( labTuis.size() + " lab TUIs: " + labTuis.toString() );
@@ -171,7 +180,7 @@ final public class LabValueFinder extend
* @return Existing and extracted LabMentions in the segment.
*/
private List<LabMention> annotateMentions( final JCas jCas, final Segment segment ) {
- final List<LabMention> labMentions = new ArrayList<>();
+ final List<LabMention> unvaluedLabMentions = new ArrayList<>();
for ( IdentifiedAnnotation annotation : JCasUtil.selectCovered( jCas, IdentifiedAnnotation.class, segment ) ) {
// first check to see if the annotation is a lab mention.
if ( LabMention.class.isInstance( annotation ) ) {
@@ -185,10 +194,18 @@ final public class LabValueFinder extend
initValueRelation( jCas, (LabMention) annotation );
}
// add the LabMention and move on.
- labMentions.add( (LabMention) annotation );
+ unvaluedLabMentions.add( (LabMention)annotation );
continue;
}
// Annotation was not a LabMention, but check to see if any part of it can be.
+ if ( _useDrugs && MedicationMention.class.isInstance( annotation ) ) {
+ LOGGER.info( "Using Drug " + annotation.getCoveredText() );
+ // We have valid lab concepts in the annotation. Create an overlapping LabMention with those concepts.
+ final LabMention lab = createLabMention( jCas,
+ OntologyConceptUtil.getUmlsConcepts( annotation ), annotation.getBegin(), annotation.getEnd() );
+ unvaluedLabMentions.add( lab );
+ }
+ // Check using hardcoded extra concept types.
final Collection<UmlsConcept> validConcepts
= OntologyConceptUtil.getUmlsConceptStream( annotation )
.filter( c -> labTuis.contains( c.getTui() ) )
@@ -198,9 +215,9 @@ final public class LabValueFinder extend
}
// We have valid lab concepts in the annotation. Create an overlapping LabMention with those concepts.
final LabMention lab = createLabMention( jCas, validConcepts, annotation.getBegin(), annotation.getEnd() );
- labMentions.add( lab );
+ unvaluedLabMentions.add( lab );
}
- return labMentions;
+ return unvaluedLabMentions;
}
/**
Modified: ctakes/trunk/ctakes-regression-test/src/test/java/org/apache/ctakes/core/ae/LabValueFinderTester.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-regression-test/src/test/java/org/apache/ctakes/core/ae/LabValueFinderTester.java?rev=1827922&r1=1827921&r2=1827922&view=diff
==============================================================================
--- ctakes/trunk/ctakes-regression-test/src/test/java/org/apache/ctakes/core/ae/LabValueFinderTester.java (original)
+++ ctakes/trunk/ctakes-regression-test/src/test/java/org/apache/ctakes/core/ae/LabValueFinderTester.java Wed Mar 28 15:34:24 2018
@@ -42,6 +42,13 @@ public class LabValueFinderTester {
static private AnalysisEngineDescription defaultLabAnnotator;
static private AnalysisEngineDescription sameLineLabAnnotator;
+ /**
+ * If you choose to test with the default ctakes dictionary, use the second DefaultJCasTermAnnotator with
+ * UMLS credentials. Also, uncomment the PARAM_USE_DRUGS lines in descriptor creation as many a "Lab"
+ * is represented by a medication in traditional ctakes.
+ *
+ * @throws UIMAException -
+ */
@BeforeClass
public static void setUpBeforeClass() throws UIMAException {
simpleSegmentator = SimpleSegmentAnnotator.createAnnotatorDescription();
@@ -53,10 +60,17 @@ public class LabValueFinderTester {
builder.add( AnalysisEngineFactory.createEngineDescription( ContextDependentTokenizerAnnotator.class ) );
builder.add( AnalysisEngineFactory.createEngineDescription( POSTagger.class ) );
builder.add( DefaultJCasTermAnnotator.createAnnotatorDescription( DICT_DESC_PATH ) );
+// builder.add( AnalysisEngineFactory.createEngineDescription( DefaultJCasTermAnnotator.class,
+// UmlsUserApprover.USER_PARAM, "UMLS_USER",
+// UmlsUserApprover.PASS_PARAM, "UMLS_PASS" ) );
midPipeline = builder.createAggregateDescription();
- defaultLabAnnotator = LabValueFinder.createAnnotatorDescription( PARAM_ALL_SECTIONS, "false" );
- sameLineLabAnnotator = LabValueFinder.createAnnotatorDescription( LabValueFinder.PARAM_MAX_NEWLINES, 1, PARAM_ALL_SECTIONS, "false" );
+ defaultLabAnnotator = LabValueFinder.createAnnotatorDescription(
+// LabValueFinder.PARAM_USE_DRUGS, "true",
+ PARAM_ALL_SECTIONS, "false" );
+ sameLineLabAnnotator = LabValueFinder.createAnnotatorDescription(
+// LabValueFinder.PARAM_USE_DRUGS, "true",
+ LabValueFinder.PARAM_MAX_NEWLINES, 1, PARAM_ALL_SECTIONS, "false" );
// LabValueFinder.LOGGER.setLevel( Level.DEBUG );
}