ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1478064 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae: EventTimeRelationAnnotator.java feature/UmlsFeatureExtractor.java
Date Wed, 01 May 2013 15:59:14 GMT
Author: dligach
Date: Wed May  1 15:59:13 2013
New Revision: 1478064

URL: http://svn.apache.org/r1478064
Log:
added UMLS typeID feature extractor

Added:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java
Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeRelationAnnotator.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeRelationAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeRelationAnnotator.java?rev=1478064&r1=1478063&r2=1478064&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeRelationAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventTimeRelationAnnotator.java
Wed May  1 15:59:13 2013
@@ -9,7 +9,7 @@ import org.apache.ctakes.relationextract
 import org.apache.ctakes.relationextractor.ae.features.PartOfSpeechFeaturesExtractor;
 import org.apache.ctakes.relationextractor.ae.features.RelationFeaturesExtractor;
 import org.apache.ctakes.relationextractor.ae.features.TokenFeaturesExtractor;
-import org.apache.ctakes.temporal.ae.feature.DocTimeRelFeatureExtractor;
+import org.apache.ctakes.temporal.ae.feature.UmlsFeatureExtractor;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
@@ -63,7 +63,7 @@ public class EventTimeRelationAnnotator 
     return Lists.newArrayList(
         new TokenFeaturesExtractor(), 
         new PartOfSpeechFeaturesExtractor(), 
-        new DocTimeRelFeatureExtractor());
+        new UmlsFeatureExtractor());
   }
 
   @Override

Added: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java?rev=1478064&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java
Wed May  1 15:59:13 2013
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ctakes.temporal.ae.feature;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.ctakes.relationextractor.ae.features.RelationFeaturesExtractor;
+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.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.jcas.JCas;
+import org.cleartk.classifier.Feature;
+import org.uimafit.util.JCasUtil;
+
+public class UmlsFeatureExtractor implements RelationFeaturesExtractor {
+
+  @Override
+  public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1, IdentifiedAnnotation
arg2)
+      throws AnalysisEngineProcessException {
+
+    List<Feature> features = new ArrayList<Feature>();
+    
+    JCas systemView;
+    try {
+      systemView = jCas.getView("_InitialView");
+    } catch (CASException e) {
+      throw new AnalysisEngineProcessException(e);
+    }
+    
+    // TODO: add the same logic for arg2
+    if(arg1 instanceof EventMention) {
+      List<EntityMention> entityMentions = JCasUtil.selectCovering(systemView, EntityMention.class,
arg1.getBegin(), arg1.getEnd());
+      
+      Set<Integer> uniqueTypeIDs = new HashSet<Integer>();
+      for(EntityMention entityMention : entityMentions) {
+        uniqueTypeIDs.add(entityMention.getTypeID());
+        features.add(new Feature("arg1EntityTypeID", String.valueOf(entityMention.getTypeID())));
+      }
+      
+      // TODO: this is the correct implementatino, but it does not perform as well 
+//      for(int typeID : uniqueTypeIDs) {
+//        features.add(new Feature("arg1EntityTypeID", String.valueOf(typeID)));
+//      }
+
+    }
+    
+    return features;
+  }
+}



Mime
View raw message