ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1524216 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/SignSymptomDurations.java
Date Tue, 17 Sep 2013 20:40:07 GMT
Author: dligach
Date: Tue Sep 17 20:40:06 2013
New Revision: 1524216

URL: http://svn.apache.org/r1524216
Log:
added a method to print annotation context

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=1524216&r1=1524215&r2=1524216&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
Tue Sep 17 20:40:06 2013
@@ -21,6 +21,7 @@ import org.apache.uima.analysis_engine.A
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.collection.CollectionReader;
 import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
 import org.cleartk.util.Options_ImplBase;
 import org.kohsuke.args4j.Option;
 import org.uimafit.component.JCasAnnotator_ImplBase;
@@ -122,8 +123,8 @@ public class SignSymptomDurations {
       }
 
       if(durationDistribution.size() > 0) { 
-        // System.out.println(signSymptomText + "," + convertToString(durationDistribution));
-        System.out.println(signSymptomText + ": " + durationDistribution);
+        System.out.println(signSymptomText + "," + convertToString(durationDistribution));
+        // System.out.println(signSymptomText + ": " + durationDistribution);
       }
     }
     
@@ -160,6 +161,15 @@ public class SignSymptomDurations {
       return sortedTimeMentions.get(0);
     }
     
+    private static String getAnnotationContext(Annotation annotation, int maxContextWindowSize)
{
+      
+      String text = annotation.getCAS().getDocumentText();
+      int begin = Math.max(0, annotation.getBegin() - maxContextWindowSize);
+      int end = Math.min(text.length(), annotation.getEnd() + maxContextWindowSize);
+      
+      return text.substring(begin, end).replaceAll("[\r\n]", " ");
+    }
+    
     private static String convertToString(Multiset<String> durationDistribution) {
       
       List<String> durationBins = Arrays.asList("second", "minute", "hour", "day",
"week", "month", "year");



Mime
View raw message