ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevenbeth...@apache.org
Subject svn commit: r1480990 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventAnnotator.java
Date Fri, 10 May 2013 12:24:04 GMT
Author: stevenbethard
Date: Fri May 10 12:24:03 2013
New Revision: 1480990

URL: http://svn.apache.org/r1480990
Log:
Adds features for tokens at end of UMLS entities in EventAnnotator

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventAnnotator.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventAnnotator.java?rev=1480990&r1=1480989&r2=1480990&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventAnnotator.java
Fri May 10 12:24:03 2013
@@ -64,8 +64,10 @@ import org.uimafit.factory.AnalysisEngin
 import org.uimafit.util.JCasUtil;
 
 import com.google.common.base.Predicate;
+import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
 
 public class EventAnnotator extends TemporalEntityAnnotator_ImplBase {
 
@@ -202,6 +204,17 @@ public class EventAnnotator extends Temp
   public void process(JCas jCas, Segment segment) throws AnalysisEngineProcessException {
     PredicateArgumentExtractor predicateArgumentExtractor = new PredicateArgumentExtractor(jCas);
 
+    // Create features for tokens that end UMLS (or other) entities
+    Multimap<BaseToken, Feature> endOfEntityFeatures = HashMultimap.create();
+    for (IdentifiedAnnotation entity : JCasUtil.select(jCas, IdentifiedAnnotation.class))
{
+      if (!entity.getClass().equals(EventMention.class)) {
+        List<BaseToken> tokens = JCasUtil.selectCovered(jCas, BaseToken.class, entity);
+        BaseToken lastToken = tokens.get(tokens.size() - 1);
+        String value = String.format("%s_%s", entity.getClass().getSimpleName(), entity.getTypeID());
+        endOfEntityFeatures.put(lastToken, new Feature("EndOf", value));
+      }
+    }
+
     Random rand = new Random();
     
     //TRY SMOTE algorithm here to generate more minority class samples
@@ -281,6 +294,9 @@ public class EventAnnotator extends Temp
 
         // features from surrounding tokens
         features.addAll(this.contextFeatureExtractor.extractWithin(jCas, token, sentence));
+        
+        // features from ends of entities
+        features.addAll(endOfEntityFeatures.get(token));
 
         // features from surrounding entity, phrase, etc. chunk-labels
         for (ChunkingExtractor extractor : chunkingExtractors) {



Mime
View raw message