ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1490330 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/RelationContextViewerPipeline.java
Date Thu, 06 Jun 2013 15:52:28 GMT
Author: dligach
Date: Thu Jun  6 15:52:28 2013
New Revision: 1490330

URL: http://svn.apache.org/r1490330
Log:
expanded the size of the context that's used to display a relation

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/RelationContextViewerPipeline.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/RelationContextViewerPipeline.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/RelationContextViewerPipeline.java?rev=1490330&r1=1490329&r2=1490330&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/RelationContextViewerPipeline.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/RelationContextViewerPipeline.java
Thu Jun  6 15:52:28 2013
@@ -30,7 +30,6 @@ import org.apache.ctakes.core.cr.XMIRead
 import org.apache.ctakes.temporal.eval.CommandLine;
 import org.apache.ctakes.temporal.eval.THYMEData;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
-import org.apache.ctakes.typesystem.type.textspan.Sentence;
 import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.cas.CASException;
@@ -180,10 +179,15 @@ public class RelationContextViewerPipeli
     
     private static String getTextBetweenAnnotations(JCas jCas, Annotation arg1, Annotation
arg2) {
       
-      int begin = Math.min(arg1.getBegin(), arg2.getBegin());
-      int end = Math.max(arg1.getEnd(), arg2.getEnd());
+      final int windowSize = 15;
       
-      return jCas.getDocumentText().substring(begin, end).replaceAll("[\r\n]", " ");
+      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]", " ");
     }
     
     private static BufferedWriter getWriter(String filePath, boolean append) {



Mime
View raw message