Im creating an annotator called "NewAnnotator" and try to make it works in a pipeline with others annotators in ClearTK like: SentenceAnnotator, PosTaggerAnnotator, etc. So I want to be able to run pipeline:

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());

I wrote the code with no error, but when running it returns a lot of errors, which I think from this part in my NewAnnotator code:

  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");

I almost copy this part from PosTaggerAnnotator, but it has no use in my NewAnnotator, I just add in so that I can use:

aggregate.add(NewAnnotator.getDescription());   

because I don't know any other way to add to aggregate without .getDescription(); and I also don't know how to declare a correct getDescription() in my annotator, even it can works fine without it. So please give me some advise here if you have experienced it! Thank you!

有帮助吗?

解决方案

getDescription() is a convenience method to create a default description for your annotator. It uses AnalysisEngineFactory.createPrimitiveDescription(), to which you need to provide the right arguments, like this:

  public static AnalysisEngineDescription getDescription() throws ResourceInitializationException {
    return AnalysisEngineFactory.createPrimitiveDescription(
          NewAnnotator.class,
          first_parameter_name,  first_parameter_value, 
          second_parameter_name, second_parameter_value,
          ... ); 
  }

There are more examples in the uimaFIT codebase.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top