ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1631577 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae: DocTimeRelAnnotator.java feature/EventPropertyExtractor.java
Date Mon, 13 Oct 2014 22:06:19 GMT
Author: tmill
Date: Mon Oct 13 22:06:19 2014
New Revision: 1631577

URL: http://svn.apache.org/r1631577
Log:
CTAKES-82: Fixes to doctimerel to add properties if non-existent.

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/DocTimeRelAnnotator.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventPropertyExtractor.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=1631577&r1=1631576&r2=1631577&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
Mon Oct 13 22:06:19 2014
@@ -31,6 +31,8 @@ import org.apache.ctakes.temporal.ae.fea
 import org.apache.ctakes.temporal.ae.feature.SectionHeaderExtractor;
 import org.apache.ctakes.temporal.ae.feature.TimeXExtractor;
 import org.apache.ctakes.temporal.ae.feature.UmlsSingleFeatureExtractor;
+import org.apache.ctakes.typesystem.type.refsem.Event;
+import org.apache.ctakes.typesystem.type.refsem.EventProperties;
 //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;
@@ -140,24 +142,28 @@ public class DocTimeRelAnnotator extends
   @Override
   public void process(JCas jCas) throws AnalysisEngineProcessException {
     for (EventMention eventMention : JCasUtil.select(jCas, EventMention.class)) {
-      if (eventMention.getEvent() != null) {
-        List<Feature> features = this.contextExtractor.extract(jCas, eventMention);
-        features.addAll(this.verbTensePatternExtractor.extract(jCas, eventMention));//add
nearby verb POS pattern feature
-        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
-        features.addAll(this.genericExtractor.extract(jCas, eventMention)); //add the closest
time expression types
-        features.addAll(this.dateExtractor.extract(jCas, eventMention)); //add the closest
NE type
-        features.addAll(this.umlsExtractor.extract(jCas, eventMention)); //add umls features
-//        features.addAll(this.durationExtractor.extract(jCas, eventMention)); //add duration
feature
-//        features.addAll(this.disSemExtractor.extract(jCas, eventMention)); //add distributional
semantic features
-        if (this.isTraining()) {
-          String outcome = eventMention.getEvent().getProperties().getDocTimeRel();
-          this.dataWriter.write(new Instance<String>(outcome, features));
-        } else {
-          String outcome = this.classifier.classify(features);
-          eventMention.getEvent().getProperties().setDocTimeRel(outcome);
+      List<Feature> features = this.contextExtractor.extract(jCas, eventMention);
+      features.addAll(this.verbTensePatternExtractor.extract(jCas, eventMention));//add nearby
verb POS pattern feature
+      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
+      features.addAll(this.genericExtractor.extract(jCas, eventMention)); //add the closest
time expression types
+      features.addAll(this.dateExtractor.extract(jCas, eventMention)); //add the closest
NE type
+      features.addAll(this.umlsExtractor.extract(jCas, eventMention)); //add umls features
+      //        features.addAll(this.durationExtractor.extract(jCas, eventMention)); //add
duration feature
+      //        features.addAll(this.disSemExtractor.extract(jCas, eventMention)); //add
distributional semantic features
+      if (this.isTraining()) {
+        String outcome = eventMention.getEvent().getProperties().getDocTimeRel();
+        this.dataWriter.write(new Instance<String>(outcome, features));
+      } else {
+        String outcome = this.classifier.classify(features);
+        if (eventMention.getEvent() == null) {
+          Event event = new Event(jCas);
+          eventMention.setEvent(event);
+          EventProperties props = new EventProperties(jCas);
+          event.setProperties(props);
         }
+        eventMention.getEvent().getProperties().setDocTimeRel(outcome);
       }
     }
   }

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventPropertyExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventPropertyExtractor.java?rev=1631577&r1=1631576&r2=1631577&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventPropertyExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventPropertyExtractor.java
Mon Oct 13 22:06:19 2014
@@ -47,13 +47,14 @@ public class EventPropertyExtractor impl
 	  
 	  //1 get event:
 	  EventMention event = (EventMention)annotation;
-	  String contextModal = event.getEvent().getProperties().getContextualModality();
-	  if ( "GENERIC".equals(contextModal) ){
-		  Feature contexmod = new Feature(this.name, contextModal);
-		  features.add(contexmod);
-//		  logger.info("found a event: "+ contextModal);
+	  if(event.getEvent()!= null && event.getEvent().getProperties() != null){
+	    String contextModal = event.getEvent().getProperties().getContextualModality();
+	    if ( "GENERIC".equals(contextModal) ){
+	      Feature contexmod = new Feature(this.name, contextModal);
+	      features.add(contexmod);
+	      //		  logger.info("found a event: "+ contextModal);
+	    }
 	  }
-	  
 	  return features;
   }
 



Mime
View raw message