ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1481791 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel: EventTimeFlatTreeFeatureExtractor.java TemporalFTExtractor.java TemporalPETExtractor.java TemporalPathExtractor.java
Date Mon, 13 May 2013 11:24:39 GMT
Author: tmill
Date: Mon May 13 11:24:39 2013
New Revision: 1481791

URL: http://svn.apache.org/r1481791
Log:
Made tree kernel features general to all possible pair combinations of events and times.

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

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/EventTimeFlatTreeFeatureExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/EventTimeFlatTreeFeatureExtractor.java?rev=1481791&r1=1481790&r2=1481791&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/EventTimeFlatTreeFeatureExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/EventTimeFlatTreeFeatureExtractor.java
Mon May 13 11:24:39 2013
@@ -34,33 +34,43 @@ public class EventTimeFlatTreeFeatureExt
 		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()));
+		feats.add(new Feature("TK_BOP_Tree", bopTree.toString()));
+		feats.add(new Feature("TK_BOW_Tree", bowTree.toString()));
 		return feats;
 	}
 
-	private static SimpleTree getTree(JCas jcas, IdentifiedAnnotation arg1, IdentifiedAnnotation
arg2, String label, Function<BaseToken, String> leafFun){
+	private static SimpleTree getTree(JCas jcas, IdentifiedAnnotation arg1, IdentifiedAnnotation
arg2, String label, Function<BaseToken, String> leafFun) throws AnalysisEngineProcessException{
 		SimpleTree tree = new SimpleTree(label);
 		SimpleTree arg1Tree = null;
 		SimpleTree arg2Tree = null;
 		String eventModality="";
-		String timeClass;
+		String timeClass="";
 	
 		// make sure we have the right classes
 		if(arg1 instanceof EventMention){
 			eventModality = ((EventMention)arg1).getEvent().getProperties().getContextualModality();
-			timeClass = ((TimeMention)arg2).getTimeClass();
-
 			arg1Tree = new SimpleTree("EVENT-"+eventModality);
-			arg2Tree = new SimpleTree("TIMEX-"+timeClass);
-		}else{
-			eventModality = ((EventMention)arg2).getEvent().getProperties().getContextualModality();
+		}else if(arg1 instanceof TimeMention){
 			timeClass = ((TimeMention)arg1).getTimeClass();
-
 			arg1Tree = new SimpleTree("TIMEX-"+timeClass);
-			arg2Tree = new SimpleTree("EVENT-"+eventModality);
+		}else{
+		  throw new AnalysisEngineProcessException("Argument type not recognized (arg1) -- must
be EventMention or TimeMention", null);
 		}
 		
+		if(arg2 instanceof EventMention){
+		  EventMention mention = (EventMention) arg2;
+		  if(mention.getEvent() == null || mention.getEvent().getProperties() == null){
+		    System.err.println("Something is null here!");
+		  }
+      eventModality = ((EventMention)arg2).getEvent().getProperties().getContextualModality();
+      arg2Tree = new SimpleTree("EVENT-"+eventModality);		  
+		}else if(arg2 instanceof TimeMention){
+      timeClass = ((TimeMention)arg2).getTimeClass();
+      arg2Tree = new SimpleTree("TIMEX-"+timeClass);		  
+    }else{
+      throw new AnalysisEngineProcessException("Argument type not recognized (arg2) -- must
be EventMention or TimeMention", null);
+    }
+		
 		List<BaseToken> tokens = JCasUtil.selectCovered(jcas, BaseToken.class, arg1.getBegin(),
arg2.getEnd());
 		tree.addChild(arg1Tree);
 		for(BaseToken token : tokens){
@@ -78,5 +88,4 @@ public class EventTimeFlatTreeFeatureExt
 		tree.addChild(arg2Tree);
 		return tree;
 	}
-
 }

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalFTExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalFTExtractor.java?rev=1481791&r1=1481790&r2=1481791&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalFTExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalFTExtractor.java
Mon May 13 11:24:39 2013
@@ -40,22 +40,24 @@ public class TemporalFTExtractor impleme
 			arg2 = temp;
 		}
 		
-		String a1type, a2type;
+		String a1type="", a2type="";
 		String eventModality="";
 		String timeClass;
 		
 		if(arg1 instanceof EventMention){
 			eventModality = ((EventMention)arg1).getEvent().getProperties().getContextualModality();
-			timeClass = ((TimeMention)arg2).getTimeClass();
-			
 			a1type = "EVENT-"+eventModality;
-			a2type = "TIMEX-"+timeClass;
-		}else{
-			eventModality = ((EventMention)arg2).getEvent().getProperties().getContextualModality();
+		}else if(arg1 instanceof TimeMention){
 			timeClass = ((TimeMention)arg1).getTimeClass();
-			
 			a1type = "TIMEX-"+timeClass;
-			a2type = "EVENT-"+eventModality;
+		}
+		
+		if(arg2 instanceof EventMention){
+      eventModality = ((EventMention)arg2).getEvent().getProperties().getContextualModality();
+      a2type = "EVENT-"+eventModality;		  
+		}else if(arg2 instanceof TimeMention){
+      timeClass = ((TimeMention)arg2).getTimeClass();
+      a2type = "TIMEX-"+timeClass;		  
 		}
 		
 		TreebankNode t1 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg1, "ARG1-"+a1type);

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalPETExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalPETExtractor.java?rev=1481791&r1=1481790&r2=1481791&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalPETExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalPETExtractor.java
Mon May 13 11:24:39 2013
@@ -39,22 +39,24 @@ public class TemporalPETExtractor implem
 			arg2 = temp;
 		}
 		
-		String a1type, a2type;
+		String a1type="", a2type="";
 		String eventModality="";
 		String timeClass;
 		
 		if(arg1 instanceof EventMention){
 			eventModality = ((EventMention)arg1).getEvent().getProperties().getContextualModality();
-			timeClass = ((TimeMention)arg2).getTimeClass();
-			
 			a1type = "EVENT-"+eventModality;
-			a2type = "TIMEX-"+timeClass;
-		}else{
-			eventModality = ((EventMention)arg2).getEvent().getProperties().getContextualModality();
-			timeClass = ((TimeMention)arg1).getTimeClass();
-			
+		}else if(arg1 instanceof TimeMention){
+			timeClass = ((TimeMention)arg1).getTimeClass();	
 			a1type = "TIMEX-"+timeClass;
-			a2type = "EVENT-"+eventModality;
+		}
+		
+		if(arg2 instanceof EventMention){
+      eventModality = ((EventMention)arg2).getEvent().getProperties().getContextualModality();
+      a2type = "EVENT-"+eventModality;		  
+		}else if(arg2 instanceof TimeMention){
+      timeClass = ((TimeMention)arg2).getTimeClass();
+      a2type = "TIMEX-"+timeClass;		  
 		}
 		
 		TreebankNode t1 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg1, "ARG1-"+a1type);

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalPathExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalPathExtractor.java?rev=1481791&r1=1481790&r2=1481791&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalPathExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/treekernel/TemporalPathExtractor.java
Mon May 13 11:24:39 2013
@@ -36,20 +36,24 @@ public class TemporalPathExtractor imple
 			arg2 = temp;
 		}
 		
-		String a1type, a2type;
+		String a1type="", a2type="";
 		String eventModality="";
-		String timeClass;
+		String timeClass="";
 
 		if(arg1 instanceof EventMention){
 			eventModality = ((EventMention)arg1).getEvent().getProperties().getContextualModality();
-			timeClass = ((TimeMention)arg2).getTimeClass();
 			a1type = "EVENT-"+eventModality;
-			a2type = "TIMEX-"+timeClass;
-		}else{
-			eventModality = ((EventMention)arg2).getEvent().getProperties().getContextualModality();
+		}else if(arg1 instanceof TimeMention){
 			timeClass = ((TimeMention)arg1).getTimeClass();
 			a1type = "TIMEX-"+timeClass;
-			a2type = "EVENT"+eventModality;
+		}
+		
+		if(arg2 instanceof EventMention){
+      eventModality = ((EventMention)arg2).getEvent().getProperties().getContextualModality();
+      a2type = "EVENT"+eventModality;		  
+		}else if(arg2 instanceof TimeMention){
+      timeClass = ((TimeMention)arg2).getTimeClass();
+      a2type = "TIMEX-"+timeClass;		  
 		}
 		
 		TreebankNode t1 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg1, "ARG1-"+a1type);



Mime
View raw message