public static Dictionary createOptionalDictionary(UimaContext context, String parameter)
throws ResourceInitializationException {
String dictionaryName = CasConsumerUtil.getOptionalStringParameter(
context, parameter);
Dictionary dictionary = null;
if (dictionaryName != null) {
Logger logger = context.getLogger();
try {
InputStream dictIn = CasConsumerUtil.getOptionalResourceAsStream(context,
dictionaryName);
if (dictIn == null) {
String message = "The dictionary file " + dictionaryName +
" does not exist!";
if (logger.isLoggable(Level.WARNING)) {
logger.log(Level.WARNING, message);
}
return null;
}
dictionary = new Dictionary(dictIn);
} catch (IOException e) {
// if this fails just print error message and continue
String message = "IOException during dictionary reading, "
+ "running without dictionary: " + e.getMessage();