ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1466634 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature: EventTimeFlatTreeFeatureExtractor.java TemporalPETExtractor.java TemporalPathExtractor.java
Date Wed, 10 Apr 2013 19:14:59 GMT
Author: tmill
Date: Wed Apr 10 19:14:59 2013
New Revision: 1466634

URL: http://svn.apache.org/r1466634
Log:
Tree kernel feature modifications: handle null trees and parameterize Bag of Whatevers.

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventTimeFlatTreeFeatureExtractor.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPETExtractor.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPathExtractor.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventTimeFlatTreeFeatureExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventTimeFlatTreeFeatureExtractor.java?rev=1466634&r1=1466633&r2=1466634&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventTimeFlatTreeFeatureExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/EventTimeFlatTreeFeatureExtractor.java
Wed Apr 10 19:14:59 2013
@@ -14,6 +14,8 @@ import org.apache.uima.jcas.JCas;
 import org.cleartk.classifier.Feature;
 import org.uimafit.util.JCasUtil;
 
+import com.google.common.base.Function;
+
 
 public class EventTimeFlatTreeFeatureExtractor implements RelationFeaturesExtractor{
 
@@ -29,8 +31,16 @@ public class EventTimeFlatTreeFeatureExt
 			arg2 = temp;
 		}
 		
-		SimpleTree tree = new SimpleTree("BOP");
+		SimpleTree bopTree = getTree(jcas, arg1, arg2, "BOP", new Function<BaseToken,String>(){public
String apply(BaseToken t){ return t.getPartOfSpeech();}});
+//		SimpleTree bowTree = getTree(jcas, arg1, arg2, "BOW", new Function<BaseToken,String>(){public
String apply(BaseToken t){ return t.getCoveredText();}});
 		
+		feats.add(new Feature("TK_BOP", bopTree.toString()));
+//		feats.add(new Feature("TK_BOW", bowTree.toString()));
+		return feats;
+	}
+
+	private static SimpleTree getTree(JCas jcas, IdentifiedAnnotation arg1, IdentifiedAnnotation
arg2, String label, Function<BaseToken, String> leafFun){
+		SimpleTree tree = new SimpleTree(label);
 		SimpleTree arg1Tree = null;
 		SimpleTree arg2Tree = null;
 		String eventModality="";
@@ -55,7 +65,7 @@ public class EventTimeFlatTreeFeatureExt
 		tree.addChild(arg1Tree);
 		for(BaseToken token : tokens){
 			SimpleTree tokenTree = new SimpleTree("TOK");
-			tokenTree.addChild(new SimpleTree(token.getPartOfSpeech()));
+			tokenTree.addChild(new SimpleTree(leafFun.apply(token)));
 			
 			if(token.getEnd() <= arg1.getEnd()){
 				arg1Tree.addChild(tokenTree);
@@ -66,10 +76,7 @@ public class EventTimeFlatTreeFeatureExt
 			}
 		}
 		tree.addChild(arg2Tree);
-		
-		feats.add(new Feature("TK_BOP", tree.toString()));
-		return feats;
+		return tree;
 	}
 
-
 }

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPETExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPETExtractor.java?rev=1466634&r1=1466633&r2=1466634&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPETExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPETExtractor.java
Wed Apr 10 19:14:59 2013
@@ -26,6 +26,12 @@ public class TemporalPETExtractor implem
 		// first get the root and print it out...
 		TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, AnnotationTreeUtils.getAnnotationTree(jcas,
arg1));
 		
+		if(root == null){
+			SimpleTree fakeTree = new SimpleTree("(S (NN null))");
+			features.add(new Feature("TK_PET", fakeTree.toString()));
+			return features;
+		}
+		
 		// swap the order if necessary:
 		if(arg2.getBegin() <= arg1.getBegin() && arg2.getEnd() <= arg1.getEnd()){
 			IdentifiedAnnotation temp = arg1;

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPathExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPathExtractor.java?rev=1466634&r1=1466633&r2=1466634&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPathExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/TemporalPathExtractor.java
Wed Apr 10 19:14:59 2013
@@ -24,6 +24,11 @@ public class TemporalPathExtractor imple
 		List<Feature> features = new ArrayList<Feature>();
 		// first get the root and print it out...
 		TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, AnnotationTreeUtils.getAnnotationTree(jcas,
arg1));
+		if(root == null){
+			SimpleTree fakeTree = new SimpleTree("(S (NN null))");
+			features.add(new Feature("TK_PATH", fakeTree.toString()));
+			return features;
+		}
 		// swap the order if necessary:
 		if(arg2.getBegin() <= arg1.getBegin() && arg2.getEnd() <= arg1.getEnd()){
 			IdentifiedAnnotation temp = arg1;



Mime
View raw message