我正在创建一个名为“NewAnnotator”的注释器,并尝试使其在管道中与ClearTK中的其他注释器一起工作,如: SentenceAnnotator,PosTaggerAnnotator等等所以我希望能够运行管道:
aggregate.add(SentenceAnnotator.getDescription());
aggregate.add(PosTaggerAnnotator.getDescription());
aggregate.add(NewAnnotator.getDescription());
// run the classification pipeline on the new texts
SimplePipeline.runPipeline(reader, aggregate.createAggregateDescription());
我编写的代码没有错误,但是在运行时会返回很多错误,我想从NewAnnotator代码的这一部分开始:
public static AnalysisEngineDescription getDescription() throws ResourceInitializationException {
return AnalysisEngineFactory.createPrimitiveDescription(
NewAnnotator.class,
PARAM_POSTAG_MODEL_FILE,
ParamUtil.getParameterValue(PARAM_POSTAG_MODEL_FILE, "/somepath"));
}
public static final String PARAM_POSTAG_MODEL_FILE = ConfigurationParameterFactory.createConfigurationParameterName(
PosTaggerAnnotator.class,
"postagModelFile");
我几乎从PosTaggerAnnotator复制这部分,但它在我的NewAnnotator中没用,我只是加入以便我可以使用:
aggregate.add(NewAnnotator.getDescription());
因为我不知道在没有.getDescription();
的情况下添加到聚合的任何其他方式,我也不知道如何在我的注释器中声明一个正确的getDescription()
,即使没有它也能正常工作。
如果您有经验,请在这里给我一些建议!谢谢!
答案 0 :(得分:0)
getDescription()
是一种为注释器创建默认描述的便捷方法。它使用AnalysisEngineFactory.createPrimitiveDescription()
,您需要提供正确的参数,如下所示:
public static AnalysisEngineDescription getDescription() throws ResourceInitializationException {
return AnalysisEngineFactory.createPrimitiveDescription(
NewAnnotator.class,
first_parameter_name, first_parameter_value,
second_parameter_name, second_parameter_value,
... );
}
uimaFIT codebase中有更多示例。