Package opennlp.tools.util
Class TrainingParameters
java.lang.Object
opennlp.tools.util.TrainingParameters
- All Implemented Interfaces:
Parameters
Declares and handles default parameters used for or during training models.
-
Field Summary
FieldsFields inherited from interface opennlp.tools.util.Parameters
ALGORITHM_DEFAULT_VALUE, ALGORITHM_PARAM, CUTOFF_DEFAULT_VALUE, CUTOFF_PARAM, ITERATIONS_DEFAULT_VALUE, ITERATIONS_PARAM, THREADS_PARAM, TRAINER_TYPE_PARAM -
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.private static IntegergetIntParameter(String param, String[] args) Retrieves the specified parameter from the specified arguments.intgetIntParameter(String namespace, String key, int defaultValue) Obtains a training parameter value in the specified namespace.getObjectSettings(String namespace) private static StringgetParameter(String param, String[] args) Retrieves the specified parameter from the given arguments.private static intgetParameterIndex(String param, String[] args) Returns the index of the parameter in the arguments, or-1if the parameter is not found.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) voidputIfAbsent(String key, double value) voidputIfAbsent(String key, int value) voidputIfAbsent(String key, String value) voidputIfAbsent(String namespace, String key, boolean value) voidputIfAbsent(String namespace, String key, double value) voidputIfAbsent(String namespace, String key, int value) voidputIfAbsent(String namespace, String key, String value) voidserialize(OutputStream out) Serializes aParametersinstance via a specifiedOutputStream.static TrainingParameters
-
Field Details
-
parameters
-
-
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
- Specified by:
algorithmin interfaceParameters- Returns:
- Retrieves the (training) algorithm name for a given name space, or
nullif unset.
-
algorithm
- Specified by:
algorithmin interfaceParameters- Returns:
- Retrieves the (training) algorithm name. or @code null} if not set.
-
getObjectSettings
- Specified by:
getObjectSettingsin interfaceParameters- 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
- Specified by:
getObjectSettingsin interfaceParameters- 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
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Specified by:
putIfAbsentin interfaceParameters- 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 thisParametersinstance.
-
putIfAbsent
Description copied from interface:Parameters- Specified by:
putIfAbsentin interfaceParameters- Parameters:
key- The identifying key to put or retrieve avaluewith.value- TheStringparameter to put into thisParametersinstance.
-
putIfAbsent
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Specified by:
putIfAbsentin interfaceParameters- 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 thisParametersinstance.
-
putIfAbsent
Description copied from interface:Parameters- Specified by:
putIfAbsentin interfaceParameters- Parameters:
key- The identifying key to put or retrieve avaluewith.value- TheIntegerparameter to put into thisParametersinstance.
-
putIfAbsent
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Specified by:
putIfAbsentin interfaceParameters- 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 thisParametersinstance.
-
putIfAbsent
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Specified by:
putIfAbsentin interfaceParameters- Parameters:
key- The identifying key to put or retrieve avaluewith.value- TheDoubleparameter to put into thisParametersinstance.
-
putIfAbsent
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey, if the value was not present before. Thenamespacecan be used to prefix thekey.- Specified by:
putIfAbsentin interfaceParameters- 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 thisParametersinstance.
-
putIfAbsent
Description copied from interface:Parameters- Specified by:
putIfAbsentin interfaceParameters- Parameters:
key- The identifying key to put or retrieve avaluewith.value- TheBooleanparameter to put into thisParametersinstance.
-
put
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one. Thenamespacecan be used to prefix thekey.- Specified by:
putin interfaceParameters- 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 thisParametersinstance.
-
put
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one.- Specified by:
putin interfaceParameters- Parameters:
key- The identifying key to put or retrieve avaluewith.value- TheStringparameter to put into thisParametersinstance.
-
put
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one. Thenamespacecan be used to prefix thekey.- Specified by:
putin interfaceParameters- 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 thisParametersinstance.
-
put
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one.- Specified by:
putin interfaceParameters- Parameters:
key- The identifying key to put or retrieve avaluewith.value- TheIntegerparameter to put into thisParametersinstance.
-
put
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one. Thenamespacecan be used to prefix thekey.- Specified by:
putin interfaceParameters- 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 thisParametersinstance.
-
put
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one.- Specified by:
putin interfaceParameters- Parameters:
key- The identifying key to put or retrieve avaluewith.value- TheDoubleparameter to put into thisParametersinstance.
-
put
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one. Thenamespacecan be used to prefix thekey.- Specified by:
putin interfaceParameters- 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 thisParametersinstance.
-
put
Description copied from interface:ParametersPuts avalueinto the currentParametersunder a certainkey. If the value was present before, the previous value will be overwritten with the specified one.- Specified by:
putin interfaceParameters- Parameters:
key- The identifying key to put or retrieve avaluewith.value- TheBooleanparameter to put into thisParametersinstance.
-
serialize
Description copied from interface:ParametersSerializes aParametersinstance via a specifiedOutputStream.- Specified by:
serializein interfaceParameters- Parameters:
out- A valid, openOutputStreamto write to.- Throws:
IOException- Thrown if errors occurred.
-
getStringParameter
Description copied from interface:ParametersObtains a training parameter value.- Specified by:
getStringParameterin interfaceParameters- 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
Description copied from interface:ParametersObtains a training parameter value in the specified namespace.- Specified by:
getStringParameterin interfaceParameters- 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
Description copied from interface:ParametersObtains a training parameter value.- Specified by:
getIntParameterin interfaceParameters- 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
Description copied from interface:ParametersObtains a training parameter value in the specified namespace.- Specified by:
getIntParameterin interfaceParameters- 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
Description copied from interface:ParametersObtains a training parameter value.- Specified by:
getDoubleParameterin interfaceParameters- 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
Description copied from interface:ParametersObtains a training parameter value in the specified namespace.- Specified by:
getDoubleParameterin interfaceParameters- 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
Description copied from interface:ParametersObtains a training parameter value.- Specified by:
getBooleanParameterin interfaceParameters- 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
Description copied from interface:ParametersObtains a training parameter value in the specified namespace.- Specified by:
getBooleanParameterin interfaceParameters- 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
-
getIntParameter
Retrieves the specified parameter from the specified arguments.- Parameters:
param- parameter nameargs- arguments- Returns:
- parameter value
-
getParameter
Retrieves the specified parameter from the given arguments.- Parameters:
param- parameter nameargs- arguments- Returns:
- parameter value
-
getParameterIndex
Returns the index of the parameter in the arguments, or-1if the parameter is not found.- Parameters:
param- parameter nameargs- arguments- Returns:
- the index of the parameter in the arguments, or
-1if the parameter is not found
-