ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1645692 - /ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/RelationExtractorAnnotator.java
Date Mon, 15 Dec 2014 16:28:38 GMT
Author: clin
Date: Mon Dec 15 16:28:38 2014
New Revision: 1645692

URL: http://svn.apache.org/r1645692
Log:
add null check before feature extraction.

Modified:
    ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/RelationExtractorAnnotator.java

Modified: ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/RelationExtractorAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/RelationExtractorAnnotator.java?rev=1645692&r1=1645691&r2=1645692&view=diff
==============================================================================
--- ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/RelationExtractorAnnotator.java
(original)
+++ ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/RelationExtractorAnnotator.java
Mon Dec 15 16:28:38 2014
@@ -50,6 +50,7 @@ import org.cleartk.ml.CleartkProcessingE
 import org.cleartk.ml.Feature;
 import org.cleartk.ml.Instance;
 import org.cleartk.ml.jar.GenericJarClassifierFactory;
+import org.cleartk.util.ViewUriUtil;
 
 import com.google.common.collect.Lists;
 
@@ -147,7 +148,13 @@ public abstract class RelationExtractorA
         Annotation arg1 = relation.getArg1().getArgument();
         Annotation arg2 = relation.getArg2().getArgument();
         // The key is a list of args so we can do bi-directional lookup
-        relationLookup.put(Arrays.asList(arg1, arg2), relation);
+        List<Annotation> key = Arrays.asList(arg1, arg2);
+        if(relationLookup.containsKey(key)){
+         String reln = relationLookup.get(key).getCategory();
+         System.err.println("Error in: "+ ViewUriUtil.getURI(jCas).toString());
+         System.err.println("Error! This attempted relation " + relation.getCategory() +
" already has a relation " + reln + " at this span: " + arg1.getCoveredText() + " -- " + arg2.getCoveredText());
+        }
+        relationLookup.put(key, relation);
       }
     }
 
@@ -165,7 +172,8 @@ public abstract class RelationExtractorA
         // apply all the feature extractors to extract the list of features
         List<Feature> features = new ArrayList<>();
         for (RelationFeaturesExtractor extractor : this.featureExtractors) {
-          features.addAll(extractor.extract(jCas, arg1, arg2));
+        	 List<Feature> feats = extractor.extract(jCas, arg1, arg2);
+        	 if (feats != null)  features.addAll(feats);
         }
 
         // sanity check on feature values



Mime
View raw message