ctakes-commits mailing list archives

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

URL: http://svn.apache.org/r1480989
Log:
Makes entity chunking work over IdentifiedAnnotations instead of EntityMentions, since most
UMLS entities are now EventMentions.

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=1480989&r1=1480988&r2=1480989&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:09:31 2013
@@ -34,8 +34,8 @@ import org.apache.ctakes.temporal.utils.
 import org.apache.ctakes.typesystem.type.constants.CONST;
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
 import org.apache.ctakes.typesystem.type.syntax.Chunk;
-import org.apache.ctakes.typesystem.type.textsem.EntityMention;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
 import org.apache.ctakes.typesystem.type.textspan.Segment;
 import org.apache.ctakes.typesystem.type.textspan.Sentence;
 import org.apache.uima.UimaContext;
@@ -134,7 +134,7 @@ public class EventAnnotator extends Temp
         EventAnnotator.createFeatureSelectionURI(modelDirectory));
   }
 
-  private BIOChunking<BaseToken, EntityMention> entityChunking;
+  private BIOChunking<BaseToken, IdentifiedAnnotation> entityChunking;
 
   private BIOChunking<BaseToken, EventMention> eventChunking;
 
@@ -161,9 +161,9 @@ public class EventAnnotator extends Temp
     super.initialize(context);
 
     // define chunkings
-    this.entityChunking = new BIOChunking<BaseToken, EntityMention>(
+    this.entityChunking = new BIOChunking<BaseToken, IdentifiedAnnotation>(
         BaseToken.class,
-        EntityMention.class,
+        IdentifiedAnnotation.class,
         "typeID");
     this.phraseChunking = new BIOChunking<BaseToken, Chunk>(
         BaseToken.class,
@@ -235,13 +235,23 @@ public class EventAnnotator extends Temp
           CONST.NE_TYPE_ID_FINDING,
           CONST.NE_TYPE_ID_PROCEDURE,
           CONST.NE_TYPE_ID_UNKNOWN };
-      List<EntityMention> entities = JCasUtil.selectCovered(jCas, EntityMention.class,
sentence);
+      List<IdentifiedAnnotation> entities;
+      if (this.isTraining()) {
+        entities = Lists.newArrayList();
+        for (IdentifiedAnnotation entity : JCasUtil.selectCovered(jCas, IdentifiedAnnotation.class,
sentence)) {
+          if (!entity.getClass().equals(EventMention.class)) {
+            entities.add(entity);
+          }
+        }
+      } else {
+        entities = JCasUtil.selectCovered(jCas, IdentifiedAnnotation.class, sentence);
+      }
+      
       List<ChunkingExtractor> chunkingExtractors = Lists.newArrayList(); 
       for (int typeID : entityTypeIDs) {
-        Predicate<EntityMention> hasTypeID = hasEntityType(typeID);
-        String name = String.format("EntityTag_%d", typeID);
-        List<EntityMention> subEntities = Lists.newArrayList(Iterables.filter(entities,
hasTypeID));
-        chunkingExtractors.add(new ChunkingExtractor(name, this.entityChunking, jCas, tokens,
subEntities));
+        Predicate<IdentifiedAnnotation> hasTypeID = hasEntityType(typeID);
+        List<IdentifiedAnnotation> subEntities = Lists.newArrayList(Iterables.filter(entities,
hasTypeID));
+        chunkingExtractors.add(new ChunkingExtractor("EntityTag", this.entityChunking, jCas,
tokens, subEntities));
       }
       
       // add extractor for phase chunks
@@ -320,10 +330,10 @@ public class EventAnnotator extends Temp
     
   }
 
-  private static Predicate<EntityMention> hasEntityType(final int typeID) {
-    return new Predicate<EntityMention>() {
+  private static Predicate<IdentifiedAnnotation> hasEntityType(final int typeID) {
+    return new Predicate<IdentifiedAnnotation>() {
       @Override
-      public boolean apply(EntityMention mention) {
+      public boolean apply(IdentifiedAnnotation mention) {
         return mention.getTypeID() == typeID;
       }
     };



Mime
View raw message