Return-Path: X-Original-To: apmail-uima-user-archive@www.apache.org Delivered-To: apmail-uima-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 439C81872A for ; Fri, 13 Nov 2015 14:22:42 +0000 (UTC) Received: (qmail 43694 invoked by uid 500); 13 Nov 2015 14:22:42 -0000 Delivered-To: apmail-uima-user-archive@uima.apache.org Received: (qmail 43669 invoked by uid 500); 13 Nov 2015 14:22:42 -0000 Mailing-List: contact user-help@uima.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@uima.apache.org Delivered-To: mailing list user@uima.apache.org Received: (qmail 43658 invoked by uid 99); 13 Nov 2015 14:22:41 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Nov 2015 14:22:41 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 51C3C180EA9 for ; Fri, 13 Nov 2015 14:22:41 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1 X-Spam-Level: * X-Spam-Status: No, score=1 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H2=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 1NAJiDLID3wz for ; Fri, 13 Nov 2015 14:22:31 +0000 (UTC) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 7BFBD20270 for ; Fri, 13 Nov 2015 14:22:30 +0000 (UTC) Received: from [192.168.11.108] ([132.230.176.14]) by mrelayeu.kundenserver.de (mreue003) with ESMTPSA (Nemesis) id 0MZysF-1Zgxqd0oZD-00Ljjw for ; Fri, 13 Nov 2015 15:22:28 +0100 Subject: Re: how to call UIMA Ruta from uimaFIT To: user@uima.apache.org References: <5644958A.4040405@averbis.com> <5645DF38.1000207@averbis.com> From: =?UTF-8?Q?Peter_Kl=c3=bcgl?= Message-ID: <5645F273.6020701@averbis.com> Date: Fri, 13 Nov 2015 15:23:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:P7hUHgpxhUjVIq18pMYg8/QjhXWfPKmICgq8BmnXETelSoV/My4 upwcE3o7FTnN+YApJo4+9VQTwQc2hdB6/0/DG+biXPaDlXADUCvXUgMQ7ibAZSlN9F/zciZ a+IZ8sSwOgWSlUkFT4RJNcpn9ULJJ7XqusqxD09GyOSurb24a8ZzH9qcV4QH/v9JUfLtB5S F50Xp4+rPe46SCeKHITzw== X-UI-Out-Filterresults: notjunk:1;V01:K0:wJC6KN4223I=:szi2njQI17uX/MM/DLjrmQ Rhp/syYnOp1JRDr25vPndIz8IOQSsMscT7pDkGaauFi0mh4rvNC26Uvfu2rKQXKAVXgQArRtf iLGjEiQj/4d9NUKK6XY8HM1DBm2W6cydoUFcfeJufQJvObxqfH9iz4FkT5gc27vCA30+Wrvw5 tVf1ChXQTL1s9OSGaI1iiJQuaskDLtHJmgVyWMTTm1OHTSUGlP6MR2Tc9ctZG4heIQtNiIafz AzGKUDzrLi/fa250+fUY8BSnTOeyKEBpvS31fXk83DTLrkYVZ0Vqbcb1klbJX1RwnhgfcQSPE OT3JpBitoi0659QV6FkYiqhuK1R9/LYO7QHwR/kE64/2d4mQaMEZyxQknypZuN+uD41DdtmnE ajxJH142y8Rji6HIPE6o+Ekf6Ebs7V92KQ0VIMRTVdYFc6le79mi1GNS7N1hAUY/b+/3uG80d gd9BNPGm7ypdWiQuolrz++fc6DlcLjzc5ZyRuPweXJqXP8FyMMicncEsuj4+xuDlJNAiKx3nx CBF8T7MKK4i5j4HwwOQjTkoIbi8cRyPjrojHDtQZ7ju41Z7f10yui7JNn860WAdCDeJm5fDyX gxP2H7ZIt6UAyERZvAGWno8xq2jbUUzyWMluOIiCZcRILIz9WhNzcuUE1RvvUx7vJEEUQLrEm zWn609vr8bxLuIAN3Y1lXROa1hQMrtq3TbZgtSlupsXpzXkPqX4/Y0nTyjEfKBjpO4TokNR2s 8GHKWnMcjhfWGf+Q Hi, you're welcome :-) Yes, the class is not generated automatically when the project is imported. I usually call "maven->update project" which cleans and builds the project and helps Eclipse to update the source folders. Best, Peter Am 13.11.2015 um 15:18 schrieb Olivier Austina: > Hi Peter, > > Thank for your help it works very very well now. > The first time I import your project, it indicates an error for import > tutorial.entity.Date.Date statement. I fixed it following this post here > > if it can help someone also. These 4 instructions : *Clean, refresh, build, > restart.* > Thank you again. > > Regards > Olivier > > > 2015-11-13 14:01 GMT+01:00 Peter Klügl : > >> Hi, >> >> I assume that there are several problems, e.g., the missing JCas cover >> classes. >> >> I have taken the liberty to create a project based on your example like >> I would use ruta right now (with 2.3.1): >> http://people.apache.org/~pkluegl/examples/date-example.zip >> >> - the script file are in src/main/ruta >> - the wordlist file is in src/main/resources >> - the descriptors are generated to target/generated-sources/ruta >> - the JCas cover classes are generated to target/generated-sources/jcasgen >> - src/test/java contains two JUnit tests: one based on the generated >> descriptor and one based on uimaFIT without ae descriptor >> >> Let me know if this helps and/or you have questions about the project >> setup. >> >> Best, >> >> Peter >> >> Am 12.11.2015 um 17:04 schrieb Olivier Austina: >>> Hi Peter, >>> >>> >>> Thank you for you reply. To answer to your questions: >>> >>> >>> - who created DateTypeSystem.xml? Was it the ruta-maven-plugin or the >>> build process of the Ruta Workbench? Did you move the type system >>> descriptor, e.g., making the import in the AE descriptor invalid? >>> >>> DateTypeSystem.xml is created by the Ruta Workbench. I have created the >>> project with Ruta Workbench and then try to use it in java program with >>> maven. This is the DateTypeSystem.xml file content : >>> >>> >>> >>> tutorial.entity.DateTypeSystem >>> >>> >>> >>> >>> >>> tutorial.entity.Date.Month >>> Type defined in >> tutorial.entity.Date >>> uima.tcas.Annotation >>> >>> >>> tutorial.entity.Date.Year >>> Type defined in >> tutorial.entity.Date >>> uima.tcas.Annotation >>> >>> >>> tutorial.entity.Date.Date >>> Type defined in >> tutorial.entity.Date >>> uima.tcas.Annotation >>> >>> >>> >>> >>> - did you include the jcasgen-maven-plugin in your pom? Or did you use >>> the Component Descriptor Editor to create JCas cover classes. >>> >>> No I didn't use it. I have only create a simple maven project with >> eclipse >>> and try to call UIMA Ruta with uimaFIT. >>> >>> - the error messages indicate that the type system import of your >>> analysis engine has some problems and that the Month type is not >>> resolved. Furthermore,tThe Month class (JCas cover class for the type) >>> is missing. Either there was already a class or JCasGen was not executed. >>> >>> Can you provide the complete pom and a short description of the layout >>> of your project? >>> >>> This is the pom: >>> >>> >> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >>> http://maven.apache.org/xsd/maven-4.0.0.xsd"> >>> 4.0.0 >>> >>> tuto >>> tuto-step0 >>> 0.0.1-SNAPSHOT >>> jar >>> >>> tuto-step0 >>> http://maven.apache.org >>> >>> >>> UTF-8 >>> >>> >>> >>> >>> org.apache.uima >>> ruta-core >>> 2.3.1 >>> >>> >>> >>> org.apache.uima >>> uimafit-core >>> 2.1.0 >>> >>> >>> junit >>> junit >>> 3.8.1 >>> test >>> >>> >>> >>> >>> This is java code with imports: >>> >>> package tuto.tuto_step0; >>> >>> import java.io.File; >>> import java.io.IOException; >>> >>> import org.apache.uima.UIMAFramework; >>> import org.apache.uima.analysis_engine.AnalysisEngine; >>> import org.apache.uima.analysis_engine.AnalysisEngineProcessException; >>> import org.apache.uima.cas.CAS; >>> import org.apache.uima.cas.CASException; >>> import org.apache.uima.cas.text.AnnotationFS; >>> import org.apache.uima.cas.text.AnnotationIndex; >>> import org.apache.uima.fit.util.ContainmentIndex.Type; >>> import org.apache.uima.fit.util.JCasUtil; >>> import org.apache.uima.jcas.JCas; >>> import org.apache.uima.resource.ResourceInitializationException; >>> import org.apache.uima.resource.ResourceSpecifier; >>> import org.apache.uima.util.InvalidXMLException; >>> import org.apache.uima.util.XMLInputSource; >>> >>> >>> >>> public class App >>> { >>> public static void main( String[] args ) throws IOException, >>> InvalidXMLException, ResourceInitializationException, >>> AnalysisEngineProcessException, CASException >>> { >>> //System.out.println( "Hello World!" ); >>> File specFile = new >>> >> File("/home/olhome/software/workspace/rutatest1/dateproject/descriptor/tutorial/entity/DateEngine.xml"); >>> XMLInputSource in = new XMLInputSource(specFile); >>> ResourceSpecifier specifier = UIMAFramework.getXMLParser(). >>> parseResourceSpecifier(in); >>> // for import by name... set the datapath in the >> ResourceManager >>> AnalysisEngine ae = >>> UIMAFramework.produceAnalysisEngine(specifier); >>> CAS cas = ae.newCAS(); >>> cas.setDocumentText("This is my document. March June >>> December"); >>> ae.process(cas); >>> // For plain UIMA >>> /* >>> org.apache.uima.cas.Type monthType = >>> cas.getTypeSystem().getType("tutorial.entity.Date.Month"); >>> AnnotationIndex annotationIndex = >>> cas.getAnnotationIndex(monthType); >>> for (AnnotationFS each : annotationIndex) { >>> System.out.println(each.getCoveredText()); >>> } >>> */ >>> >>> JCas jcas = cas.getJCas(); >>> for (Month month : JCasUtil.select(jcas, Month.class)) { >>> System.out.println(month.getCoveredText()); >>> } >>> >>> >>> } >>> } >>> >>> Thank you. >>> >>> Regards >>> Olivier >>> >>> >>> 2015-11-12 14:35 GMT+01:00 Peter Klügl : >>> >>>> Hi, >>>> >>>> here a few fast comments and questions: >>>> - the example code uses uimaFIT only for the select, but not for the >>>> creation/initialization of the components/CAS. Thus, >>>> org.apache.uima.fit/types.txt won't help much. However, the types should >>>> be included by the import in the AE. >>>> - who created DateTypeSystem.xml? Was it the ruta-maven-plugin or the >>>> build process of the Ruta Workbench? Did you move the type system >>>> descriptor, e.g., making the import in the AE descriptor invalid? >>>> - did you include the jcasgen-maven-plugin in your pom? Or did you use >>>> the Component Descriptor Editor to create JCas cover classes. >>>> - the error messages indicate that the type system import of your >>>> analysis engine has some problems and that the Month type is not >>>> resolved. Furthermore,tThe Month class (JCas cover class for the type) >>>> is missing. Either there was already a class or JCasGen was not >> executed. >>>> Can you provide the complete pom and a short description of the layout >>>> of your project? >>>> >>>> Best, >>>> >>>> Peter >>>> >>>> PS: a uimaFIT like approach for creating a Ruta engine could look like >>>> (whereas direct initialization of AE should be avoided in general): >>>> AnalysisEngine ae = createEngine(RutaEngine.class, >>>> RutaEngine.PARAM_MAIN_SCRIPT, >>>> "org.apache.uima.ruta.engine.UimafitTest", >>>> RutaEngine.PARAM_SCRIPT_PATHS, new String[] { >>>> "src/test/resources" }); >>>> >>>> >>>> Am 12.11.2015 um 14:12 schrieb Olivier Austina: >>>>> Hi, >>>>> >>>>> I try to call a simple UIMA ruta script from uimaFIT in java. It works >> in >>>>> plain UIMA but it didn't work in uimaFIT for me. Here is the script: >>>>> >>>>> PACKAGE tutorial.entity; >>>>> WORDLIST MonthsList = 'month.txt'; >>>>> DECLARE Month; >>>>> DECLARE Year; >>>>> DECLARE Date; >>>>> Document{-> MARKFAST(Month, MonthsList )}; >>>>> NUM{REGEXP("19..|20..") -> MARK(Year,1,2)}; >>>>> Month Year {-> MARK(Date,1,2)}; >>>>> >>>>> Here is the java code (based on Ruta doc example): >>>>> >>>>> //System.out.println( "Hello World!" ); >>>>> File specFile = new >>>>> >> File("/home/olhome/software/workspace/rutatest1/dateproject/descriptor/tutorial/entity/DateEngine.xml"); >>>>> XMLInputSource in = new XMLInputSource(specFile); >>>>> ResourceSpecifier specifier = UIMAFramework.getXMLParser(). >>>>> parseResourceSpecifier(in); >>>>> // for import by name... set the datapath in the >>>> ResourceManager >>>>> AnalysisEngine ae = >>>>> UIMAFramework.produceAnalysisEngine(specifier); >>>>> CAS cas = ae.newCAS(); >>>>> cas.setDocumentText("This is my document. March June >>>>> December"); >>>>> ae.process(cas); >>>>> >>>>> JCas jcas = cas.getJCas(); >>>>> for (Month month : JCasUtil.select(jcas, Month.class)) { >>>>> System.out.println(month.getCoveredText()); >>>>> } >>>>> >>>>> This is the pom dependencies: >>>>> >>>>> >>>>> org.apache.uima >>>>> ruta-core >>>>> 2.3.1 >>>>> >>>>> >>>>> >>>>> org.apache.uima >>>>> uimafit-core >>>>> 2.1.0 >>>>> >>>>> >>>>> >>>>> I have the following error: >>>>> >>>>> Exception in thread "main" java.lang.Error: Unresolved compilation >>>>> problems: >>>>> Month cannot be resolved to a type >>>>> Bound mismatch: The generic method select(FSArray, Class) of >> type >>>>> JCasUtil is not applicable for the arguments (JCas, Class). The >>>>> inferred type Month is not a valid substitute for the bounded parameter >>>> >>>> extends TOP> >>>>> Month cannot be resolved to a type >>>>> at tuto.tuto_step0.App.main(App.java:51) >>>>> >>>>> >>>>> It seems that I am not able to correctly import types like in the maven >>>>> example. I am not so familiar with maven. I have put the >>>> DateTypeSystem.xml >>>>> in a folder called tuto under src folder and add the line >>>>> "classpath*:/tuto/DateTypeSystem.xml" in the text file >>>>> src/META-INF/org.apache.uima.fit/types.txt. >>>>> >>>>> Any suggestion is welcome. Thank you. >>>>> >>>>> Regards >>>>> Olivier >>>>> >>