}
public static final TrainingParameters loadTrainingParams(String inFileValue,
boolean isSequenceTrainingAllowed) throws ResourceInitializationException {
TrainingParameters params;
if (inFileValue != null) {
InputStream paramsIn = null;
try {
paramsIn = new FileInputStream(new File(inFileValue));
params = new opennlp.tools.util.TrainingParameters(paramsIn);
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
finally {
try {
if (paramsIn != null)
paramsIn.close();
} catch (IOException e) {
}
}
if (!TrainerFactory.isValid(params.getSettings())) {
throw new ResourceInitializationException(new Exception("Training parameters file is invalid!"));
}
if (!isSequenceTrainingAllowed && TrainerFactory.isSequenceTraining(params.getSettings())) {
throw new ResourceInitializationException(new Exception("Sequence training is not supported!"));
}
}
else {
params = TrainingParameters.defaultParams();