Class TrainerFactory
java.lang.Object
opennlp.tools.ml.TrainerFactory
A factory to initialize
Trainer instances depending on a trainer type
configured via Parameters.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> opennlp.tools.ml.EventModelSequenceTrainer<T, opennlp.tools.util.TrainingParameters> getEventModelSequenceTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String, String> reportMap) Retrieves anEventModelSequenceTrainerthat fits the given parameters.static opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters> getEventTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String, String> reportMap) Works just likegetEventTrainer(TrainingParameters, Map, TrainingConfiguration)except thatTrainingConfigurationis initialized with default values.static opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters> getEventTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String, String> reportMap, opennlp.tools.util.TrainingConfiguration config) Retrieves anEventTrainerthat fits the given parameters.static opennlp.tools.ml.SequenceTrainer<opennlp.tools.util.TrainingParameters> getSequenceModelTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String, String> reportMap) Retrieves aSequenceTrainerthat fits the given parameters.static TrainerFactory.TrainerTypegetTrainerType(opennlp.tools.util.Parameters trainParams) Determines theTrainerFactory.TrainerTypebased on theParameters.ALGORITHM_PARAMvalue.static booleanisValid(opennlp.tools.util.Parameters trainParams)
-
Constructor Details
-
TrainerFactory
public TrainerFactory()
-
-
Method Details
-
getTrainerType
Determines theTrainerFactory.TrainerTypebased on theParameters.ALGORITHM_PARAMvalue.- Parameters:
trainParams- - A mapping oftraining parameters.- Returns:
- The
TrainerFactory.TrainerTypeornullif the type couldn't be determined.
-
getSequenceModelTrainer
public static opennlp.tools.ml.SequenceTrainer<opennlp.tools.util.TrainingParameters> getSequenceModelTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String, String> reportMap) Retrieves aSequenceTrainerthat fits the given parameters.- Parameters:
trainParams- TheParametersto check for the trainer type. Note: The entryParameters.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> opennlp.tools.ml.EventModelSequenceTrainer<T, opennlp.tools.util.TrainingParameters> getEventModelSequenceTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String, String> reportMap) Retrieves anEventModelSequenceTrainerthat fits the given parameters.- Parameters:
trainParams- TheParametersto check for the trainer type. Note: The entryParameters.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 opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters> getEventTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String, String> reportMap) Works just likegetEventTrainer(TrainingParameters, Map, TrainingConfiguration)except thatTrainingConfigurationis initialized with default values. -
getEventTrainer
public static opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters> getEventTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String, String> reportMap, opennlp.tools.util.TrainingConfiguration config) Retrieves anEventTrainerthat fits the given parameters.- Parameters:
trainParams- TheParametersto check for the trainer type. Note: The entryParameters.ALGORITHM_PARAMis used to determine the type. If the type is not defined, theParameters.ALGORITHM_DEFAULT_VALUEwill be used.reportMap- AMapthat shall be used during initialization of theEventTrainer.config- TheTrainingConfigurationto be used.- Returns:
- A valid
EventTrainerfor the configuredtrainParams.
-
isValid
public static boolean isValid(opennlp.tools.util.Parameters trainParams) - Parameters:
trainParams- TheParametersto validate. Must not benull.- Returns:
trueif thetrainParamscould be validated,falseotherwise.
-