uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Klügl <peter.klu...@averbis.com>
Subject Re: Error using RUTA from Java
Date Thu, 21 May 2015 15:41:24 GMT
Hi,

unfortunately, Ruta.createAnalysisEngineDescription() does not provide
the functionality to create a valid descriptor for a multi-script
analysis engine. That should be changed and/or the documentation should
be extended/updated.

Here are some option right now (not tested yet, but I will test it when
I find the time):
1. use the descriptors built by the UIMA Ruta Workbench
2. set the configuration parameters manually
3. use a different method of creating the descriptor

1. There are absolute paths, but if the files are not found there, then
the classpath is used as fallback.

2. Something like:
...
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeDes);
ae.setConfigParameterValue(RutaEngine.PARAM_ADDITIONAL_SCRIPTS, new
String[] {"Base", "Crase"});
ae.reconfigure();


3. In UIMA Ruta 2.3.0 there is/will be a lot of new functionality,
especially a maven plugin for building analysis engine and type system
descriptors from script files. The important code is in
RutaDescriptorFactory. There is a unit test that gives some hint how to
use the factory:
GenerateDescriptorTest.testCreateAnalysisEngineDescription()
There is also an exemplary maven project:
example-projects/ruta-maven-example

You could do something like the following:
...
RutaDescriptorFactory rdf = new RutaDescriptorFactory();
RutaDescriptorInformation descriptorInformation =
rdf.parseDescriptorInformation(scriptText);
RutaBuildOptions options = new RutaBuildOptions();
ClassLoader classLoader = UIMAChecker.class.getClassLoader();
AnalysisEngineDescription aed = rdf.createAnalysisEngineDescription(null,
        descriptorInformation, options, null, null, null, classLoader);
AnalysisEngineMetaData metaData = aed.getAnalysisEngineMetaData();
metaData.setTypeSystem(tsd);
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeDes);

.. using createDescriptions() instead of
createAnalysisEngineDescription() is necessary if you define new types
in your scripts.

Best,

Peter





Am 21.05.2015 um 14:04 schrieb William Colen:
> Thank you, Peter.
>
> Maybe that is the case. I am not setting any parameter, as follows:
>
> TypeSystemDescription tsd =
>> TypeSystemDescriptionFactory.createTypeSystemDescription("MainTypeSystem");
>> URL url = Resources.getResource("Main.ruta");
>> String scriptText = Resources.toString(url, Charsets.UTF_8);
>> AnalysisEngineDescription aeDes =
>> Ruta.createAnalysisEngineDescription(scriptText, tsd);
>> AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeDes);
>
> Are there any tutorial explaining how to do that from command line? We can
> execute everything correctly from Ruta tools for Eclipse.
>
> The source code is open:
>
> This is from where we call RUTA:
> https://github.com/Fichberg/cogroo4/blob/labXP215_Will/cogroo-gc/src/main/java/org/cogroo/tools/checker/checkers/UIMAChecker.java
>
> The scripts and the type system:
>
> https://github.com/Fichberg/cogroo4/tree/labXP215_Will/cogroo-ruta
>
>
> Thank you for your help!
> William
>
> 2015-05-21 4:55 GMT-03:00 Peter Klügl <peter.kluegl@averbis.com>:
>
>> Hi,
>>
>> I must admit that I do not know the source of the problem yet.
>>
>> Either RutaParser.file_input() (or RutaEngine.loadScript/IS()) returns
>> null, but this should cause some other exceptions. Or the linking of
>> mentioned/imported script names in the ruta file does not match the
>> names in the configuration parameters.
>>
>> Some questions to narrow down the problem:
>> - Is the analysis engine configured correctly? Do the values of
>> additionalScripts match the scripts imported in the main ruta file?
>> - Are there any spaces in paths, or any period in file names?
>> - Do you use the UIMA Ruta Workbench? If yes, are there any problems
>> reported?
>> - Are you able to load/process the analysis engine of the imported
>> script for their own? Just to exclude some hidden parser error there.
>> - Can you check if there are any typos in the file names?
>> - Can you switch to absolute paths (scriptPaths, descriptorPaths,... )
>> to rule out problems with the classloader approach?
>> - Can you post the complete configuration of the analysis engine?
>>
>> If all fails, we need to debug... my first guess would be to investigate
>> why there is a null value in RutaModule.setScriptDependencies() or why a
>> module is not assigned in that map.
>> If it is an option concerning non-disclosure, you can send me the files
>> (or a small project where the problem can be reproduced) and I will
>> debug it. (You can of course send it to me directly off-list).
>>
>> Best,
>>
>> Peter
>>
>> Am 21.05.2015 um 01:26 schrieb William Colen:
>>> Thank you, Peter.
>>>
>>> I was using 2.2.1 and upgraded to 2.3.0 RC2 as you advised, but the error
>>> persists. Now I will post the complete stacktrace:
>>>
>>> Mai 20, 2015 6:56:23 PM
>>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl
>>> callAnalysisComponentProcess(417)
>>> GRAVE: Exception occurred
>>> org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator
>>> processing failed.
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:401)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:308)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:269)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:73)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:1)
>>> at
>>>
>> org.cogroo.tools.checker.TypedCheckerComposite.check(TypedCheckerComposite.java:49)
>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:252)
>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:271)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.main(UIMAChecker.java:130)
>>> Caused by: java.lang.NullPointerException
>>> at
>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironment(RutaEngine.java:580)
>>> at
>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironments(RutaEngine.java:575)
>>> at org.apache.uima.ruta.engine.RutaEngine.process(RutaEngine.java:530)
>>> at
>>>
>> org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:385)
>>> ... 8 more
>>>
>>> org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator
>>> processing failed.
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:401)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:308)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:269)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:73)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:1)
>>> at
>>>
>> org.cogroo.tools.checker.TypedCheckerComposite.check(TypedCheckerComposite.java:49)
>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:252)
>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:271)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.main(UIMAChecker.java:130)
>>> Caused by: java.lang.NullPointerException
>>> at
>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironment(RutaEngine.java:580)
>>> at
>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironments(RutaEngine.java:575)
>>> at org.apache.uima.ruta.engine.RutaEngine.process(RutaEngine.java:530)
>>> at
>>>
>> org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:385)
>>> ... 8 more
>>> Mai 20, 2015 6:56:23 PM
>>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl
>>> callAnalysisComponentProcess(417)
>>> GRAVE: Exception occurred
>>> org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator
>>> processing failed.
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:401)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:308)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:269)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:73)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:1)
>>> at
>>>
>> org.cogroo.tools.checker.TypedCheckerComposite.check(TypedCheckerComposite.java:49)
>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:252)
>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:271)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.main(UIMAChecker.java:130)
>>> Caused by: java.lang.NullPointerException
>>> at
>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironment(RutaEngine.java:580)
>>> at
>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironments(RutaEngine.java:575)
>>> at org.apache.uima.ruta.engine.RutaEngine.process(RutaEngine.java:530)
>>> at
>>>
>> org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:385)
>>> ... 8 more
>>>
>>> org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator
>>> processing failed.
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:401)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:308)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:269)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:73)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:1)
>>> at
>>>
>> org.cogroo.tools.checker.TypedCheckerComposite.check(TypedCheckerComposite.java:49)
>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:252)
>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:271)
>>> at
>> org.cogroo.tools.checker.checkers.UIMAChecker.main(UIMAChecker.java:130)
>>> Caused by: java.lang.NullPointerException
>>> at
>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironment(RutaEngine.java:580)
>>> at
>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironments(RutaEngine.java:575)
>>> at org.apache.uima.ruta.engine.RutaEngine.process(RutaEngine.java:530)
>>> at
>>>
>> org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
>>> at
>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:385)
>>> ... 8 more
>>>
>>>
>>>
>>> 2015-05-20 17:46 GMT-03:00 Peter Klügl <pkluegl@uni-wuerzburg.de>:
>>>
>>>> Hi,
>>>>
>>>> I assume that you use UIMA Ruta 2.2.1?
>>>>
>>>> Are there any prior exception?
>>>>
>>>> I had a similar problem, which should be fixed now. Could be related to
>>>> the bugs reported in UIMA-4045 or UIMA-4046.
>>>> Normally, I would assume that there is a syntax error in the additional
>>>> script causing the module to be null. If the script file is not found,
>> then
>>>> there should be a clear error message.
>>>>
>>>> Could you try the UIMA Ruta 2.3.0 RC2, but upgrading the dependency
>>>> version of uima-core to 2.3.0 and using the staging repository?
>>>>
>>>> <repositories>
>>>>         <repository>
>>>>           <id>staged-release</id>
>>>> <url>
>>>> https://repository.apache.org/content/repositories/orgapacheuima-1053/
>>>> </url>
>>>>         </repository>
>>>>       </repositories>
>>>>
>>>> Best,
>>>>
>>>> Peter
>>>>
>>>>
>>>> Am 20.05.2015 um 21:45 schrieb William Colen:
>>>>
>>>>> Hello,
>>>>>
>>>>> We have a Main RUTA script that imports a few children scripts, as
>>>>> follows:
>>>>>
>>>>> PACKAGE cogroo.ruta;
>>>>>
>>>>>> TYPESYSTEM BaseTypeSystem;
>>>>>> IMPORT opennlp.uima.Token FROM TypeSystem AS cgToken;
>>>>>> IMPORT opennlp.uima.Sentence FROM TypeSystem AS cgSentence;
>>>>>> SCRIPT Crase;
>>>>>> SCRIPT Base;
>>>>>> Document{-> CALL(Base)};
>>>>>> Document{-> CALL(Crase)};
>>>>>>
>>>>> All the scripts are in the root of the classpath.
>>>>>
>>>>> We are trying to call it from Java, using the following code:
>>>>>
>>>>> TypeSystemDescription tsd =
>>>>>
>> TypeSystemDescriptionFactory.createTypeSystemDescription("MainTypeSystem"
>>>>>> );
>>>>>> URL url = Resources.getResource("Main.ruta");
>>>>>> String scriptText = Resources.toString(url, Charsets.UTF_8);
>>>>>> AnalysisEngineDescription aeDes =
>>>>>> Ruta.createAnalysisEngineDescription(scriptText, tsd);
>>>>>> AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeDes);
>>>>>>
>>>>>   The error we are getting:
>>>>>
>>>>> org.apache.uima.analysis_engine.AnalysisEngineProcessException:
>> Annotator
>>>>>> processing failed.
>>>>>> at
>>>>>>
>>>>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:401)
>>>>>> at
>>>>>>
>>>>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:309)
>>>>>> at
>>>>>>
>>>>>>
>> org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:267)
>>>>>> at
>>>>>>
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:74)
>>>>>> at
>>>>>>
>> org.cogroo.tools.checker.checkers.UIMAChecker.check(UIMAChecker.java:1)
>>>>>> at
>>>>>>
>>>>>>
>> org.cogroo.tools.checker.TypedCheckerComposite.check(TypedCheckerComposite.java:49)
>>>>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:252)
>>>>>> at org.cogroo.checker.GrammarChecker.analyze(GrammarChecker.java:271)
>>>>>> at
>>>>>>
>> org.cogroo.tools.checker.checkers.UIMAChecker.main(UIMAChecker.java:131)
>>>>>> Caused by: java.lang.NullPointerException
>>>>>> at
>>>>>>
>>>>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironment(RutaEngine.java:529)
>>>>>> at
>>>>>>
>>>>>>
>> org.apache.uima.ruta.engine.RutaEngine.resetEnvironments(RutaEngine.java:524)
>>>>>> at org.apache.uima.ruta.engine.RutaEngine.process(RutaEngine.java:480)
>>>>>> at
>>>>>>
>>>>>>
>> org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
>>>>>> at
>>>>>>
>>>>>>
>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:385)
>>>>>> ... 8 more
>>>>>>
>>>>> We have a feeling that RUTA can't find the child script files, and that
>>>>> causes the error. Are we missing something?
>>>>>
>>>>>
>>>>> Thank you,
>>>>> William
>>>>>
>>>>>
>>


Mime
View raw message