ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1589163 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature: CheckSpecialWordRelationExtractor.java NearbyVerbTenseRelationExtractor.java SectionHeaderRelationExtractor.java
Date Tue, 22 Apr 2014 15:15:28 GMT
Author: clin
Date: Tue Apr 22 15:15:27 2014
New Revision: 1589163

URL: http://svn.apache.org/r1589163
Log:
added three more feature extractors for event-time relation discovery.

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

Added: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/CheckSpecialWordRelationExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/CheckSpecialWordRelationExtractor.java?rev=1589163&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/CheckSpecialWordRelationExtractor.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/CheckSpecialWordRelationExtractor.java
Tue Apr 22 15:15:27 2014
@@ -0,0 +1,64 @@
+package org.apache.ctakes.temporal.ae.feature;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ctakes.relationextractor.ae.features.RelationFeaturesExtractor;
+import org.apache.ctakes.typesystem.type.syntax.WordToken;
+import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.jcas.JCas;
+import org.cleartk.classifier.Feature;
+import org.uimafit.util.JCasUtil;
+
+public class CheckSpecialWordRelationExtractor implements RelationFeaturesExtractor{
+	
+	final static List<String> specialWd = Arrays.asList("before","prior","previous","previously","ago","soon","earlier","early","after","later","subsequent","follow","following","followed","post","since","back","start","started","by","past","starting");
+
+	@Override
+	public List<Feature> extract(JCas jcas, IdentifiedAnnotation arg1,
+			IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
+		List<Feature> feats = new ArrayList<Feature>();
+
+		//find event
+		EventMention event = null;
+		if(arg1 instanceof EventMention){
+			event = (EventMention) arg1;
+		}else if(arg1 instanceof EventMention){
+			event = (EventMention) arg2;
+		}else{
+			return feats;
+		}
+
+		//1 get covering sentence:
+		Map<EventMention, Collection<Sentence>> coveringMap =
+				JCasUtil.indexCovering(jcas, EventMention.class, Sentence.class);
+		Collection<Sentence> sentList = coveringMap.get(event);
+
+		//2 get Verb Tense
+		if (sentList != null && !sentList.isEmpty()){
+			for(Sentence sent : sentList) {
+				for ( WordToken wt : JCasUtil.selectCovered(jcas, WordToken.class, sent)) {
+					if (wt != null){
+						String wdtext = wt.getCoveredText().toLowerCase();
+						if (specialWd.contains(wdtext)){
+							Feature feature = new Feature("SpecialWd", wdtext);
+							feats.add(feature);
+						}
+					}
+				}
+				
+				//logger.info("found nearby verb's pos tag: "+ verbTP);
+			}
+
+		}
+		return feats;
+	}
+
+
+}

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

Added: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/NearbyVerbTenseRelationExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/NearbyVerbTenseRelationExtractor.java?rev=1589163&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/NearbyVerbTenseRelationExtractor.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/NearbyVerbTenseRelationExtractor.java
Tue Apr 22 15:15:27 2014
@@ -0,0 +1,62 @@
+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.relationextractor.ae.features.RelationFeaturesExtractor;
+import org.apache.ctakes.typesystem.type.syntax.WordToken;
+import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.jcas.JCas;
+import org.cleartk.classifier.Feature;
+import org.uimafit.util.JCasUtil;
+
+public class NearbyVerbTenseRelationExtractor implements RelationFeaturesExtractor{
+
+	@Override
+	public List<Feature> extract(JCas jcas, IdentifiedAnnotation arg1,
+			IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
+		List<Feature> feats = new ArrayList<Feature>();
+
+		//find event
+		EventMention event = null;
+		if(arg1 instanceof EventMention){
+			event = (EventMention) arg1;
+		}else if(arg1 instanceof EventMention){
+			event = (EventMention) arg2;
+		}else{
+			return feats;
+		}
+
+		//1 get covering sentence:
+		Map<EventMention, Collection<Sentence>> coveringMap =
+				JCasUtil.indexCovering(jcas, EventMention.class, Sentence.class);
+		Collection<Sentence> sentList = coveringMap.get(event);
+
+		//2 get Verb Tense
+		if (sentList != null && !sentList.isEmpty()){
+			for(Sentence sent : sentList) {
+				String verbTP ="";
+				for ( WordToken wt : JCasUtil.selectCovered(jcas, WordToken.class, sent)) {
+					if (wt != null){
+						String pos = wt.getPartOfSpeech();
+						if (pos.startsWith("VB")){
+							verbTP = verbTP + "_" + pos;
+						}
+					}
+				}
+				Feature feature = new Feature("VerbTenseFeature", verbTP);
+				feats.add(feature);
+				//logger.info("found nearby verb's pos tag: "+ verbTP);
+			}
+
+		}
+		return feats;
+	}
+
+
+}

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

Added: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/SectionHeaderRelationExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/SectionHeaderRelationExtractor.java?rev=1589163&view=auto
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/SectionHeaderRelationExtractor.java
(added)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/SectionHeaderRelationExtractor.java
Tue Apr 22 15:15:27 2014
@@ -0,0 +1,52 @@
+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.relationextractor.ae.features.RelationFeaturesExtractor;
+import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textspan.Segment;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.jcas.JCas;
+import org.cleartk.classifier.Feature;
+import org.uimafit.util.JCasUtil;
+
+public class SectionHeaderRelationExtractor implements RelationFeaturesExtractor{
+
+	@Override
+	public List<Feature> extract(JCas jcas, IdentifiedAnnotation arg1,
+			IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
+		List<Feature> feats = new ArrayList<Feature>();
+
+		//find event
+		EventMention event = null;
+		if(arg1 instanceof EventMention){
+			event = (EventMention) arg1;
+		}else if(arg1 instanceof EventMention){
+			event = (EventMention) arg2;
+		}else{
+			return feats;
+		}
+
+		//get covering segment set:
+		Map<EventMention, Collection<Segment>> coveringMap =
+				JCasUtil.indexCovering(jcas, EventMention.class, Segment.class);
+		Collection<Segment> segList = coveringMap.get(event);
+
+		//get segment id
+		if (segList != null && !segList.isEmpty()){
+			for(Segment seg : segList) {
+				String segname = seg.getId();
+				Feature feature = new Feature("SegmentID", segname);
+				feats.add(feature);
+			}
+
+		}
+		return feats;
+	}
+
+
+}

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



Mime
View raw message