Package opennlp.tools.ml
Class TrainerFactory
java.lang.Object
opennlp.tools.ml.TrainerFactory
A factory to initialize
Trainer instances depending on a trainer type
configured via TrainingParameters.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <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)
-
Constructor Details
-
TrainerFactory
public TrainerFactory()
-
-
Method Details
-
getTrainerType
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
- Parameters:
trainParams- TheTrainingParametersto validate. Must not benull.- Returns:
trueif thetrainParamscould be validated,falseotherwise.
-