multilingual-ctap-feature/src/main/java/com/ctapweb/feature/annotator/SentenceAnnotator.java
@Override
	public void initialize(UimaContext aContext) throws ResourceInitializationException {
		logger.trace(LogMarker.UIMA_MARKER, new InitializingAEMessage(aeType, aeName));

		super.initialize(aContext);
		String modelFilePath = null;

		// define the model to be loaded based on the mandatory LanguageCode config parameter
		String lCode = "";
		if(aContext.getConfigParameterValue(PARAM_LANGUAGE_CODE) == null) {
			ResourceInitializationException e = new ResourceInitializationException("mandatory_value_missing", 
					new Object[] {PARAM_LANGUAGE_CODE});
			logger.throwing(e);
			throw e;
		} else {
			lCode = ((String) aContext.getConfigParameterValue(PARAM_LANGUAGE_CODE)).toUpperCase();
		}

		// gets the model resource, which is declared in the annotator xml
		String languageSpecificResourceKey = RESOURCE_KEY+lCode;
		try {
			modelFilePath = getContext().getResourceFilePath(languageSpecificResourceKey);

			// Stanza models are currently being hosted by the web service
			if (modelFilePath != null) {
				logger.trace(LogMarker.UIMA_MARKER,
						new LoadLangModelMessage(languageSpecificResourceKey, modelFilePath));
			}

			switch (lCode) {
				case SupportedLanguages.PORTUGUESE:
					segmenter = new StanzaSentenceSegmenter();
					break;
				case SupportedLanguages.GERMAN:
				case SupportedLanguages.DUTCH:
				case SupportedLanguages.ENGLISH:
					segmenter = new OpenNLPSentenceSegmenter(modelFilePath);
					break;
			}
		} catch (ResourceAccessException e) {
			logger.throwing(e);
			throw new ResourceInitializationException("could_not_access_data",
					new Object[] {modelFilePath}, e);
		} catch (InvalidFormatException e) {
			logger.throwing(e);
			throw new ResourceInitializationException(CTAPException.EXCEPTION_DIGEST, 
					"incorrect_lang_model_format",
					new Object[] {modelFilePath}, e);
		} catch (IOException e) {
			logger.throwing(e);
			throw new ResourceInitializationException(CTAPException.EXCEPTION_DIGEST, 
					"file_io_error",
					new Object[] {modelFilePath}, e);
		} 

		logger.trace(LogMarker.UIMA_MARKER, new InitializeAECompleteMessage(aeType, aeName));
	}
/**
	 * Loads the appropriate sentence detector model.
	 */
Loads the appropriate sentence detector model.
Loads the appropriate sentence detector model .
@Override
	public void initialize(UimaContext aContext) throws ResourceInitializationException {
		logger.trace(LogMarker.UIMA_MARKER, new InitializingAEMessage(aeType, aeName));
		super.initialize(aContext);
		String modelFilePath = null;
		String lCode = "";
		if(aContext.getConfigParameterValue(PARAM_LANGUAGE_CODE) == null) {
			ResourceInitializationException e = new ResourceInitializationException("mandatory_value_missing", 
					new Object[] {PARAM_LANGUAGE_CODE});
			logger.throwing(e);
			throw e;
		} else {
			lCode = ((String) aContext.getConfigParameterValue(PARAM_LANGUAGE_CODE)).toUpperCase();
		}
		String languageSpecificResourceKey = RESOURCE_KEY+lCode;
		try {
			modelFilePath = getContext().getResourceFilePath(languageSpecificResourceKey);
			if (modelFilePath != null) {
				logger.trace(LogMarker.UIMA_MARKER,
						new LoadLangModelMessage(languageSpecificResourceKey, modelFilePath));
			}
			switch (lCode) {
				case SupportedLanguages.PORTUGUESE:
					segmenter = new StanzaSentenceSegmenter();
					break;
				case SupportedLanguages.GERMAN:
				case SupportedLanguages.DUTCH:
				case SupportedLanguages.ENGLISH:
					segmenter = new OpenNLPSentenceSegmenter(modelFilePath);
					break;
			}
		} catch (ResourceAccessException e) {
			logger.throwing(e);
			throw new ResourceInitializationException("could_not_access_data",
					new Object[] {modelFilePath}, e);
		} catch (InvalidFormatException e) {
			logger.throwing(e);
			throw new ResourceInitializationException(CTAPException.EXCEPTION_DIGEST, 
					"incorrect_lang_model_format",
					new Object[] {modelFilePath}, e);
		} catch (IOException e) {
			logger.throwing(e);
			throw new ResourceInitializationException(CTAPException.EXCEPTION_DIGEST, 
					"file_io_error",
					new Object[] {modelFilePath}, e);
		} 
		logger.trace(LogMarker.UIMA_MARKER, new InitializeAECompleteMessage(aeType, aeName));
	}
@ Override public void initialize ( UimaContext aContext ) throws ResourceInitializationException { logger . trace ( LogMarker . UIMA_MARKER , new InitializingAEMessage ( aeType , aeName ) ) ; super . initialize ( aContext ) ; String modelFilePath = null ; String lCode = "" ; if ( aContext . getConfigParameterValue ( PARAM_LANGUAGE_CODE ) == null ) { ResourceInitializationException e = new ResourceInitializationException ( "mandatory_value_missing" , new Object [ ] { PARAM_LANGUAGE_CODE } ) ; logger . throwing ( e ) ; throw e ; } else { lCode = ( ( String ) aContext . getConfigParameterValue ( PARAM_LANGUAGE_CODE ) ) . toUpperCase ( ) ; } String languageSpecificResourceKey = RESOURCE_KEY + lCode ; try { modelFilePath = getContext ( ) . getResourceFilePath ( languageSpecificResourceKey ) ; if ( modelFilePath != null ) { logger . trace ( LogMarker . UIMA_MARKER , new LoadLangModelMessage ( languageSpecificResourceKey , modelFilePath ) ) ; } switch ( lCode ) { case SupportedLanguages . PORTUGUESE : segmenter = new StanzaSentenceSegmenter ( ) ; break ; case SupportedLanguages . GERMAN : case SupportedLanguages . DUTCH : case SupportedLanguages . ENGLISH : segmenter = new OpenNLPSentenceSegmenter ( modelFilePath ) ; break ; } } catch ( ResourceAccessException e ) { logger . throwing ( e ) ; throw new ResourceInitializationException ( "could_not_access_data" , new Object [ ] { modelFilePath } , e ) ; } catch ( InvalidFormatException e ) { logger . throwing ( e ) ; throw new ResourceInitializationException ( CTAPException . EXCEPTION_DIGEST , "incorrect_lang_model_format" , new Object [ ] { modelFilePath } , e ) ; } catch ( IOException e ) { logger . throwing ( e ) ; throw new ResourceInitializationException ( CTAPException . EXCEPTION_DIGEST , "file_io_error" , new Object [ ] { modelFilePath } , e ) ; } logger . trace ( LogMarker . UIMA_MARKER , new InitializeAECompleteMessage ( aeType , aeName ) ) ; }
Loads the appropriate sentence detector model.
Loads the appropriate sentence detector model .
// define the model to be loaded based on the mandatory LanguageCode config parameter // gets the model resource, which is declared in the annotator xml // Stanza models are currently being hosted by the web service