ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1467344 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/DateXExtractor.java
Date Fri, 12 Apr 2013 16:45:43 GMT
Author: clin
Date: Fri Apr 12 16:45:43 2013
New Revision: 1467344

URL: http://svn.apache.org/r1467344
Log:
add DateAnnotation feature extractor for DocTimeRel

Added:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/DateXExtractor.java
  (with props)

Added: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/DateXExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/DateXExtractor.java?rev=1467344&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/DateXExtractor.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/DateXExtractor.java
Fri Apr 12 16:45:43 2013
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ctakes.temporal.ae.feature;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ctakes.typesystem.type.textsem.DateAnnotation;
+import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.cleartk.classifier.Feature;
+import org.cleartk.classifier.feature.extractor.CleartkExtractorException;
+import org.cleartk.classifier.feature.extractor.simple.SimpleFeatureExtractor;
+import org.uimafit.util.JCasUtil;
+
+public class DateXExtractor implements SimpleFeatureExtractor {
+
+  private String name;
+
+  public DateXExtractor() {
+    super();
+    this.name = "DateXFeature";
+    
+  }
+
+  @Override
+  public List<Feature> extract(JCas view, Annotation annotation) throws CleartkExtractorException
{
+	  List<Feature> features = new ArrayList<Feature>();
+	  
+	  //1 get covering sentence:
+	  Map<EventMention, Collection<Sentence>> coveringMap =
+			  JCasUtil.indexCovering(view, EventMention.class, Sentence.class);
+	  EventMention targetTokenAnnotation = (EventMention)annotation;
+	  Collection<Sentence> sentList = coveringMap.get(targetTokenAnnotation);
+	  
+	  //2 get DateX
+	  if (sentList != null && !sentList.isEmpty()){
+		  for(Sentence sent : sentList) {
+			  for (@SuppressWarnings("unused") DateAnnotation date : JCasUtil.selectCovered(view,
DateAnnotation.class, sent)) {
+				  Feature indicator = new Feature("DateXNearby", this.name);
+				  features.add(indicator);
+				  break;
+			  }
+		  }
+	  }
+	  
+
+	  return features;
+  }
+
+}

Propchange: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/DateXExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message