ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1675501 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotator.java
Date Wed, 22 Apr 2015 21:15:18 GMT
Author: clin
Date: Wed Apr 22 21:15:17 2015
New Revision: 1675501

URL: http://svn.apache.org/r1675501
Log:
Modified the token and POS feature extractors of DocTimeRel to look context within a sentence.

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotator.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotator.java?rev=1675501&r1=1675500&r2=1675501&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotator.java
Wed Apr 22 21:15:17 2015
@@ -25,6 +25,7 @@ import java.util.List;
 //import java.util.Map;
 
 
+
 import org.apache.ctakes.temporal.ae.feature.ClosestVerbExtractor;
 //import org.apache.ctakes.temporal.ae.feature.CoveredTextToValuesExtractor;
 import org.apache.ctakes.temporal.ae.feature.DateAndMeasurementExtractor;
@@ -38,6 +39,7 @@ import org.apache.ctakes.typesystem.type
 //import org.apache.ctakes.temporal.ae.feature.duration.DurationExpectationFeatureExtractor;
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
 import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
@@ -102,7 +104,7 @@ public class DocTimeRelAnnotator extends
         new File(modelDirectory, "model.jar"));
   }
 
-  private CleartkExtractor contextExtractor;  
+  private CleartkExtractor<EventMention, BaseToken> contextExtractor;  
   private SectionHeaderExtractor sectionIDExtractor;
   private ClosestVerbExtractor closestVerbExtractor;
   private TimeXExtractor timeXExtractor;
@@ -117,10 +119,10 @@ public class DocTimeRelAnnotator extends
   @Override
   public void initialize(UimaContext context) throws ResourceInitializationException {
     super.initialize(context);
-    CombinedExtractor1 baseExtractor = new CombinedExtractor1(
-        new CoveredTextExtractor(),
-        new TypePathExtractor(BaseToken.class, "partOfSpeech"));
-    this.contextExtractor = new CleartkExtractor(
+    CombinedExtractor1<BaseToken> baseExtractor = new CombinedExtractor1<BaseToken>(
+        new CoveredTextExtractor<BaseToken>(),
+        new TypePathExtractor<BaseToken>(BaseToken.class, "partOfSpeech"));
+    this.contextExtractor = new CleartkExtractor<EventMention, BaseToken>(
         BaseToken.class,
         baseExtractor,
         new Preceding(3),
@@ -147,7 +149,14 @@ public class DocTimeRelAnnotator extends
   @Override
   public void process(JCas jCas) throws AnalysisEngineProcessException {
     for (EventMention eventMention : JCasUtil.select(jCas, EventMention.class)) {
-      List<Feature> features = this.contextExtractor.extract(jCas, eventMention);
+      List<Sentence> sents = JCasUtil.selectCovering(jCas, Sentence.class, eventMention);
+      List<Feature> features = new ArrayList<>();
+      if(sents!=null && sents.size()>0){
+    	  features.addAll(this.contextExtractor.extractWithin(jCas, eventMention, sents.get(0)));
+      }else{
+    	  features.addAll(this.contextExtractor.extract(jCas, eventMention));
+      }
+       
       features.addAll(this.sectionIDExtractor.extract(jCas, eventMention)); //add section
heading
       features.addAll(this.closestVerbExtractor.extract(jCas, eventMention)); //add closest
verb
       features.addAll(this.timeXExtractor.extract(jCas, eventMention)); //add the closest
time expression types



Mime
View raw message