Package opennlp.tools.util
Class TrainingParameters
java.lang.Object
opennlp.tools.util.TrainingParameters
Declares and handles default parameters used for or during training models.
- 
Field Summary
Fields - 
Constructor Summary
ConstructorsConstructorDescriptionNo-arg constructor to create a defaultTrainingParametersinstance.InputStreambased constructor that reads inTrainingParameters.TrainingParameters(Map<String, Object> map) Key-value based constructor to apply aMapbased configuration initialization.TrainingParameters(TrainingParameters trainingParameters) Copy constructor to hand over the config of existingTrainingParameters. - 
Method Summary
Modifier and TypeMethodDescriptionstatic TrainingParametersbooleangetBooleanParameter(String key, boolean defaultValue) Obtains a training parameter value.booleangetBooleanParameter(String namespace, String key, boolean defaultValue) Obtains a training parameter value in the specified namespace.doublegetDoubleParameter(String key, double defaultValue) Obtains a training parameter value.doublegetDoubleParameter(String namespace, String key, double defaultValue) Obtains a training parameter value in the specified namespace.intgetIntParameter(String key, int defaultValue) Obtains a training parameter value.intgetIntParameter(String namespace, String key, int defaultValue) Obtains a training parameter value in the specified namespace.getObjectSettings(String namespace) getParameters(String namespace) getStringParameter(String key, String defaultValue) Obtains a training parameter value.getStringParameter(String namespace, String key, String defaultValue) Obtains a training parameter value in the specified namespace.voidvoidvoidvoidvoidvoidvoidvoidvoidputIfAbsent(String key, boolean value) Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.voidputIfAbsent(String key, double value) Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.voidputIfAbsent(String key, int value) Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.voidputIfAbsent(String key, String value) Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.voidputIfAbsent(String namespace, String key, boolean value) Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.voidputIfAbsent(String namespace, String key, double value) Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.voidputIfAbsent(String namespace, String key, int value) Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.voidputIfAbsent(String namespace, String key, String value) Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.voidserialize(OutputStream out) Serializes aTrainingParametersinstance via a specifiedOutputStream.static TrainingParameters 
- 
Field Details
- 
ALGORITHM_PARAM
- See Also:
 
 - 
TRAINER_TYPE_PARAM
- See Also:
 
 - 
ITERATIONS_PARAM
- See Also:
 
 - 
CUTOFF_PARAM
- See Also:
 
 - 
THREADS_PARAM
- See Also:
 
 - 
ITERATIONS_DEFAULT_VALUE
public static final int ITERATIONS_DEFAULT_VALUE- See Also:
 
 - 
CUTOFF_DEFAULT_VALUE
public static final int CUTOFF_DEFAULT_VALUE- See Also:
 
 
 - 
 - 
Constructor Details
- 
TrainingParameters
public TrainingParameters()No-arg constructor to create a defaultTrainingParametersinstance. - 
TrainingParameters
Copy constructor to hand over the config of existingTrainingParameters. - 
TrainingParameters
Key-value based constructor to apply aMapbased configuration initialization. - 
TrainingParameters
InputStreambased constructor that reads inTrainingParameters.- Throws:
 IOException- Thrown if IO errors occurred.
 
 - 
 - 
Method Details
- 
algorithm
- Returns:
 - Retrieves the training algorithm name for a given name space, or 
nullif unset. 
 - 
algorithm
- Returns:
 - Retrieves the training algorithm name. or @code null} if not set.
 
 - 
getObjectSettings
- Parameters:
 namespace- The name space to filter or narrow the search space. May benull.- Returns:
 - Retrieves a parameter 
Mapwhich can be passed to the train and validate methods. 
 - 
getObjectSettings
- Returns:
 - Retrieves a parameter 
Mapof all parameters without narrowing. 
 - 
getParameters
- Parameters:
 namespace- The name space to filter or narrow the search space. May benull.- Returns:
 - Retrieves 
TrainingParameterswhich can be passed to the train and validate methods. 
 - 
putIfAbsent
Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be put. May benull.key- The identifying key to put or retrieve avaluewith.value- TheStringparameter to put into thisTrainingParametersinstance.
 - 
putIfAbsent
Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.- Parameters:
 key- The identifying key to put or retrieve avaluewith.value- TheStringparameter to put into thisTrainingParametersinstance.
 - 
putIfAbsent
Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be put. May benull.key- The identifying key to put or retrieve avaluewith.value- TheIntegerparameter to put into thisTrainingParametersinstance.
 - 
putIfAbsent
Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.- Parameters:
 key- The identifying key to put or retrieve avaluewith.value- TheIntegerparameter to put into thisTrainingParametersinstance.
 - 
putIfAbsent
Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be put. May benull.key- The identifying key to put or retrieve avaluewith.value- TheDoubleparameter to put into thisTrainingParametersinstance.
 - 
putIfAbsent
Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Parameters:
 key- The identifying key to put or retrieve avaluewith.value- TheDoubleparameter to put into thisTrainingParametersinstance.
 - 
putIfAbsent
Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be put. May benull.key- The identifying key to put or retrieve avaluewith.value- TheBooleanparameter to put into thisTrainingParametersinstance.
 - 
putIfAbsent
Puts avalueinto the currentTrainingParametersunder a certainkey, if the value was not present before.- Parameters:
 key- The identifying key to put or retrieve avaluewith.value- TheBooleanparameter to put into thisTrainingParametersinstance.
 - 
put
Puts avalueinto the currentTrainingParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one. Thenamespacecan be used to prefix thekey.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be put. May benull.key- The identifying key to put or retrieve avaluewith.value- TheStringparameter to put into thisTrainingParametersinstance.
 - 
put
Puts avalueinto the currentTrainingParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one.- Parameters:
 key- The identifying key to put or retrieve avaluewith.value- TheStringparameter to put into thisTrainingParametersinstance.
 - 
put
Puts avalueinto the currentTrainingParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one. Thenamespacecan be used to prefix thekey.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be put. May benull.key- The identifying key to put or retrieve avaluewith.value- TheIntegerparameter to put into thisTrainingParametersinstance.
 - 
put
Puts avalueinto the currentTrainingParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one.- Parameters:
 key- The identifying key to put or retrieve avaluewith.value- TheIntegerparameter to put into thisTrainingParametersinstance.
 - 
put
Puts avalueinto the currentTrainingParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one. Thenamespacecan be used to prefix thekey.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be put. May benull.key- The identifying key to put or retrieve avaluewith.value- TheDoubleparameter to put into thisTrainingParametersinstance.
 - 
put
Puts avalueinto the currentTrainingParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one.- Parameters:
 key- The identifying key to put or retrieve avaluewith.value- TheDoubleparameter to put into thisTrainingParametersinstance.
 - 
put
Puts avalueinto the currentTrainingParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one. Thenamespacecan be used to prefix thekey.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be put. May benull.key- The identifying key to put or retrieve avaluewith.value- TheBooleanparameter to put into thisTrainingParametersinstance.
 - 
put
Puts avalueinto the currentTrainingParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one.- Parameters:
 key- The identifying key to put or retrieve avaluewith.value- TheBooleanparameter to put into thisTrainingParametersinstance.
 - 
serialize
Serializes aTrainingParametersinstance via a specifiedOutputStream.- Parameters:
 out- A valid, openOutputStreamto write to.- Throws:
 IOException- Thrown if errors occurred.
 - 
getStringParameter
Obtains a training parameter value.Note:
ClassCastExceptioncan be thrown if the value is notString- Parameters:
 key- The identifying key to retrieve avaluewith.defaultValue- The alternative value to use, ifkeywas not present.- Returns:
 - The 
training valueassociated withkeyif present, or adefaultValueif not. 
 - 
getStringParameter
Obtains a training parameter value in the specified namespace.Note:
ClassCastExceptioncan be thrown if the value is notString- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be searched. May benull.key- The identifying key to retrieve avaluewith.defaultValue- The alternative value to use, ifkeywas not present.- Returns:
 - The 
training valueassociated withkeyif present, or adefaultValueif not. 
 - 
getIntParameter
Obtains a training parameter value.- Parameters:
 key- The identifying key to retrieve avaluewith.defaultValue- The alternative value to use, ifkeywas not present.- Returns:
 - The 
training valueassociated withkeyif present, or adefaultValueif not. 
 - 
getIntParameter
Obtains a training parameter value in the specified namespace.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be searched. May benull.key- The identifying key to retrieve avaluewith.defaultValue- The alternative value to use, ifkeywas not present.- Returns:
 - The 
training valueassociated withkeyif present, or adefaultValueif not. 
 - 
getDoubleParameter
Obtains a training parameter value.- Parameters:
 key- The identifying key to retrieve avaluewith.defaultValue- The alternative value to use, ifkeywas not present.- Returns:
 - The 
training valueassociated withkeyif present, or adefaultValueif not. 
 - 
getDoubleParameter
Obtains a training parameter value in the specified namespace.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be searched. May benull.key- The identifying key to retrieve avaluewith.defaultValue- The alternative value to use, ifkeywas not present.- Returns:
 - The 
training valueassociated withkeyif present, or adefaultValueif not. 
 - 
getBooleanParameter
Obtains a training parameter value.- Parameters:
 key- The identifying key to retrieve avaluewith.defaultValue- The alternative value to use, ifkeywas not present.- Returns:
 - The 
training valueassociated withkeyif present, or adefaultValueif not. 
 - 
getBooleanParameter
Obtains a training parameter value in the specified namespace.- Parameters:
 namespace- A prefix to declare or use a name space under whichkeyshall be searched. May benull.key- The identifying key to retrieve avaluewith.defaultValue- The alternative value to use, ifkeywas not present.- Returns:
 - The 
training valueassociated withkeyif present, or adefaultValueif not. 
 - 
defaultParams
- Returns:
 - Retrieves a new 
instanceinitialized with default values. 
 - 
setParams
 
 -