ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1561884 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/PrintNormalizedTemporalExpressions.java
Date Mon, 27 Jan 2014 22:16:48 GMT
Author: dligach
Date: Mon Jan 27 22:16:48 2014
New Revision: 1561884

URL: http://svn.apache.org/r1561884
Log:
a script useful for checking which temporal expressions in gold data can be normalized by
steve bethard's normalizer

Added:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/PrintNormalizedTemporalExpressions.java
  (with props)

Added: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/PrintNormalizedTemporalExpressions.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/PrintNormalizedTemporalExpressions.java?rev=1561884&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/PrintNormalizedTemporalExpressions.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/PrintNormalizedTemporalExpressions.java
Mon Jan 27 22:16:48 2014
@@ -0,0 +1,48 @@
+package org.apache.ctakes.temporal.data.analysis;
+
+import org.apache.ctakes.temporal.ae.feature.duration.DurationTimeUnitFeatureExtractor;
+import org.apache.ctakes.typesystem.type.textsem.TimeMention;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.jcas.JCas;
+import org.threeten.bp.temporal.TemporalUnit;
+import org.uimafit.component.JCasAnnotator_ImplBase;
+import org.uimafit.util.JCasUtil;
+
+import scala.collection.immutable.Set;
+
+import com.google.common.collect.Lists;
+
+/**
+ * 
+ */
+public class PrintNormalizedTemporalExpressions extends JCasAnnotator_ImplBase {        
                                      
+  
+  public static final String GOLD_VIEW_NAME = "GoldView";
+
+  @Override                                                                             
                                    
+  public void process(JCas jCas) throws AnalysisEngineProcessException {                
                                    
+    
+    JCas goldView;                                                                      
                                    
+    try {                                                                               
                                    
+      goldView = jCas.getView(GOLD_VIEW_NAME);                                          
                                    
+    } catch (CASException e) {                                                          
                                    
+      throw new AnalysisEngineProcessException(e);                                      
                                    
+    }                                                                                   
                                                                                         
                                                           
+    
+    for(TimeMention mention : Lists.newArrayList(JCasUtil.select(goldView, TimeMention.class)))
{
+      String timex = mention.getCoveredText();
+      Set<TemporalUnit> units = DurationTimeUnitFeatureExtractor.normalize(timex);
+
+      if(units == null) {
+        System.out.println(timex + "|" + "n/a");
+      } else {
+        scala.collection.Iterator<TemporalUnit> iterator = units.iterator();
+        while(iterator.hasNext()) {
+          TemporalUnit unit = iterator.next();
+          System.out.println(timex + "|" + unit.getName());
+        } 
+      }
+    }
+  }                                                                                     
                                    
+}                                                                                       
                                    
\ No newline at end of file

Propchange: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/PrintNormalizedTemporalExpressions.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message