ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1589833 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/duration/DurationEventTimeFeatureExtractor.java
Date Thu, 24 Apr 2014 18:56:41 GMT
Author: dligach
Date: Thu Apr 24 18:56:41 2014
New Revision: 1589833

URL: http://svn.apache.org/r1589833
Log:
got rid of the loop and replaced it with an iterator

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=1589833&r1=1589832&r2=1589833&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 18:56:41 2014
@@ -60,21 +60,17 @@ 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) {
-      float cumulativeProbability = 0f;
-      for(String bin : Utils.bins) { 
-        if(bin.equals(timeUnit)) {
-          cumulativeProbability = cumulativeProbability + eventDistribution.get(bin); 
-          break;
-        }
+    String timeUnit = timeUnits.iterator().next();
+    float cumulativeProbability = 0f;
+    for(String bin : Utils.bins) { 
+      if(bin.equals(timeUnit)) {
         cumulativeProbability = cumulativeProbability + eventDistribution.get(bin); 
+        break;
       }
-      features.add(new Feature("cumulative_probability", cumulativeProbability));
-      break; // for now only use firs time unit
+      cumulativeProbability = cumulativeProbability + eventDistribution.get(bin); 
     }
-
+    features.add(new Feature("cumulative_probability", cumulativeProbability));
+    
     return features; 
   }
 }



Mime
View raw message