我正在创建一个名为"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();的情况下添加到aggregate的任何其他方法,我也不知道如何在我的注释器中声明一个正确的getDescription(),即使没有它也可以很好地工作。所以,如果你经历过,请在这里给我一些建议!谢谢!
发布于 2013-06-04 18:39:25
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中有更多的例子。
https://stackoverflow.com/questions/16912330
复制相似问题