ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1481792 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal: ae/ ae/feature/ eval/
Date Mon, 13 May 2013 11:29:29 GMT
Author: tmill
Date: Mon May 13 11:29:28 2013
New Revision: 1481792

URL: http://svn.apache.org/r1481792
Log:
Best-performing configuration of event-event extractor with one new feature and one completed.

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventRelations.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java?rev=1481792&r1=1481791&r2=1481792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/EventEventRelationAnnotator.java
Mon May 13 11:29:28 2013
@@ -10,6 +10,8 @@ import org.apache.ctakes.relationextract
 import org.apache.ctakes.relationextractor.ae.features.PartOfSpeechFeaturesExtractor;
 import org.apache.ctakes.relationextractor.ae.features.RelationFeaturesExtractor;
 import org.apache.ctakes.relationextractor.ae.features.TokenFeaturesExtractor;
+import org.apache.ctakes.temporal.ae.feature.EventArgumentPropertyExtractor;
+import org.apache.ctakes.temporal.ae.feature.UmlsFeatureExtractor;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
@@ -62,6 +64,11 @@ public class EventEventRelationAnnotator
 	    return Lists.newArrayList(
 	    						  new TokenFeaturesExtractor()
 	    						, new PartOfSpeechFeaturesExtractor()
+	    						, new EventArgumentPropertyExtractor()
+	    						, new UmlsFeatureExtractor()
+//	    						, new DependencyTreeFeaturesExtractor()
+//	    						, new DependencyPathFeaturesExtractor()
+	    						
 //	    						, new TemporalAttributeFeatureExtractor()
 //	    						, new EventTimeFlatTreeFeatureExtractor()
 //	    						, new TemporalPETExtractor()
@@ -81,8 +88,10 @@ public class EventEventRelationAnnotator
 	    List<IdentifiedAnnotationPair> pairs = Lists.newArrayList();
 	    List<EventMention> events = new ArrayList<EventMention>(JCasUtil.selectCovered(jCas,
EventMention.class, sentence));
 	    for (int i = 0; i < events.size(); i++){
+	      if(!events.get(i).getClass().equals(EventMention.class)) continue;
 	    	for(int j = i+1; j < events.size(); j++){
-	          pairs.add(new IdentifiedAnnotationPair(events.get(i), events.get(j)));
+	    	  if(!events.get(j).getClass().equals(EventMention.class)) continue;
+	        pairs.add(new IdentifiedAnnotationPair(events.get(i), events.get(j)));
 	    	}
 	    }
 	    return pairs;

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java?rev=1481792&r1=1481791&r2=1481792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/feature/UmlsFeatureExtractor.java
Mon May 13 11:29:28 2013
@@ -27,6 +27,7 @@ import org.apache.ctakes.relationextract
 import org.apache.ctakes.typesystem.type.textsem.EntityMention;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.utils.struct.CounterMap;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.cas.CASException;
 import org.apache.uima.jcas.JCas;
@@ -48,23 +49,47 @@ public class UmlsFeatureExtractor implem
       throw new AnalysisEngineProcessException(e);
     }
     
-    // TODO: add the same logic for arg2
     if(arg1 instanceof EventMention) {
-      List<EntityMention> entityMentions = JCasUtil.selectCovering(systemView, EntityMention.class,
arg1.getBegin(), arg1.getEnd());
+//      List<EntityMention> entityMentions = JCasUtil.selectCovering(systemView, EntityMention.class,
arg1.getBegin(), arg1.getEnd());
+
+      CounterMap<String> typeCounts = 
+          getMentionTypes(JCasUtil.selectCovering(systemView, EntityMention.class, arg1.getBegin(),
arg1.getEnd()));
       
-      Set<Integer> uniqueTypeIDs = new HashSet<Integer>();
-      for(EntityMention entityMention : entityMentions) {
-        uniqueTypeIDs.add(entityMention.getTypeID());
-        features.add(new Feature("arg1EntityTypeID", String.valueOf(entityMention.getTypeID())));
+      // print out totals:
+      for(String typeId : typeCounts.keySet()){
+        features.add(new Feature("arg1EntityTypeID_"+typeId, typeCounts.get(typeId)));  
     
       }
       
+      // TO print out just the types without counts:
+//      for(String typeId : typeCounts.keySet()){
+//        features.add(new Feature("arg1EntityTypeID_", typeId));
+//      }
+      
       // TODO: this is the correct implementatino, but it does not perform as well 
 //      for(int typeID : uniqueTypeIDs) {
 //        features.add(new Feature("arg1EntityTypeID", String.valueOf(typeID)));
 //      }
 
     }
-    
+
+    if(arg2 instanceof EventMention){
+      CounterMap<String> typeCounts = 
+          getMentionTypes(JCasUtil.selectCovering(systemView, EntityMention.class, arg2.getBegin(),
arg2.getEnd()));
+      
+      // print out totals:
+      for(String typeId : typeCounts.keySet()){
+        features.add(new Feature("arg2EntityTypeID_"+typeId, typeCounts.get(typeId)));  
     
+      }      
+    }
     return features;
   }
+  
+  private static CounterMap<String> getMentionTypes(List<EntityMention> entities){
+    CounterMap<String> typeCounts = new CounterMap<String>();
+    for(EntityMention entityMention : entities) {
+      typeCounts.add(String.valueOf(entityMention.getTypeID()));
+    }
+    return typeCounts;
+    
+  }
 }

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventRelations.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventRelations.java?rev=1481792&r1=1481791&r2=1481792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventRelations.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventEventRelations.java
Mon May 13 11:29:28 2013
@@ -55,8 +55,8 @@ EvaluationOfTemporalRelations_ImplBase {
   }
 
   @Override
-  protected void train(CollectionReader collectionReader, File directory)
-      throws Exception {
+  protected void train(CollectionReader collectionReader, File directory) throws Exception
+       {
     AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
     aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class, TimeMention.class,
BinaryTextRelation.class));
     //	    aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(MergeContainsOverlap.class));
@@ -69,13 +69,17 @@ EvaluationOfTemporalRelations_ImplBase {
     aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(PreserveEventEventRelations.class));
     aggregateBuilder.add(EventEventRelationAnnotator.createDataWriterDescription(
         LIBSVMStringOutcomeDataWriter.class,
-        //	        TKSVMlightStringOutcomeDataWriter.class,
+//        	        TKSVMlightStringOutcomeDataWriter.class,
         directory,
         1.0));
     SimplePipeline.runPipeline(collectionReader, aggregateBuilder.createAggregate());
 
     HideOutput hider = new HideOutput();
+    // libsvm:
     JarClassifierBuilder.trainAndPackage(directory,  "-t", "0", "-c", "10");
+    // tksvmlight with no tk features:
+//    JarClassifierBuilder.trainAndPackage(directory, "-t", "0", "-c", "10", "-N", "0");
+//    JarClassifierBuilder.trainAndPackage(directory,  "-t", "5", "-S", "0", "-N", "3", "-C",
"+", "-T", "1.0");
     hider.restoreOutput();
     hider.close();
   }

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java?rev=1481792&r1=1481791&r2=1481792&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTemporalRelations_ImplBase.java
Mon May 13 11:29:28 2013
@@ -53,7 +53,7 @@ public abstract class EvaluationOfTempor
 
 	public EvaluationOfTemporalRelations_ImplBase(File baseDirectory,
 			File rawTextDirectory, File knowtatorXMLDirectory,
-			File xmiDirectory, File treebankDirectory, boolean printRelations, boolean printErrors,
ParameterSettings params) {
+			File xmiDirectory, File treebankDirectory, boolean printErrors, boolean printRelations,
ParameterSettings params) {
 		super(baseDirectory, rawTextDirectory, knowtatorXMLDirectory, xmiDirectory,
 				treebankDirectory);
 		this.params = params;



Mime
View raw message