ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1746614 - /ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/PositiveAndNegativeExamplePrinter.java
Date Thu, 02 Jun 2016 18:31:40 GMT
Author: dligach
Date: Thu Jun  2 18:31:40 2016
New Revision: 1746614

URL: http://svn.apache.org/viewvc?rev=1746614&view=rev
Log:
fixed most relations with one of the arguments "missing"

Modified:
    ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/PositiveAndNegativeExamplePrinter.java

Modified: ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/PositiveAndNegativeExamplePrinter.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/PositiveAndNegativeExamplePrinter.java?rev=1746614&r1=1746613&r2=1746614&view=diff
==============================================================================
--- ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/PositiveAndNegativeExamplePrinter.java
(original)
+++ ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/PositiveAndNegativeExamplePrinter.java
Thu Jun  2 18:31:40 2016
@@ -21,7 +21,6 @@ package org.apache.ctakes.pipelines;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
-import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardOpenOption;
 import java.util.ArrayList;
@@ -184,11 +183,13 @@ public class PositiveAndNegativeExampleP
     
     List<String> tokens = new ArrayList<>();
     for(BaseToken baseToken : JCasUtil.selectCovered(jCas, BaseToken.class, sent)) {
-      if(baseToken.getBegin() == arg1.getBegin() && (baseToken.getEnd() == arg1.getEnd()))
{
+      // for a few hundred examples, begin/end offsets don't both match token begin/end
+      // so using an 'or' rather than 'and'
+      if(baseToken.getBegin() == arg1.getBegin() || (baseToken.getEnd() == arg1.getEnd()))
{
         tokens.add("<e1>");
         tokens.add(baseToken.getCoveredText());
         tokens.add("</e1>");
-      } else if(baseToken.getBegin() == arg2.getBegin() && (baseToken.getEnd() ==
arg2.getEnd())) {
+      } else if(baseToken.getBegin() == arg2.getBegin() || (baseToken.getEnd() == arg2.getEnd()))
{
         tokens.add("<e2>");
         tokens.add(baseToken.getCoveredText());
         tokens.add("</e2>");
@@ -200,7 +201,7 @@ public class PositiveAndNegativeExampleP
     return String.join(" ", tokens).replaceAll("[\r\n]", " ");
   }
   
-  public static String getTextBetween(JCas jCas, Annotation arg1, Annotation arg2)  {
+  public static String getTokensBetween(JCas jCas, Annotation arg1, Annotation arg2)  {
     
     // todo: use 2 tokens for things like 'during those hospitalizations ...'
     // todo: ensure previous tokens are in the same sentence
@@ -221,29 +222,4 @@ public class PositiveAndNegativeExampleP
     
     return tokens.toString().replaceAll("[\r\n]", " ");
   }
-  
-  @SuppressWarnings("unused")
-  private static String annotateEvents(List<EventMention> eventMentions, Sentence sentence)
{
-    
-    String text = sentence.getCoveredText();
-    for(EventMention eventMention : eventMentions) {
-      text = text.replace(eventMention.getCoveredText(), "[" + eventMention.getCoveredText()
+ "]");
-    }
-    
-    return text;
-  }
-  
-  @SuppressWarnings("unused")
-  private static String getTextBetweenAnnotations(JCas jCas, Annotation arg1, Annotation
arg2) {
-
-    final int windowSize = 0;
-
-    String text = jCas.getDocumentText();
-    int leftArgBegin = Math.min(arg1.getBegin(), arg2.getBegin());
-    int rightArgEnd = Math.max(arg1.getEnd(), arg2.getEnd());
-    int begin = Math.max(0, leftArgBegin - windowSize);
-    int end = Math.min(text.length(), rightArgEnd + windowSize); 
-
-    return text.substring(begin, end).replaceAll("[\r\n]", " ");
-  }
 }



Mime
View raw message