ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1765525 - in /ctakes/trunk: ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/pairing/cluster/ClusterMentionPairer_ImplBase.java ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java
Date Wed, 19 Oct 2016 01:18:52 GMT
Author: seanfinan
Date: Wed Oct 19 01:18:51 2016
New Revision: 1765525

URL: http://svn.apache.org/viewvc?rev=1765525&view=rev
Log:
Fixing NPE

Modified:
    ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/pairing/cluster/ClusterMentionPairer_ImplBase.java
    ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java

Modified: ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/pairing/cluster/ClusterMentionPairer_ImplBase.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/pairing/cluster/ClusterMentionPairer_ImplBase.java?rev=1765525&r1=1765524&r2=1765525&view=diff
==============================================================================
--- ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/pairing/cluster/ClusterMentionPairer_ImplBase.java
(original)
+++ ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/pairing/cluster/ClusterMentionPairer_ImplBase.java
Wed Oct 19 01:18:51 2016
@@ -1,16 +1,7 @@
 package org.apache.ctakes.coreference.ae.pairing.cluster;
 
-import static org.apache.ctakes.coreference.ae.MarkableHeadTreeCreator.getKey;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.ctakes.coreference.ae.MentionClusterCoreferenceAnnotator.CollectionTextRelationIdentifiedAnnotationPair;
 import org.apache.ctakes.coreference.ae.pairing.AnnotationPairer;
-//import org.apache.ctakes.dependency.parser.util.DependencyUtility;
 import org.apache.ctakes.typesystem.type.relation.CollectionTextRelation;
 import org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
@@ -20,6 +11,12 @@ import org.apache.uima.fit.util.JCasUtil
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.tcas.Annotation;
 
+import java.util.*;
+
+import static org.apache.ctakes.coreference.ae.MarkableHeadTreeCreator.getKey;
+
+//import org.apache.ctakes.dependency.parser.util.DependencyUtility;
+
 public abstract class ClusterMentionPairer_ImplBase implements AnnotationPairer<Markable,
CollectionTextRelationIdentifiedAnnotationPair> {
   public abstract List<CollectionTextRelationIdentifiedAnnotationPair> getPairs(JCas
jcas, Markable m);
   private Map<ConllDependencyNode,Collection<IdentifiedAnnotation>> nodeEntMap
= null;
@@ -42,7 +39,10 @@ public abstract class ClusterMentionPair
     IdentifiedAnnotation bestEnt = null;
     Set<IdentifiedAnnotation> otherBestEnts = new HashSet<>();
     ConllDependencyNode head = MapFactory.get(getKey(jcas), markable);
-    
+    if ( head == null ) {
+      return Collections.emptySet();
+    }
+
     Collection<IdentifiedAnnotation> coveringEnts = nodeEntMap.get(head);
     for(IdentifiedAnnotation ent : coveringEnts){
       if(ent.getOntologyConceptArr() == null) continue; // skip non-umls entities.

Modified: ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java?rev=1765525&r1=1765524&r2=1765525&view=diff
==============================================================================
--- ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java
(original)
+++ ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java
Wed Oct 19 01:18:51 2016
@@ -1,16 +1,19 @@
 package org.apache.ctakes.utils.struct;
 
+import org.apache.uima.jcas.cas.TOP;
+
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.uima.jcas.cas.TOP;
-
 public class MapFactory {
   private static Map<String, Map<?,?>> mapIndex = new HashMap<>();
 
   public static <K extends TOP,V extends TOP> V get(String mapId, K key){
     Map<?,?> map = mapIndex.get(mapId);
-    return (V) map.get(key);
+    if ( map != null ) {
+      return (V)map.get( key );
+    }
+    return null;
   }
   
   public static <K extends TOP,V extends TOP> void put(String mapId, K key, V value){



Mime
View raw message