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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> EventModelSequenceTrainer<T>
getEventModelSequenceTrainer
(TrainingParameters trainParams, Map<String, String> reportMap) Retrieves anEventModelSequenceTrainer
that fits the given parameters.static EventTrainer
getEventTrainer
(TrainingParameters trainParams, Map<String, String> reportMap) Retrieves anEventTrainer
that fits the given parameters.static SequenceTrainer
getSequenceModelTrainer
(TrainingParameters trainParams, Map<String, String> reportMap) Retrieves aSequenceTrainer
that fits the given parameters.static TrainerFactory.TrainerType
getTrainerType
(TrainingParameters trainParams) Determines theTrainerFactory.TrainerType
based on theAbstractTrainer.ALGORITHM_PARAM
value.static boolean
isValid
(TrainingParameters trainParams)
-
Constructor Details
-
TrainerFactory
public TrainerFactory()
-
-
Method Details
-
getTrainerType
Determines theTrainerFactory.TrainerType
based on theAbstractTrainer.ALGORITHM_PARAM
value.- Parameters:
trainParams
- - A mapping oftraining parameters
.- Returns:
- The
TrainerFactory.TrainerType
ornull
if the type couldn't be determined.
-
getSequenceModelTrainer
public static SequenceTrainer getSequenceModelTrainer(TrainingParameters trainParams, Map<String, String> reportMap) Retrieves aSequenceTrainer
that fits the given parameters.- Parameters:
trainParams
- TheTrainingParameters
to check for the trainer type. Note: The entryAbstractTrainer.ALGORITHM_PARAM
is used to determine the type.reportMap
- AMap
that shall be used during initialization of theSequenceTrainer
.- Returns:
- A valid
SequenceTrainer
for 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 anEventModelSequenceTrainer
that fits the given parameters.- Parameters:
trainParams
- TheTrainingParameters
to check for the trainer type. Note: The entryAbstractTrainer.ALGORITHM_PARAM
is used to determine the type.reportMap
- AMap
that shall be used during initialization of theEventModelSequenceTrainer
.- Returns:
- A valid
EventModelSequenceTrainer
for 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 anEventTrainer
that fits the given parameters.- Parameters:
trainParams
- TheTrainingParameters
to check for the trainer type. Note: The entryAbstractTrainer.ALGORITHM_PARAM
is used to determine the type. If the type is not defined, theGISTrainer.MAXENT_VALUE
will be used.reportMap
- AMap
that shall be used during initialization of theEventTrainer
.- Returns:
- A valid
EventTrainer
for the configuredtrainParams
.
-
isValid
- Parameters:
trainParams
- TheTrainingParameters
to validate. Must not benull
.- Returns:
true
if thetrainParams
could be validated,false
otherwise.
-