Package opennlp.tools.ml
Class TrainerFactory
- java.lang.Object
-
- opennlp.tools.ml.TrainerFactory
-
public class TrainerFactory extends Object
A factory to initializeTrainerinstances depending on a trainer type configured viaTrainingParameters.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTrainerFactory.TrainerType
-
Constructor Summary
Constructors Constructor Description TrainerFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> EventModelSequenceTrainer<T>getEventModelSequenceTrainer(TrainingParameters trainParams, Map<String,String> reportMap)Retrieves anEventModelSequenceTrainerthat fits the given parameters.static EventTrainergetEventTrainer(TrainingParameters trainParams, Map<String,String> reportMap)Retrieves anEventTrainerthat fits the given parameters.static SequenceTrainergetSequenceModelTrainer(TrainingParameters trainParams, Map<String,String> reportMap)Retrieves aSequenceTrainerthat fits the given parameters.static TrainerFactory.TrainerTypegetTrainerType(TrainingParameters trainParams)Determines theTrainerFactory.TrainerTypebased on theAbstractTrainer.ALGORITHM_PARAMvalue.static booleanisValid(TrainingParameters trainParams)
-
-
-
Method Detail
-
getTrainerType
public static TrainerFactory.TrainerType getTrainerType(TrainingParameters trainParams)
Determines theTrainerFactory.TrainerTypebased on theAbstractTrainer.ALGORITHM_PARAMvalue.- Parameters:
trainParams- - A mapping oftraining parameters.- Returns:
- The
TrainerFactory.TrainerTypeornullif the type couldn't be determined.
-
getSequenceModelTrainer
public static SequenceTrainer getSequenceModelTrainer(TrainingParameters trainParams, Map<String,String> reportMap)
Retrieves aSequenceTrainerthat fits the given parameters.- Parameters:
trainParams- TheTrainingParametersto check for the trainer type. Note: The entryAbstractTrainer.ALGORITHM_PARAMis used to determine the type.reportMap- AMapthat shall be used during initialization of theSequenceTrainer.- Returns:
- A valid
SequenceTrainerfor the configuredtrainParams. - Throws:
IllegalArgumentException- Thrown if the trainer type could not be determined.
-
getEventModelSequenceTrainer
public static <T> EventModelSequenceTrainer<T> getEventModelSequenceTrainer(TrainingParameters trainParams, Map<String,String> reportMap)
Retrieves anEventModelSequenceTrainerthat fits the given parameters.- Parameters:
trainParams- TheTrainingParametersto check for the trainer type. Note: The entryAbstractTrainer.ALGORITHM_PARAMis used to determine the type.reportMap- AMapthat shall be used during initialization of theEventModelSequenceTrainer.- Returns:
- A valid
EventModelSequenceTrainerfor the configuredtrainParams. - Throws:
IllegalArgumentException- Thrown if the trainer type could not be determined.
-
getEventTrainer
public static EventTrainer getEventTrainer(TrainingParameters trainParams, Map<String,String> reportMap)
Retrieves anEventTrainerthat fits the given parameters.- Parameters:
trainParams- TheTrainingParametersto check for the trainer type. Note: The entryAbstractTrainer.ALGORITHM_PARAMis used to determine the type. If the type is not defined, theGISTrainer.MAXENT_VALUEwill be used.reportMap- AMapthat shall be used during initialization of theEventTrainer.- Returns:
- A valid
EventTrainerfor the configuredtrainParams.
-
isValid
public static boolean isValid(TrainingParameters trainParams)
- Parameters:
trainParams- TheTrainingParametersto validate. Must not benull.- Returns:
trueif thetrainParamscould be validated,falseotherwise.
-
-