gpt4 book ai didi

java - HeidelTime:语言参数被指定为 NULL

转载 作者:行者123 更新时间:2023-12-01 21:23:49 24 4
gpt4 key购买 nike

我正在尝试将 HeidelTime 纳入我的 uimaFIT-Pipeline 中。

这是我的管道:

AggregateBuilder builder = new AggregateBuilder();

CollectionReaderDescription reader = createReaderDescription(TextReader.class,
TextReader.PARAM_SOURCE_LOCATION, dateTimePath, TextReader.PARAM_LANGUAGE, "en",
TextReader.PARAM_PATTERNS, "*.txt");

AnalysisEngineDescription treeTagger = createEngineDescription(TreeTaggerWrapper.class,
TreeTaggerWrapper.PARAM_LANGUAGE, "english",
TreeTaggerWrapper.PARAM_ANNOTATE_PARTOFSPEECH, true,
TreeTaggerWrapper.PARAM_ANNOTATE_SENTENCES, true,
TreeTaggerWrapper.PARAM_ANNOTATE_TOKENS, true);
builder.add(treeTagger);

AnalysisEngineDescription heidelTime = createEngineDescription(HeidelTime.class);
builder.add(heidelTime);

AnalysisEngineDescription intervalTagger = createEngineDescription(IntervalTagger.class);
builder.add(intervalTagger);

AnalysisEngineDescription xmiWriter = createEngineDescription(XmiWriter.class,
XmiWriter.PARAM_TARGET_LOCATION, outputPath,
XmiWriter.PARAM_OVERWRITE, true);
builder.add(xmiWriter);

SimplePipeline.runPipeline(reader, builder.createAggregateDescription());

但是执行时出现以下异常:

Language parameter was specified as NULL.
org.apache.uima.resource.ResourceInitializationException: Initialization of annotator class "de.unihd.dbs.uima.annotator.heideltime.HeidelTime" failed. (Descriptor: <unknown>)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:268)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:175)
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: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: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: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:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:166)
...
Caused by: java.lang.NullPointerException
at de.unihd.dbs.uima.annotator.heideltime.resources.Language.getLanguageFromString(Language.java:65)
at de.unihd.dbs.uima.annotator.heideltime.HeidelTime.initialize(HeidelTime.java:141)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:261)
... 80 more

如何设置管道中的语言和所有其他参数?我还没有找到办法。当我使用独立版本的 HeidelTime 时,我可以在构造函数中指定参数,并且工作正常。

最佳答案

我通过从 GitHub 下载 heideltime-master 并将以下文件夹放入我的/src/main/resources 文件夹中解决了该问题:

desc.annotator
desc.comsumer
desc.reader
desc.type

之后我创建了 AnalysisEngineDescriptions,如下所示:

AnalysisEngineDescription heidelTime = createEngineDescriptionFromPath(
"src/main/resources/desc/annotator/HeidelTime.xml");
builder.add(heidelTime);

AnalysisEngineDescription intervalTagger = createEngineDescriptionFromPath(
"src/main/resources/desc/annotator/IntervalTagger.xml");
builder.add(intervalTagger);

有了这个,我终于让我的管道开始工作,并且我可以在 Ruta Workbench 的 xmi 文件中看到 Timex3 注释。

关于java - HeidelTime:语言参数被指定为 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58841277/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com