从 UIMA-Fit 执行时,带有字符串函数的 UIMA RUTA 脚本不起作用

UIMA RUTA script with stringfunctions doesnt work when executing from UIMA-Fit

我正在尝试从 UIMA fit 管道执行一个简单的示例 Ruta 脚本。

STRING s;
BOOLEAN a;
STRING s2 = "LAuGH";
DECLARE Test;
BLOCK(forEACH) W{}{
    W{->MATCHEDTEXT(s), ASSIGN(a,equals(s,s2))};
    W{->MATCHEDTEXT(s), ASSIGN(a,equalsIgnoreCase(s,s2))};
    W{a ->Test};
}

当使用单独的 RUTA 项目作为独立脚本执行时,此脚本工作正常,并且创建了测试注释。但是,在具有 UIMA 拟合管道的 java 项目中,出现以下错误:

Sep 08, 2016 1:49:14 PM de.tudarmstadt.ukp.dkpro.core.api.io.ResourceCollectionReaderBase scan(393)
INFO: Scanning [file:/home/himanshu_shivhare/workspace/annotate_ruta_example-master/src/main/resources/data/]
Sep 08, 2016 1:49:14 PM de.tudarmstadt.ukp.dkpro.core.api.io.ResourceCollectionReaderBase initialize(224)
INFO: Found [1] resources to be read
Exception in thread "main" org.apache.uima.resource.ResourceInitializationException: Initialization of annotator class "org.apache.uima.ruta.engine.RutaEngine" failed.  (Descriptor: <unknown>)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:271)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:170)
    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:279)
    at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:407)
    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:429)
    at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:373)
    at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:186)
    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:279)
    at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
    at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
    at org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine(AnalysisEngineFactory.java:205)
    at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:82)
    at example.Annotate.main(Annotate.java:49)
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.file_input(RutaParser.java:726)
    at org.apache.uima.ruta.engine.RutaEngine.loadScript(RutaEngine.java:1087)
    at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:756)
    at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:530)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:266)
    ... 17 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.statements(RutaParser.java:825)
    at org.apache.uima.ruta.parser.RutaParser.file_input(RutaParser.java:712)
    ... 21 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.statement(RutaParser.java:1038)
    at org.apache.uima.ruta.parser.RutaParser.statements(RutaParser.java:804)
    ... 22 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.blockDeclaration(RutaParser.java:2940)
    at org.apache.uima.ruta.parser.RutaParser.statement(RutaParser.java:1010)
    ... 23 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.statements(RutaParser.java:825)
    at org.apache.uima.ruta.parser.RutaParser.blockDeclaration(RutaParser.java:2921)
    ... 24 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.statement(RutaParser.java:1038)
    at org.apache.uima.ruta.parser.RutaParser.statements(RutaParser.java:804)
    ... 25 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.simpleStatement(RutaParser.java:3266)
    at org.apache.uima.ruta.parser.RutaParser.statement(RutaParser.java:1000)
    ... 26 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.ruleElementsRoot(RutaParser.java:3796)
    at org.apache.uima.ruta.parser.RutaParser.simpleStatement(RutaParser.java:3250)
    ... 27 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.ruleElement(RutaParser.java:4156)
    at org.apache.uima.ruta.parser.RutaParser.ruleElementsRoot(RutaParser.java:3739)
    ... 28 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.ruleElementType(RutaParser.java:4722)
    at org.apache.uima.ruta.parser.RutaParser.ruleElement(RutaParser.java:3994)
    ... 29 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.actions(RutaParser.java:5106)
    at org.apache.uima.ruta.parser.RutaParser.ruleElementType(RutaParser.java:4688)
    ... 30 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.action(RutaParser.java:11623)
    at org.apache.uima.ruta.parser.RutaParser.actions(RutaParser.java:5085)
    ... 31 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:393)
    at org.apache.uima.ruta.parser.RutaParser.actionAssign(RutaParser.java:14714)
    at org.apache.uima.ruta.parser.RutaParser.action(RutaParser.java:11305)
    ... 32 more
Caused by: org.apache.uima.ruta.extensions.RutaParseRuntimeException: Error in Example,  line 28, "(": found no viable alternative
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:358)
    at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:372)
    at org.apache.uima.ruta.parser.RutaParser.booleanExpression(RutaParser.java:19535)
    at org.apache.uima.ruta.parser.RutaParser.actionAssign(RutaParser.java:14631)
    ... 33 more

脚本解析失败,奇怪。我正在使用来自 maven repo (2.4.0) 的最新版本的 ruta-core。有谁知道为什么会这样?谢谢

当使用uimaFIT手动创建分析引擎时,没有使用预配置的描述符,而只是实现RutaEngine.class,您需要自己配置参数additionalExtension。此参数列出语言扩展工厂。

改变你的 java 行
 ... = AnalysisEngineFactory.createEngine(RutaEngine.class);

 ... = AnalysisEngineFactory.createEngine(RutaEngine.class, RutaEngine.PARAM_ADDITIONAL_EXTENSIONS, new String[]{BooleanOperationsExtension.class.getName(), StringOperationsExtension.class.getName()});

应该可以解决问题。

免责声明:我是 UIMA Ruta 的开发者