ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1762507 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn: ae/EventTimeHybridAnnotator.java ae/EventTimeTokenAndPosBasedAnnotator.java eval/EventTimeNeuralEvaluation.java
Date Tue, 27 Sep 2016 15:47:16 GMT
Author: dligach
Date: Tue Sep 27 15:47:16 2016
New Revision: 1762507

URL: http://svn.apache.org/viewvc?rev=1762507&view=rev
Log:
now testing token/pos model

Added:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeTokenAndPosBasedAnnotator.java
      - copied, changed from r1762506, ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeHybridAnnotator.java
Removed:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeHybridAnnotator.java
Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/eval/EventTimeNeuralEvaluation.java

Copied: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeTokenAndPosBasedAnnotator.java
(from r1762506, ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeHybridAnnotator.java)
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeTokenAndPosBasedAnnotator.java?p2=ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeTokenAndPosBasedAnnotator.java&p1=ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeHybridAnnotator.java&r1=1762506&r2=1762507&rev=1762507&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeHybridAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventTimeTokenAndPosBasedAnnotator.java
Tue Sep 27 15:47:16 2016
@@ -28,11 +28,11 @@ import org.cleartk.util.ViewUriUtil;
 
 import com.google.common.collect.Lists;
 
-public class EventTimeHybridAnnotator extends CleartkAnnotator<String> {
+public class EventTimeTokenAndPosBasedAnnotator extends CleartkAnnotator<String> {
 
   public static final String NO_RELATION_CATEGORY = "none";
 
-  public EventTimeHybridAnnotator() {
+  public EventTimeTokenAndPosBasedAnnotator() {
     // TODO Auto-generated constructor stub
   }
 
@@ -42,9 +42,9 @@ public class EventTimeHybridAnnotator ex
     //get all gold relation lookup
     Map<List<Annotation>, BinaryTextRelation> relationLookup;
     relationLookup = new HashMap<>();
-    if (this.isTraining()) {
+    if(this.isTraining()) {
       relationLookup = new HashMap<>();
-      for (BinaryTextRelation relation : JCasUtil.select(jCas, BinaryTextRelation.class))
{
+      for(BinaryTextRelation relation : JCasUtil.select(jCas, BinaryTextRelation.class))
{
         Annotation arg1 = relation.getArg1().getArgument();
         Annotation arg2 = relation.getArg2().getArgument();
         // The key is a list of args so we can do bi-directional lookup
@@ -53,7 +53,7 @@ public class EventTimeHybridAnnotator ex
           String reln = relationLookup.get(key).getCategory();
           System.err.println("Error in: "+ ViewUriUtil.getURI(jCas).toString());
           System.err.println("Error! This attempted relation " + relation.getCategory() +
" already has a relation " + reln + " at this span: " + arg1.getCoveredText() + " -- " + arg2.getCoveredText());
-        }else{
+        } else{
           relationLookup.put(key, relation);
         }
       }
@@ -66,7 +66,7 @@ public class EventTimeHybridAnnotator ex
           getCandidateRelationArgumentPairs(jCas, sentence);
 
       // walk through the pairs of annotations
-      for (IdentifiedAnnotationPair pair : candidatePairs) {
+      for(IdentifiedAnnotationPair pair : candidatePairs) {
         IdentifiedAnnotation arg1 = pair.getArg1();
         IdentifiedAnnotation arg2 = pair.getArg2();
 
@@ -85,16 +85,16 @@ public class EventTimeHybridAnnotator ex
         //derive features based on context:
         List<Feature> features = new ArrayList<>();
         String[] tokens = (tokenContext + "|" + posContext).split(" ");
-        for (String token: tokens){
+        for(String token: tokens){
           features.add(new Feature(token.toLowerCase()));
         }
 
         // during training, feed the features to the data writer
-        if (this.isTraining()) {
+        if(this.isTraining()) {
           String category = getRelationCategory(relationLookup, arg1, arg2);
-          if (category == null) {
+          if(category == null) {
             category = NO_RELATION_CATEGORY;
-          } else{
+          } else {
             category = category.toLowerCase();
           }
           this.dataWriter.write(new Instance<>(category, features));
@@ -104,29 +104,28 @@ public class EventTimeHybridAnnotator ex
           String predictedCategory = this.classifier.classify(features);
 
           // add a relation annotation if a true relation was predicted
-          if (predictedCategory != null && !predictedCategory.equals(NO_RELATION_CATEGORY))
{
+          if(predictedCategory != null && !predictedCategory.equals(NO_RELATION_CATEGORY))
{
 
             // if we predict an inverted relation, reverse the order of the arguments
-            if (predictedCategory.endsWith("-1")) {
+            if(predictedCategory.endsWith("-1")) {
               predictedCategory = predictedCategory.substring(0, predictedCategory.length()
- 2);
               if(arg1 instanceof TimeMention){
                 IdentifiedAnnotation temp = arg1;
                 arg1 = arg2;
                 arg2 = temp;
               }
-            }else{
+            } else {
               if(arg1 instanceof EventMention){
                 IdentifiedAnnotation temp = arg1;
                 arg1 = arg2;
                 arg2 = temp;
               }
             }
-
+            
             createRelation(jCas, arg1, arg2, predictedCategory.toUpperCase(), 0.0);
           }
         }
       }
-
     }
   }
   

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/eval/EventTimeNeuralEvaluation.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/eval/EventTimeNeuralEvaluation.java?rev=1762507&r1=1762506&r2=1762507&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/eval/EventTimeNeuralEvaluation.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/eval/EventTimeNeuralEvaluation.java
Tue Sep 27 15:47:16 2016
@@ -43,8 +43,7 @@ import org.apache.ctakes.temporal.eval.I
 import org.apache.ctakes.temporal.eval.THYMEData;
 import org.apache.ctakes.temporal.keras.KerasStringOutcomeDataWriter;
 import org.apache.ctakes.temporal.keras.ScriptStringFeatureDataWriter;
-import org.apache.ctakes.temporal.nn.ae.EventTimePosBasedAnnotator;
-import org.apache.ctakes.temporal.nn.ae.EventTimeTokenBasedAnnotator;
+import org.apache.ctakes.temporal.nn.ae.EventTimeTokenAndPosBasedAnnotator;
 import org.apache.ctakes.temporal.utils.AnnotationIdCollection;
 import org.apache.ctakes.temporal.utils.TLinkTypeArray2;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
@@ -291,7 +290,7 @@ EvaluationOfTemporalRelations_ImplBase{
       aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(Overlap2Contains.class));
 
       aggregateBuilder.add(
-          AnalysisEngineFactory.createEngineDescription(EventTimeTokenBasedAnnotator.class,
+          AnalysisEngineFactory.createEngineDescription(EventTimeTokenAndPosBasedAnnotator.class,
               CleartkAnnotator.PARAM_IS_TRAINING,
               true,
               DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
@@ -342,7 +341,7 @@ EvaluationOfTemporalRelations_ImplBase{
 
     aggregateBuilder.add(AnalysisEngineFactory.createEngineDescription(RemoveRelations.class));
     aggregateBuilder.add(this.baseline ? RecallBaselineEventTimeRelationAnnotator.createAnnotatorDescription(directory)
:
-      AnalysisEngineFactory.createEngineDescription(EventTimeTokenBasedAnnotator.class,
+      AnalysisEngineFactory.createEngineDescription(EventTimeTokenAndPosBasedAnnotator.class,
           CleartkAnnotator.PARAM_IS_TRAINING,
           false,
           GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,



Mime
View raw message