public static SentenceModel train(String languageCode, ObjectStream<SentenceSample> samples,
boolean useTokenEnd, Dictionary abbreviations, TrainingParameters mlParams) throws IOException {
Map<String, String> manifestInfoEntries = new HashMap<String, String>();
Factory factory = new Factory();
// TODO: Fix the EventStream to throw exceptions when training goes wrong
EventStream eventStream = new SDEventStream(samples,
factory.createSentenceContextGenerator(languageCode, getAbbreviations(abbreviations)),
factory.createEndOfSentenceScanner(languageCode));
AbstractModel sentModel = TrainUtil.train(eventStream, mlParams.getSettings(), manifestInfoEntries);
return new SentenceModel(languageCode, sentModel,
useTokenEnd, abbreviations, manifestInfoEntries);