ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1520087 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/SignSymptomDurations.java
Date Wed, 04 Sep 2013 18:05:12 GMT
Author: dligach
Date: Wed Sep  4 18:05:12 2013
New Revision: 1520087

URL: http://svn.apache.org/r1520087
Log:
printing durations as vectors (for matlab)

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

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/SignSymptomDurations.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/SignSymptomDurations.java?rev=1520087&r1=1520086&r2=1520087&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/SignSymptomDurations.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/SignSymptomDurations.java
Wed Sep  4 18:05:12 2013
@@ -6,6 +6,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -30,6 +31,7 @@ import org.uimafit.util.JCasUtil;
 
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
+import com.google.common.base.Joiner;
 import com.google.common.collect.HashMultiset;
 import com.google.common.collect.Multiset;
 import com.google.common.collect.Ordering;
@@ -38,6 +40,7 @@ import com.google.common.collect.Orderin
  * Extract durations of signs/symptoms.
  * 
  * TODO: check drinking.txt; fewer day durations are captured than exist in data.
+ * TODO: need to take care of abbreviations (e.g. wk, yr, etc.)
  * 
  * @author dmitriy dligach
  */
@@ -112,9 +115,23 @@ public class SignSymptomDurations {
       }
 
       if(durationDistribution.size() > 0) { 
-        System.out.println(signSymptomText + ": " + durationDistribution);
+        String durationDistributionAsString = convertToString(durationDistribution);
+        System.out.println(signSymptomText + "," + durationDistributionAsString);
       }
     }
+    
+    private static String convertToString(Multiset<String> durationDistribution) {
+      
+      List<String> durationBins = Arrays.asList("second", "minute", "hour", "day",
"week", "month", "year");
+      List<Integer> durationValues = new LinkedList<Integer>();
+      
+      for(String durationBin : durationBins) {
+        durationValues.add(durationDistribution.count(durationBin));
+      }
+
+      Joiner joiner = Joiner.on(',');
+      return joiner.join(durationValues);
+    }
   }
   
   private static CollectionReader getCollectionReader(List<File> items) throws Exception
{



Mime
View raw message