如何从Maven项目运行外部ruta脚本而不将脚本或其类型系统放在类路径中? [英] How to run external ruta scripts from a maven project without placing the script or its typesystem in the classpath?
问题描述
到目前为止,我一直在通过创建AnalysisEngine和CAS并处理引擎来从maven项目运行ruta脚本.为此,我将所有脚本和描述符文件(Engine& TypeSystem)放入了maven项目的scr/main/resources文件夹中.
Till now, I had been running ruta scripts from a maven project by creating AnalysisEngine and CAS, and processing the engine. To do this, I had placed all the scripts and descriptor files (Engine & TypeSystem) into scr/main/resources folder of the maven project.
现在,我想将脚本和TypeSystem文件放置在外部路径中,并将该路径动态传递给运行脚本的Java代码.有可能做到吗?如果是这样,怎么办?
Now I want to place the scripts and TypeSystem files in an external path and pass the path dynamically to my java code that runs the scripts. Is it possible to do it ? If so, how ?
我只是将文件(脚本和描述符)放在外部路径中,并通过新路径来实例化AnalysisEngine,如下所示;
I simply placed the files(script & descriptor) in an external path and passed the new path to instantiate the AnalysisEngine as below;
final AnalysisEngine engine = AnalysisEngineFactory.createEngine("home/admin/Desktop/TEST_ScriptFolder/com/textjuicer/ruta/date/Dazzle_ChapRef_UpdatedEngine");
错误
org.apache.uima.util.InvalidXMLException:无法解析导入.在类路径或数据路径中找不到名称为"home/admin/Desktop/TEST_ScriptFolder/com/textjuicer/ruta/date/Dazzle_ChapRef_UpdatedEngine.xml"的文件. (描述符:) 在org.apache.uima.resource.metadata.impl.Import_impl.findAbsoluteUrl(Import_impl.java:117) 在org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription(AnalysisEngineFactory.java:869)处 在org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine(AnalysisEngineFactory.java:107) 在com.textjuicer.ruta.date.ArtifactAnnotator.getAllAnnotations(ArtifactAnnotator.java:93) 在ApplyingStyle.XmiTransformer.parseXMI(XmiTransformer.java:33) 在ApplyingStyle.ApplyStyle.applyStyleOnDocx(ApplyStyle.java:76)
org.apache.uima.util.InvalidXMLException: An import could not be resolved. No file with name "home/admin/Desktop/TEST_ScriptFolder/com/textjuicer/ruta/date/Dazzle_ChapRef_UpdatedEngine.xml" was found in the class path or data path. (Descriptor: ) at org.apache.uima.resource.metadata.impl.Import_impl.findAbsoluteUrl(Import_impl.java:117) at org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription(AnalysisEngineFactory.java:869) at org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine(AnalysisEngineFactory.java:107) at com.textjuicer.ruta.date.ArtifactAnnotator.getAllAnnotations(ArtifactAnnotator.java:93) at ApplyingStyle.XmiTransformer.parseXMI(XmiTransformer.java:33) at ApplyingStyle.ApplyStyle.applyStyleOnDocx(ApplyStyle.java:76)
推荐答案
有两层:
- RutaEngine需要找到脚本/资源/描述符
- UIMA需要能够解析描述符的导入
Ruta中的资源查找有两个阶段,它在配置参数中指定的绝对路径中搜索它们.如果找不到资源,它将在类路径中搜索它.因此,您需要设置配置参数:脚本位于scriptPaths
中,描述符位于descriptorPaths
中,单词列表位于resourcePaths
中.请参见文档以获取更多信息.
The resource lookup in Ruta has two stages, it searches for them in the absolute paths specified in the configuration parameters. If the resource is not found it searches for it in the classpath. So you need to set the configuration parameters: scripts are located in scriptPaths
, descriptors are located in descriptorPaths
and wordlists are located in resourcePaths
. See the documentation for further information.
可以通过在UIMA ResourceManager中设置数据路径或将导入更改为位置"而不是名称"来解决描述符中的导入问题.数据路径可以用作类路径的替代.如果Ruta描述文件在ruta-maven-plugin中指定了位置,则按位置使用import.
The problems with the imports in descriptors can be solved by either setting the datapath in the UIMA ResourceManager or by changing the import to "location" instead of "name". The datapath can be used as a replacement for the classpath. The Ruta descriptos use import by location if it specified int he ruta-maven-plugin.
免责声明:我是UIMA Ruta的开发人员
这篇关于如何从Maven项目运行外部ruta脚本而不将脚本或其类型系统放在类路径中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!