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 C8FF3185F1 for ; Thu, 29 Oct 2015 20:09:38 +0000 (UTC) Received: (qmail 95141 invoked by uid 500); 29 Oct 2015 20:09:38 -0000 Delivered-To: apmail-ctakes-commits-archive@ctakes.apache.org Received: (qmail 95099 invoked by uid 500); 29 Oct 2015 20:09:38 -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 95090 invoked by uid 99); 29 Oct 2015 20:09:38 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Oct 2015 20:09:38 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 2D3AEC4C21 for ; Thu, 29 Oct 2015 20:09:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.999 X-Spam-Level: X-Spam-Status: No, score=0.999 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id dSR12GH2bNzD for ; Thu, 29 Oct 2015 20:09:37 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 4BFB720633 for ; Thu, 29 Oct 2015 20:09:37 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B6BB2E0451 for ; Thu, 29 Oct 2015 20:09:36 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 8D03D3A028B for ; Thu, 29 Oct 2015 20:09:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1711353 - /ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/metastasis/ListAndConjunctionAnnotatorPipeline.java Date: Thu, 29 Oct 2015 20:09:36 -0000 To: commits@ctakes.apache.org From: dligach@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151029200936.8D03D3A028B@svn01-us-west.apache.org> Author: dligach Date: Thu Oct 29 20:09:36 2015 New Revision: 1711353 URL: http://svn.apache.org/viewvc?rev=1711353&view=rev Log: added reject/accept states Modified: ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/metastasis/ListAndConjunctionAnnotatorPipeline.java Modified: ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/metastasis/ListAndConjunctionAnnotatorPipeline.java URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/metastasis/ListAndConjunctionAnnotatorPipeline.java?rev=1711353&r1=1711352&r2=1711353&view=diff ============================================================================== --- ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/metastasis/ListAndConjunctionAnnotatorPipeline.java (original) +++ ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/metastasis/ListAndConjunctionAnnotatorPipeline.java Thu Oct 29 20:09:36 2015 @@ -24,6 +24,7 @@ import java.util.List; import java.util.Set; import org.apache.ctakes.relationextractor.data.analysis.Utils; +import org.apache.ctakes.typesystem.type.constants.CONST; import org.apache.ctakes.typesystem.type.syntax.BaseToken; import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation; import org.apache.ctakes.typesystem.type.textspan.Sentence; @@ -37,6 +38,7 @@ import org.apache.uima.fit.pipeline.Simp import org.apache.uima.fit.util.JCasUtil; import org.apache.uima.jcas.JCas; +import com.google.common.collect.Lists; import com.lexicalscope.jewel.cli.CliFactory; import com.lexicalscope.jewel.cli.Option; @@ -56,7 +58,6 @@ public class ListAndConjunctionAnnotator public static void main(String[] args) throws Exception { - System.out.println("beginning..."); Options options = CliFactory.parseArguments(Options.class, args); CollectionReader collectionReader = Utils.getCollectionReader(options.getInputDirectory()); AnalysisEngine listAndConjunctionAnnotator = AnalysisEngineFactory.createEngine(ListAndConjunctionAe.class); @@ -83,42 +84,61 @@ public class ListAndConjunctionAnnotator for(Sentence sentence : JCasUtil.select(systemView, Sentence.class)) { - String state = "start"; + String currentState = "start"; String list = ""; + for(BaseToken token : JCasUtil.selectCovered(systemView, BaseToken.class, sentence)) { - state = getNextState(systemView, state, token); - if(state == "a/s" || state == "punct" || state == "done") { - list = list + " " + token.getCoveredText(); + String nextState = getNextState(systemView, currentState, token); + if(nextState == "accept") { + System.out.println("found list in: " + sentence.getCoveredText()); + break; + } else if(nextState != "reject") { + currentState = nextState; + } else { + currentState = "start"; } - } + } + if(list != "") { System.out.println(sentence.getCoveredText() + "/" + list); } } } - + public String getNextState(JCas systemView, String currentState, BaseToken nextToken) { - Set listConnectors = new HashSet(); - listConnectors.add("and"); - listConnectors.add(","); + Set listConnectors = new HashSet<>(Lists.newArrayList("and", ",")); + + String nextState = "reject"; + int nextTokenSemType = getSemanticType(systemView, nextToken); + String nextTokenText = nextToken.getCoveredText().toLowerCase(); - String nextState = ""; - int tokenSemType = getSemanticType(systemView, nextToken); - if(currentState == "start" && tokenSemType == 6) { - nextState = "a/s"; - } else if(currentState == "start" && tokenSemType != 6) { - nextState = "start"; - } else if(currentState == "a/s" && listConnectors.contains(nextToken.getCoveredText().toLowerCase())) { - nextState = "punct"; - } else if(currentState == "a/s" && ! listConnectors.contains(nextToken.getCoveredText().toLowerCase())) { - nextState = "done"; - } else if(currentState == "punct" && tokenSemType == 6) { - nextState = "a/s"; - } else if(currentState == "punct" && tokenSemType != 6) { - nextState = "reject"; + if(currentState == "start") { + if(nextTokenSemType == CONST.NE_TYPE_ID_ANATOMICAL_SITE) { + nextState = "as1"; + } else { + nextState = "reject"; + } + } else if(currentState == "as1") { + if(listConnectors.contains(nextTokenText)) { + nextState = "punct"; + } else { + nextState = "reject"; + } + } else if(currentState == "punct") { + if(nextTokenSemType == CONST.NE_TYPE_ID_ANATOMICAL_SITE) { + nextState = "as2"; + } else { + nextState = "reject"; + } + } else if(currentState == "as2") { + if(listConnectors.contains(nextTokenText)) { + nextState = "punct"; + } else { + nextState = "accept"; + } } - + return nextState; }