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 2016/05/04 19:19:02 UTC
svn commit: r1742321 - in /ctakes/trunk/ctakes-core/src:
main/java/org/apache/ctakes/core/cc/
main/java/org/apache/ctakes/core/cc/pretty/plaintext/
main/java/org/apache/ctakes/core/cc/property/plaintext/
main/java/org/apache/ctakes/core/util/ test/java...
Author: seanfinan
Date: Wed May 4 19:19:02 2016
New Revision: 1742321
URL: http://svn.apache.org/viewvc?rev=1742321&view=rev
Log:
minor refactoring in OntologyConceptUtil
Modified:
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/JdbcWriterTemplate.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/property/plaintext/PropertyTextWriter.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/OntologyConceptUtil.java
ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/util/OntologyConceptUtilTester.java
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/JdbcWriterTemplate.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/JdbcWriterTemplate.java?rev=1742321&r1=1742320&r2=1742321&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/JdbcWriterTemplate.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/JdbcWriterTemplate.java Wed May 4 19:19:02 2016
@@ -148,7 +148,7 @@ public class JdbcWriterTemplate extends
for ( Annotation annotation : identifiedsIndex ) {
if ( annotation instanceof IdentifiedAnnotation ) {
final Collection<UmlsConcept> umlsConcepts
- = OntologyConceptUtil.getConcepts( (IdentifiedAnnotation)annotation );
+ = OntologyConceptUtil.getUmlsConcepts( (IdentifiedAnnotation)annotation );
final Collection<I2b2Concept> i2b2Concepts = createI2b2Concepts( umlsConcepts );
for ( I2b2Concept i2b2Concept : i2b2Concepts ) {
Collection<IdentifiedAnnotation> annotationList = cuiAnnotationListMap.get( i2b2Concept );
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java?rev=1742321&r1=1742320&r2=1742321&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java Wed May 4 19:19:02 2016
@@ -402,7 +402,7 @@ final public class PrettyTextWriter {
* @return map of semantic type names and cuis within those types as they apply to the annotation
*/
static private Map<String, Collection<String>> getSemanticCuis( final IdentifiedAnnotation identifiedAnnotation ) {
- final Collection<UmlsConcept> umlsConcepts = OntologyConceptUtil.getConcepts( identifiedAnnotation );
+ final Collection<UmlsConcept> umlsConcepts = OntologyConceptUtil.getUmlsConcepts( identifiedAnnotation );
if ( umlsConcepts == null || umlsConcepts.isEmpty() ) {
return Collections.emptyMap();
}
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/property/plaintext/PropertyTextWriter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/property/plaintext/PropertyTextWriter.java?rev=1742321&r1=1742320&r2=1742321&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/property/plaintext/PropertyTextWriter.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/property/plaintext/PropertyTextWriter.java Wed May 4 19:19:02 2016
@@ -149,7 +149,7 @@ public class PropertyTextWriter {
*/
static private Map<String, Collection<UmlsConcept>> getSemanticConcepts(
final IdentifiedAnnotation identifiedAnnotation ) {
- final Collection<UmlsConcept> umlsConcepts = OntologyConceptUtil.getConcepts( identifiedAnnotation );
+ final Collection<UmlsConcept> umlsConcepts = OntologyConceptUtil.getUmlsConcepts( identifiedAnnotation );
if ( umlsConcepts == null || umlsConcepts.isEmpty() ) {
return Collections.emptyMap();
}
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/OntologyConceptUtil.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/OntologyConceptUtil.java?rev=1742321&r1=1742320&r2=1742321&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/OntologyConceptUtil.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/OntologyConceptUtil.java Wed May 4 19:19:02 2016
@@ -52,7 +52,7 @@ final public class OntologyConceptUtil {
* @param annotation -
* @return array of FeatureStructure castable to array of OntologyConcept
*/
- static private FeatureStructure[] getOntologyConcepts( final IdentifiedAnnotation annotation ) {
+ static public FeatureStructure[] getConceptFeatureStructures( final IdentifiedAnnotation annotation ) {
if ( annotation == null ) {
return EMPTY_FEATURE_ARRAY;
}
@@ -65,26 +65,40 @@ final public class OntologyConceptUtil {
/**
* @param annotation -
- * @return steram of OntologyConcept
+ * @return stream of OntologyConcept
*/
- static private Stream<OntologyConcept> getOntologyConceptStream( final IdentifiedAnnotation annotation ) {
- return Arrays.stream( getOntologyConcepts( annotation ) )
+ static public Stream<OntologyConcept> getOntologyConceptStream( final IdentifiedAnnotation annotation ) {
+ return Arrays.stream( getConceptFeatureStructures( annotation ) )
.filter( OntologyConcept.class::isInstance )
.map( fs -> (OntologyConcept)fs )
.filter( isSchemeOk )
.filter( isCodeOk );
}
+ /**
+ * @param annotation -
+ * @return stream of OntologyConcept
+ */
+ static public Collection<OntologyConcept> getOntologyConcepts( final IdentifiedAnnotation annotation ) {
+ return getOntologyConceptStream( annotation ).collect( Collectors.toSet() );
+ }
/**
* @param annotation -
- * @return set of all Umls Concepts associated with the annotation
+ * @return stream of all Umls Concepts associated with the annotation
*/
- static public Collection<UmlsConcept> getConcepts( final IdentifiedAnnotation annotation ) {
- return Arrays.stream( getOntologyConcepts( annotation ) )
+ static public Stream<UmlsConcept> getUmlsConceptStream( final IdentifiedAnnotation annotation ) {
+ return getOntologyConceptStream( annotation )
.filter( UmlsConcept.class::isInstance )
- .map( fs -> (UmlsConcept)fs )
- .collect( Collectors.toSet() );
+ .map( fs -> (UmlsConcept)fs );
+ }
+
+ /**
+ * @param annotation -
+ * @return set of all Umls Concepts associated with the annotation
+ */
+ static public Collection<UmlsConcept> getUmlsConcepts( final IdentifiedAnnotation annotation ) {
+ return getUmlsConceptStream( annotation ).collect( Collectors.toSet() );
}
@@ -97,8 +111,7 @@ final public class OntologyConceptUtil {
* @return set of all Umls cuis associated with the annotation
*/
static public Collection<String> getCuis( final IdentifiedAnnotation annotation ) {
- return getConcepts( annotation )
- .stream()
+ return getUmlsConceptStream( annotation )
.map( UmlsConcept::getCui )
.collect( Collectors.toSet() );
}
@@ -108,8 +121,7 @@ final public class OntologyConceptUtil {
* @return set of all Umls tuis associated with the annotation
*/
static public Collection<String> getTuis( final IdentifiedAnnotation annotation ) {
- return getConcepts( annotation )
- .stream()
+ return getUmlsConceptStream( annotation )
.map( UmlsConcept::getTui )
.collect( Collectors.toSet() );
}
Modified: ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/util/OntologyConceptUtilTester.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/util/OntologyConceptUtilTester.java?rev=1742321&r1=1742320&r2=1742321&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/util/OntologyConceptUtilTester.java (original)
+++ ctakes/trunk/ctakes-core/src/test/java/org/apache/ctakes/core/util/OntologyConceptUtilTester.java Wed May 4 19:19:02 2016
@@ -156,7 +156,7 @@ public class OntologyConceptUtilTester {
@Test
public void testGetConcepts() {
assertEquals( "Null IdentifiedAnnotation should have no concepts", 0,
- OntologyConceptUtil.getConcepts( null ).size() );
+ OntologyConceptUtil.getUmlsConcepts( null ).size() );
assertConceptCount( TUI_1_CUI_1, 1 );
assertConceptCount( TUI_1_CUI_2_CODE_A1, 1 );
assertConceptCount( TUI_2_CUI_3_CODE_B3, 1 );
@@ -166,7 +166,7 @@ public class OntologyConceptUtilTester {
static private void assertConceptCount( final IdentifiedAnnotation annotation, final int wantedCount ) {
assertEquals( "Incorrect number of UmlsConcepts", wantedCount,
- OntologyConceptUtil.getConcepts( annotation ).size() );
+ OntologyConceptUtil.getUmlsConcepts( annotation ).size() );
}
@Test