UIMA Ruta:无法找到 JCas initialized/Script

UIMA Ruta: JCas cannot be initialized/Script cannot be found

我尝试将 UIMA Ruta 脚本 (Main.ruta) 集成到 uimaFIT 管道 (inMain.java) 中,但找不到该脚本。 这是我的项目结构:

uima-ruta-maven-test-project/src/main/Main.java
uima-ruta-maven-test-project/script/ruta/Main.ruta
uima-ruta-maven-test-project/descriptor/ruta/MainEngine.xml

这是我创建 AnalysisEngineDescription:

的代码
File file = new File("descriptor/ruta/MainEngine.xml");

AnalysisEngineDescription rutaScript = AnalysisEngineFactory.createEngineDescriptionFromPath(
                    file.getPath(),
                    RutaEngine.PARAM_SCRIPT_PATHS, "script",
                    RutaEngine.PARAM_MAIN_SCRIPT, "Main.ruta");

这是我的控制台输出:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.
org.apache.uima.resource.ResourceInitializationException: Initialization of annotator class "org.apache.uima.ruta.engine.RutaEngine" failed.  (Descriptor: file:/D:/Programming/MA/uima-ruta-maven-test-project/descriptor/ruta/MainEngine.xml)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:260)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:173)
    at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
    at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
    at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:289)
    at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:417)
    at org.apache.uima.analysis_engine.asb.impl.ASB_impl.setup(ASB_impl.java:256)
    at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initASB(AggregateAnalysisEngine_impl.java:435)
    at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:379)
    at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:192)
    at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
    at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
    at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:289)
    at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:341)
    at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:458)
    at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:178)
    at Main.main(Main.java:52)
Caused by: org.apache.uima.resource.ResourceInitializationException
    at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:579)
    at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.lambda$callInitializeMethod(AnalysisEngineImplBase.java:612)
    at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.withContexts(AnalysisEngineImplBase.java:653)
    at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.callInitializeMethod(AnalysisEngineImplBase.java:612)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:252)
    ... 16 more
Caused by: org.apache.uima.analysis_engine.AnalysisEngineProcessException
    at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:857)
    at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:576)
    ... 20 more
Caused by: java.io.FileNotFoundException: Script [Main.ruta] cannot be found at [script;D:\Programming\MA\uima-ruta-maven-test-project] or classpath with extension .ruta
    ... 22 more

我的控制台输出的最后一行似乎显示了错误。 Main.ruta 在路径 [script;D:\Programming\MA\uima-ruta-maven-test-project] 中搜索,显然不存在,因为它是无效路径。我在想的是 createEngineDescriptionFromPath 方法应该将 "script" 文件夹附加到项目路径。但相反,它在前面。

有人可以帮我解决这个问题吗?

编辑

我在文档中找到 this link,其中解释了参数 mainScriptscriptPaths 的用法。路径必须用“.”书写。而不是“/”。

我修改了我的代码如下:

AnalysisEngineDescription rutaScript = AnalysisEngineFactory.createEngineDescriptionFromPath(
                    file.getPath(),
                    RutaEngine.PARAM_SCRIPT_PATHS, "script.ruta",
                    RutaEngine.PARAM_MAIN_SCRIPT, "script.ruta.Main");

但现在我得到这个控制台输出:

Exception in thread "main" org.apache.uima.cas.CASRuntimeException: The JCas cannot be initialized.  The following errors occurred: 
JCas Class "org.apache.uima.ruta.type.AnyLine", loaded from "jar:file:/C:/Users/user/.m2/repository/org/apache/uima/ruta-typesystem/2.7.0/ruta-typesystem-2.7.0.jar!/org/apache/uima/ruta/type/AnyLine.class", is missing required constructor; likely cause is wrong version (UIMA version 3 or later JCas required).
JCas Class "org.apache.uima.ruta.type.EmptyLine", loaded from "jar:file:/C:/Users/user/.m2/repository/org/apache/uima/ruta-typesystem/2.7.0/ruta-typesystem-2.7.0.jar!/org/apache/uima/ruta/type/EmptyLine.class", is missing required constructor; likely cause is wrong version (UIMA version 3 or later JCas required).
JCas Class "org.apache.uima.ruta.type.WSLine", loaded from "jar:file:/C:/Users/user/.m2/repository/org/apache/uima/ruta-typesystem/2.7.0/ruta-typesystem-2.7.0.jar!/org/apache/uima/ruta/type/WSLine.class", is missing required constructor; likely cause is wrong version (UIMA version 3 or later JCas required).
...
at org.apache.uima.cas.impl.FSClassRegistry.reportErrors(FSClassRegistry.java:1284)
at org.apache.uima.cas.impl.FSClassRegistry.loadJCasForTSandClassLoader(FSClassRegistry.java:400)
at org.apache.uima.cas.impl.FSClassRegistry.getGeneratorsForClassLoader(FSClassRegistry.java:1320)
at org.apache.uima.cas.impl.TypeSystemImpl.getGeneratorsForClassLoader(TypeSystemImpl.java:2924)
at org.apache.uima.cas.impl.TypeSystemImpl.commit(TypeSystemImpl.java:1442)
at org.apache.uima.cas.impl.CASImpl.commitTypeSystem(CASImpl.java:1822)
at org.apache.uima.util.CasCreationUtils.doCreateCas(CasCreationUtils.java:620)
at org.apache.uima.util.CasCreationUtils.createCas(CasCreationUtils.java:292)
at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:181)
at Main.main(Main.java:52)

Ruta 类型似乎无法初始化。我的 pom.xml.

中有 UIMA Ruta 版本 2.7.0 和 DKPro 2.0.0

似乎 UIMA Ruta 2 与 UIMA v3 和其他依赖它的库(在本例中为 uimaFit、DKPro)不能很好地结合在一起。

我在我的案例中使用了以下版本:DKPro 1.11.0、UIMA 2.10.4、UIMA Ruta 2.7.0 和 uimaFit 2.4.0(另请参阅 )。

UIMA Ruta 3 最近发布。我想这个版本会更好地与 UIMA v3 一起工作。