Return-Path: X-Original-To: apmail-ctakes-commits-archive@www.apache.org Delivered-To: apmail-ctakes-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4802310494 for ; Tue, 11 Jun 2013 20:16:40 +0000 (UTC) Received: (qmail 37933 invoked by uid 500); 11 Jun 2013 20:16:40 -0000 Delivered-To: apmail-ctakes-commits-archive@ctakes.apache.org Received: (qmail 37900 invoked by uid 500); 11 Jun 2013 20:16:40 -0000 Mailing-List: contact commits-help@ctakes.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ctakes.apache.org Delivered-To: mailing list commits@ctakes.apache.org Received: (qmail 37893 invoked by uid 99); 11 Jun 2013 20:16:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jun 2013 20:16:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jun 2013 20:16:39 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 903E62388906; Tue, 11 Jun 2013 20:16:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1491939 - /ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/RelationAnnotationViewer.java Date: Tue, 11 Jun 2013 20:16:19 -0000 To: commits@ctakes.apache.org From: dligach@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130611201619.903E62388906@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dligach Date: Tue Jun 11 20:16:19 2013 New Revision: 1491939 URL: http://svn.apache.org/r1491939 Log: removed unneeded checks for "Argument" and "Related_to" Modified: ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/RelationAnnotationViewer.java Modified: ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/RelationAnnotationViewer.java URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/RelationAnnotationViewer.java?rev=1491939&r1=1491938&r2=1491939&view=diff ============================================================================== --- ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/RelationAnnotationViewer.java (original) +++ ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/pipelines/RelationAnnotationViewer.java Tue Jun 11 20:16:19 2013 @@ -23,8 +23,10 @@ import java.util.Arrays; import java.util.List; import org.apache.ctakes.relationextractor.eval.XMIReader; +import org.apache.ctakes.typesystem.type.constants.CONST; import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation; import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation; +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.CAS; @@ -83,51 +85,47 @@ public class RelationAnnotationViewer { } for(BinaryTextRelation binaryTextRelation : JCasUtil.select(systemView, BinaryTextRelation.class)) { - IdentifiedAnnotation entity1; // entity whose role is "Argument" - IdentifiedAnnotation entity2; // entity whose role is "Related_to" - - if(binaryTextRelation.getArg1().getRole().equals("Argument")) { - entity1 = (IdentifiedAnnotation) binaryTextRelation.getArg1().getArgument(); - entity2 = (IdentifiedAnnotation) binaryTextRelation.getArg2().getArgument(); - } else { - entity1 = (IdentifiedAnnotation) binaryTextRelation.getArg2().getArgument(); - entity2 = (IdentifiedAnnotation) binaryTextRelation.getArg1().getArgument(); + + IdentifiedAnnotation entity1 = (IdentifiedAnnotation) binaryTextRelation.getArg1().getArgument(); + IdentifiedAnnotation entity2 = (IdentifiedAnnotation) binaryTextRelation.getArg2().getArgument(); + + String category = binaryTextRelation.getCategory(); + if(! category.equals("location_of")) { + continue; } - String category = binaryTextRelation.getCategory(); String arg1 = entity1.getCoveredText().toLowerCase(); String arg2 = entity2.getCoveredText().toLowerCase(); int type1 = entity1.getTypeID(); int type2 = entity2.getTypeID(); // first argument has to be an anatomical site - if(type1 != 6) { + if(type1 != CONST.NE_TYPE_ID_ANATOMICAL_SITE) { continue; } // skip location_of(anatomical site, anatomical site) - if(type1 == 6 && type2 == 6) { + if(type1 == CONST.NE_TYPE_ID_ANATOMICAL_SITE && type2 == CONST.NE_TYPE_ID_ANATOMICAL_SITE) { continue; } - // "to" is not a valid disease/disorder - if(type2 == 3 && arg2.equals("to")) { - continue; - } - // print relation and its arguments: location_of(colon/6, colon cancer/2) - System.out.format("%s(%s/%d, %s/%d)\n", category, arg1, type1, arg2, type2); + List enclosingSentences = JCasUtil.selectCovering( + systemView, + Sentence.class, + entity1.getBegin(), + entity2.getEnd()); + + System.out.format("%s|%s|%s\n", arg1, arg2, enclosingSentences.get(0).getCoveredText()); } } } private static CollectionReader getCollectionReader(List items) throws Exception { - // convert the List to a String[] String[] paths = new String[items.size()]; for (int i = 0; i < paths.length; ++i) { paths[i] = items.get(i).getPath(); } - // return a reader that will load each of the XMI files return CollectionReaderFactory.createCollectionReader( XMIReader.class, XMIReader.PARAM_FILES,