0

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!

rec
  • 10,340
  • 3
  • 29
  • 43
user1314404
  • 1,253
  • 3
  • 22
  • 51

1 Answers1

0

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.

rec
  • 10,340
  • 3
  • 29
  • 43
Renaud
  • 16,073
  • 6
  • 81
  • 79
  • So is it possible not to declare getDescription() ? but still can add my annotator to the end of the above pipeline (after POSTaggerAnnotator)? I saw your link, most of them don't have getDescription() function. And for mine, no argument to provide. In my process() function, at the end, I will setPos() to get set the process result there, and can get the result of that process by getPos(), similar as POSTaggerAnnotator. – user1314404 Jun 05 '13 at 02:44
  • I tried this: ` public static AnalysisEngineDescription createDescriptor() throws ResourceInitializationException { TypeSystemDescription typeSystemDescription = TypeSystemDescriptionFactory .createTypeSystemDescription(); return AnalysisEngineFactory.createPrimitiveDescription(NewAnnotator.class,typeSystemDescription);} ` then in the pipeline I add by : ` aggregate.add(NewAnnotator.createDescriptor()); ` but looks like it still the wrong way. Still got lots of errors. – user1314404 Jun 05 '13 at 04:21
  • yes, it is possible not to declare getDescription(), it's just a convenience method to create this annotator's description – Renaud Jun 05 '13 at 07:37
  • @user1314404 can you paste the errors somewhere (e.g. gist)? Or even better: put the relevant parts of your code on github. Maybe you are missing some required parameters. – Renaud Jun 05 '13 at 07:38
  • Sure I will do it. I just download github on mac for your request. Im new user of it, not sure how to copy the error/code to that ? Googling.. – user1314404 Jun 05 '13 at 07:47
  • Sorry, I still finding way to use it. To save time, I also upload it all here: http://www.mediafire.com/folder/04wpfamyd7mvh/errorncode – user1314404 Jun 05 '13 at 09:35
  • It seems you are setting the jCas's text twice, could that be? – Renaud Jun 05 '13 at 21:02
  • You mean where is it ? If the Annotator alone, I can call it and run from another test file. It only get problem when I add to the pipeline, behind the POSTagger, ' aggregate.add(FeatureExtractionAnnotator.createDescriptor()); ' – user1314404 Jun 06 '13 at 06:37