use of com.joliciel.jochre.boundaries.JochreSplitEventStream in project jochre by urieli.
the class Jochre method doCommandTrainSplits.
/**
* Train the letter splitting model.
*
* @param featureDescriptors
* the feature descriptors for training this model
* @param criteria
* the criteria used to select the training corpus
*/
public void doCommandTrainSplits(List<String> featureDescriptors, CorpusSelectionCriteria criteria) {
if (jochreSession.getSplitModelPath() == null)
throw new RuntimeException("Missing argument: splitModel");
if (featureDescriptors == null)
throw new JochreException("features is required");
File splitModelFile = new File(jochreSession.getSplitModelPath());
splitModelFile.getParentFile().mkdirs();
SplitFeatureParser splitFeatureParser = new SplitFeatureParser();
Set<SplitFeature<?>> splitFeatures = splitFeatureParser.getSplitFeatureSet(featureDescriptors);
ClassificationEventStream corpusEventStream = new JochreSplitEventStream(criteria, splitFeatures, jochreSession);
ModelTrainerFactory modelTrainerFactory = new ModelTrainerFactory();
ClassificationModelTrainer trainer = modelTrainerFactory.constructTrainer(jochreSession.getConfig());
ClassificationModel splitModel = trainer.trainModel(corpusEventStream, featureDescriptors);
splitModel.persist(splitModelFile);
}
Aggregations