ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1581359 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventDurationDistribution.java
Date Tue, 25 Mar 2014 14:46:17 GMT
Author: dligach
Date: Tue Mar 25 14:46:17 2014
New Revision: 1581359

URL: http://svn.apache.org/r1581359
Log:
moved formatDistribution(...) to Utils since it's used by another class now

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventDurationDistribution.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventDurationDistribution.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventDurationDistribution.java?rev=1581359&r1=1581358&r2=1581359&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventDurationDistribution.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/EventDurationDistribution.java
Tue Mar 25 14:46:17 2014
@@ -12,6 +12,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.ctakes.relationextractor.eval.XMIReader;
+import org.apache.ctakes.temporal.ae.feature.duration.Utils;
 import org.apache.ctakes.typesystem.type.structured.DocumentID;
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
@@ -137,7 +138,7 @@ public class EventDurationDistribution {
       }
 
       if(durationDistribution.size() > 0) { 
-        System.out.println(formatDistribution(mentionText, durationDistribution, ", ", true)
+ "[" + durationDistribution.size() + " instances]");
+        System.out.println(Utils.formatDistribution(mentionText, durationDistribution, ",
", true) + "[" + durationDistribution.size() + " instances]");
       }else{
         System.out.println(mentionText + ": No duration information found.");
       }
@@ -218,40 +219,6 @@ public class EventDurationDistribution {
       Joiner joiner = Joiner.on(',');
       return joiner.join(durationValues);
     }
-    
-    /**
-     * Convert duration distribution multiset to a format that's easy to parse automatically.
-     * Format: <sign/symptom>,<time bin>:<count>, ...
-     * Example: apnea, second:5, minute:1, hour:5, day:10, week:1, month:0, year:0
-     */
-    private static String formatDistribution(
-        String mentionText, 
-        Multiset<String> durationDistribution, 
-        String separator,
-        boolean normalize) {
-      
-      List<String> distribution = new LinkedList<String>();
-      distribution.add(mentionText);
-
-      double total = 0;
-      if(normalize) {
-        for(String bin : BINS) {
-          total += durationDistribution.count(bin);
-        }
-      }
-      
-      for(String bin : BINS) {
-        if(normalize) {
-          distribution.add(String.format("%s:%.3f", bin, durationDistribution.count(bin)
/ total));  
-        } else {
-          distribution.add(String.format("%s:%d", bin, durationDistribution.count(bin)));
-        }
-        
-      }
-      
-      Joiner joiner = Joiner.on(separator);
-      return joiner.join(distribution);
-    }
   }
   
   private static CollectionReader getCollectionReader(List<File> items) throws Exception
{



Mime
View raw message