ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1589787 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/duration/DurationEventTimeFeatureExtractor.java
Date Thu, 24 Apr 2014 16:30:01 GMT
Author: dligach
Date: Thu Apr 24 16:30:00 2014
New Revision: 1589787

URL: http://svn.apache.org/r1589787
Log:
now using cumulative probability as a feature

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/duration/DurationEventTimeFeatureExtractor.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/duration/DurationEventTimeFeatureExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/duration/DurationEventTimeFeatureExtractor.java?rev=1589787&r1=1589786&r2=1589787&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/duration/DurationEventTimeFeatureExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/duration/DurationEventTimeFeatureExtractor.java
Thu Apr 24 16:30:00 2014
@@ -36,7 +36,7 @@ import com.google.common.base.Charsets;
 import com.google.common.io.Files;
 
 /**
- * Assumes all relations whose argument have no duration data have been deleted.
+ * Calculate probability that CONTAINS relation can exist between two arguments.
  */
 public class DurationEventTimeFeatureExtractor implements RelationFeaturesExtractor {
 
@@ -60,16 +60,18 @@ public class DurationEventTimeFeatureExt
     Map<String, Float> eventDistribution = textToDistribution.get(eventText);
 
     HashSet<String> timeUnits = Utils.getTimeUnits(timeText);
+    
+    // sum probabilities for all duration bins up to the time unit
     for(String timeUnit : timeUnits) {
-      Map<String, Float> timeDistribution = Utils.convertToDistribution(timeUnit);
-      for(String bin : Utils.bins) {
-        features.add(new Feature("bin_diff_" + bin, timeDistribution.get(bin) - eventDistribution.get(bin)));
+      float cumulativeProbability = 0f;
+      for(String bin : Utils.bins) { 
+        if(bin.equals(timeUnit)) {
+          cumulativeProbability = cumulativeProbability + eventDistribution.get(bin); 
+          break;
+        }
+        cumulativeProbability = cumulativeProbability + eventDistribution.get(bin); 
       }
-
-      float eventExpectedDuration = Utils.expectedDuration(eventDistribution);
-      float timeExpectedDuration = Utils.expectedDuration(timeDistribution);
-      features.add(new Feature("duration_difference", timeExpectedDuration - eventExpectedDuration));
-
+      features.add(new Feature("cumulative_probability", cumulativeProbability));
       break; // for now only use firs time unit
     }
 



Mime
View raw message