ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1763834 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventEventTokenBasedAnnotator.java
Date Fri, 07 Oct 2016 20:55:48 GMT
Author: dligach
Date: Fri Oct  7 20:55:48 2016
New Revision: 1763834

URL: http://svn.apache.org/viewvc?rev=1763834&view=rev
Log:
rewrote my implementation of getRelCategory

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventEventTokenBasedAnnotator.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventEventTokenBasedAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventEventTokenBasedAnnotator.java?rev=1763834&r1=1763833&r2=1763834&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventEventTokenBasedAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/nn/ae/EventEventTokenBasedAnnotator.java
Fri Oct  7 20:55:48 2016
@@ -119,7 +119,7 @@ public class EventEventTokenBasedAnnotat
    * @param arg2
    * @return
    */
-  protected String getRelationCategory2(
+  protected String getRelationCategory1(
       Map<List<Annotation>, BinaryTextRelation> relationLookup,
       IdentifiedAnnotation arg1,
       IdentifiedAnnotation arg2) {
@@ -152,7 +152,7 @@ public class EventEventTokenBasedAnnotat
    * @param arg2
    * @return
    */
-  protected String getRelationCategory3(Map<List<Annotation>, BinaryTextRelation>
relationLookup,
+  protected String getRelationCategory2(Map<List<Annotation>, BinaryTextRelation>
relationLookup,
       IdentifiedAnnotation arg1,
       IdentifiedAnnotation arg2) {
     
@@ -180,17 +180,28 @@ public class EventEventTokenBasedAnnotat
       IdentifiedAnnotation arg1,
       IdentifiedAnnotation arg2) {
     
-    BinaryTextRelation forwardRelation = relationLookup.get(Arrays.asList(arg1, arg2));
-    BinaryTextRelation reverseRelation = relationLookup.get(Arrays.asList(arg2, arg1));
-    
-    String label = null;
-    if(forwardRelation != null) {
-      label = forwardRelation.getCategory(); // arg1 contains arg2
-    } else if(reverseRelation != null) {
-      label = reverseRelation.getCategory(); // arg2 contains arg1
+    // gold view representation (i.e. only contains relations)
+    BinaryTextRelation arg1ContainsArg2 = relationLookup.get(Arrays.asList(arg1, arg2));
+    BinaryTextRelation arg2ContainsArg1 = relationLookup.get(Arrays.asList(arg2, arg1));
+
+    // now translate to position dependent representation (i.e. contains and contains-1)
+    if(arg1ContainsArg2 != null) {
+      // still need to know whether it's arg1 ... arg2 or arg2 ... arg1
+      // because that determines whether it's contains or contains-1
+      if(arg1.getBegin() < arg2.getBegin()) {
+        return arg1ContainsArg2.getCategory();
+      } else {
+        return arg1ContainsArg2.getCategory() + "-1";
+      }
+    } else if(arg2ContainsArg1 != null) {
+      if(arg1.getBegin() < arg2.getBegin()) {
+        return arg2ContainsArg1.getCategory() + "-1";
+      } else {
+        return arg2ContainsArg1.getCategory();
+      }
+    } else {
+      return null;      
     }
-    
-    return label;
   }
 
   protected void createRelation(JCas jCas, IdentifiedAnnotation arg1,



Mime
View raw message