ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1586480 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/data/analysis/RelationContextViewerPipeline.java
Date Thu, 10 Apr 2014 22:07:33 GMT
Author: tmill
Date: Thu Apr 10 22:07:32 2014
New Revision: 1586480

URL: http://svn.apache.org/r1586480
Log:
CTAKES-82: Print out additional context for temporal relation viewer.

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=1586480&r1=1586479&r2=1586480&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 Apr 10 22:07:32 2014
@@ -30,6 +30,7 @@ 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;
@@ -154,13 +155,23 @@ public class RelationContextViewerPipeli
       BufferedWriter writer = getWriter(outputFile, true);
       try {
         for(BinaryTextRelation binaryTextRelation : JCasUtil.select(goldView, BinaryTextRelation.class))
{
-          
+          boolean sameSentence = false;
           Annotation arg1 = binaryTextRelation.getArg1().getArgument();
           Annotation arg2 = binaryTextRelation.getArg2().getArgument();
-          
           String category = binaryTextRelation.getCategory();
           String text = getTextBetweenAnnotations(systemView, arg1, arg2);
-          String output = String.format("%s|%s|%s|%s\n", category, arg1.getCoveredText(),
arg2.getCoveredText(), text);
+
+          List<Sentence> sents1 = JCasUtil.selectCovering(systemView, Sentence.class,
arg1.getBegin(), arg1.getEnd());
+          List<Sentence> sents2 = JCasUtil.selectCovering(systemView, Sentence.class,
arg2.getBegin(), arg2.getEnd());
+          if(sents1.size() == 1 && sents2.size() == 1){
+            if(sents1.get(0) == sents2.get(0)){
+              sameSentence = true;
+            }
+          }else{
+            System.err.println("Could not find covering sent for relation: " + String.format("%s|%s|%s|%s\n",
category, arg1.getCoveredText(), arg2.getCoveredText(), text));
+          }
+          
+          String output = String.format("%s|%s|%s|%s|%s|%s|%s\n", category, arg1.getCoveredText(),
arg2.getCoveredText(), text, arg1.getType().toString(), arg2.getType().toString(), sameSentence
? "same" : "different");
       
           try {
             writer.write(output);



Mime
View raw message