CleartkMultiAnnotator extends JCasAnnotator_ImplBase implements
    Initializable { @Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); if (this.dataWriterFactoryClassName == null && this.classifierFactoryClassName == null) { CleartkInitializationException.neitherParameterSet( PARAM_DATA_WRITER_FACTORY_CLASS_NAME, this.dataWriterFactoryClassName, PARAM_CLASSIFIER_FACTORY_CLASS_NAME, this.classifierFactoryClassName); } if (this.isTraining != null) { this.primitiveIsTraining = this.isTraining; } else if (!DEFAULT_DATA_WRITER_FACTORY_CLASS_NAME.equals(this.dataWriterFactoryClassName)) { this.primitiveIsTraining = true; } else if (context.getConfigParameterValue(DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY) != null) { this.primitiveIsTraining = true; } else if (!DEFAULT_CLASSIFIER_FACTORY_CLASS_NAME.equals(this.classifierFactoryClassName)) { this.primitiveIsTraining = false; } else if (context.getConfigParameterValue(GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH) != null) { this.primitiveIsTraining = false; } else { String message = "Please specify PARAM_IS_TRAINING - unable to infer it from context"; throw new IllegalArgumentException(message); } this.uimaContext = context; UimaContextAdmin contextAdmin = (UimaContextAdmin) this.uimaContext; ConfigurationManager manager = contextAdmin.getConfigurationManager(); if (this.isTraining()) { this.dataWriters = new HashMap<String, DataWriter<OUTCOME_TYPE>>(); this.outputDirectoryRoot = (File) manager.getConfigParameterValue(DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY); this.dataWriterFactory = InitializableFactory.create( context, dataWriterFactoryClassName, DataWriterFactory.class); } else { this.classifiers = new HashMap<String, Classifier<OUTCOME_TYPE>>(); this.classifierJarPathRoot = (File) manager.getConfigParameterValue(GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH); this.classifierFactory = InitializableFactory.create( context, classifierFactoryClassName, ClassifierFactory.class); } }  @Override void initialize(UimaContext context); @Override void collectionProcessComplete(); static final String PARAM_CLASSIFIER_FACTORY_CLASS_NAME; static final String PARAM_DATA_WRITER_FACTORY_CLASS_NAME; static final String PARAM_IS_TRAINING; }
@Test public void testChildClassifierParentAnnotator() throws Exception { CleartkMultiAnnotator<Parent> multiClassifierAnnotator = new ParentTestAnnotator(); multiClassifierAnnotator.initialize(UimaContextFactory.createUimaContext( CleartkMultiAnnotator.PARAM_CLASSIFIER_FACTORY_CLASS_NAME, ChildClassifierFactory.class.getName())); }
@Test public void testGenericClassifierGenericAnnotator() throws Exception { CleartkMultiAnnotator<Object> classifierAnnotator = new TestMultiAnnotator<Object>(); classifierAnnotator.initialize(UimaContextFactory.createUimaContext( CleartkMultiAnnotator.PARAM_CLASSIFIER_FACTORY_CLASS_NAME, TestClassifierFactory.class.getName())); }