mlParams = CmdLineUtil.loadTrainingParameters(params.getParams(), false);
if (mlParams != null) {
if (!TrainerType.EVENT_MODEL_TRAINER.equals(TrainerFactory.getTrainerType(mlParams.getSettings()))) {
throw new TerminateToolException(1, "Sequence training is not supported!");
}
}
if(mlParams == null) {
mlParams = ModelUtil.createDefaultTrainingParameters();
}
File modelOutFile = params.getModel();
CmdLineUtil.checkOutputFile("sentence detector model", modelOutFile);
char[] eos = null;
if (params.getEosChars() != null) {
String eosString = SentenceSampleStream.replaceNewLineEscapeTags(
params.getEosChars());
eos = eosString.toCharArray();
}
SentenceModel model;
try {
Dictionary dict = loadDict(params.getAbbDict());
SentenceDetectorFactory sdFactory = SentenceDetectorFactory.create(
params.getFactory(), params.getLang(), true, dict, eos);
model = SentenceDetectorME.train(params.getLang(), sampleStream,
sdFactory, mlParams);
} catch (IOException e) {
throw new TerminateToolException(-1, "IO error while reading training data or indexing data: "
+ e.getMessage(), e);
}
finally {
try {
sampleStream.close();