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
-
Constructor Summary
ConstructorDescriptionNo-arg constructor to create a defaultTrainingParameters
instance.InputStream
based constructor that reads inTrainingParameters
.TrainingParameters
(Map<String, Object> map) Key-value based constructor to apply aMap
based configuration initialization.TrainingParameters
(TrainingParameters trainingParameters) Copy constructor to hand over the config of existingTrainingParameters
. -
Method Summary
Modifier and TypeMethodDescriptionstatic TrainingParameters
boolean
getBooleanParameter
(String key, boolean defaultValue) Obtains a training parameter value.boolean
getBooleanParameter
(String namespace, String key, boolean defaultValue) Obtains a training parameter value in the specified namespace.double
getDoubleParameter
(String key, double defaultValue) Obtains a training parameter value.double
getDoubleParameter
(String namespace, String key, double defaultValue) Obtains a training parameter value in the specified namespace.int
getIntParameter
(String key, int defaultValue) Obtains a training parameter value.int
getIntParameter
(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.void
void
void
void
void
void
void
void
void
putIfAbsent
(String key, boolean value) Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.void
putIfAbsent
(String key, double value) Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.void
putIfAbsent
(String key, int value) Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.void
putIfAbsent
(String key, String value) Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.void
putIfAbsent
(String namespace, String key, boolean value) Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.void
putIfAbsent
(String namespace, String key, double value) Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.void
putIfAbsent
(String namespace, String key, int value) Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.void
putIfAbsent
(String namespace, String key, String value) Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.void
serialize
(OutputStream out) Serializes aTrainingParameters
instance 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 defaultTrainingParameters
instance. -
TrainingParameters
Copy constructor to hand over the config of existingTrainingParameters
. -
TrainingParameters
Key-value based constructor to apply aMap
based configuration initialization. -
TrainingParameters
InputStream
based 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
null
if 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
Map
which can be passed to the train and validate methods.
-
getObjectSettings
- Returns:
- Retrieves a parameter
Map
of all parameters without narrowing.
-
getParameters
- Parameters:
namespace
- The name space to filter or narrow the search space. May benull
.- Returns:
- Retrieves
TrainingParameters
which can be passed to the train and validate methods.
-
putIfAbsent
Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before. Thenamespace
can be used to prefix thekey
.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be put. May benull
.key
- The identifying key to put or retrieve avalue
with.value
- TheString
parameter to put into thisTrainingParameters
instance.
-
putIfAbsent
Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.- Parameters:
key
- The identifying key to put or retrieve avalue
with.value
- TheString
parameter to put into thisTrainingParameters
instance.
-
putIfAbsent
Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before. Thenamespace
can be used to prefix thekey
.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be put. May benull
.key
- The identifying key to put or retrieve avalue
with.value
- TheInteger
parameter to put into thisTrainingParameters
instance.
-
putIfAbsent
Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.- Parameters:
key
- The identifying key to put or retrieve avalue
with.value
- TheInteger
parameter to put into thisTrainingParameters
instance.
-
putIfAbsent
Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before. Thenamespace
can be used to prefix thekey
.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be put. May benull
.key
- The identifying key to put or retrieve avalue
with.value
- TheDouble
parameter to put into thisTrainingParameters
instance.
-
putIfAbsent
Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before. Thenamespace
can be used to prefix thekey
.- Parameters:
key
- The identifying key to put or retrieve avalue
with.value
- TheDouble
parameter to put into thisTrainingParameters
instance.
-
putIfAbsent
Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before. Thenamespace
can be used to prefix thekey
.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be put. May benull
.key
- The identifying key to put or retrieve avalue
with.value
- TheBoolean
parameter to put into thisTrainingParameters
instance.
-
putIfAbsent
Puts avalue
into the currentTrainingParameters
under a certainkey
, if the value was not present before.- Parameters:
key
- The identifying key to put or retrieve avalue
with.value
- TheBoolean
parameter to put into thisTrainingParameters
instance.
-
put
Puts avalue
into the currentTrainingParameters
under a certainkey
. If the value was present before, the previous value will be overwritten with the specified one. Thenamespace
can be used to prefix thekey
.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be put. May benull
.key
- The identifying key to put or retrieve avalue
with.value
- TheString
parameter to put into thisTrainingParameters
instance.
-
put
Puts avalue
into the currentTrainingParameters
under 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 avalue
with.value
- TheString
parameter to put into thisTrainingParameters
instance.
-
put
Puts avalue
into the currentTrainingParameters
under a certainkey
. If the value was present before, the previous value will be overwritten with the specified one. Thenamespace
can be used to prefix thekey
.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be put. May benull
.key
- The identifying key to put or retrieve avalue
with.value
- TheInteger
parameter to put into thisTrainingParameters
instance.
-
put
Puts avalue
into the currentTrainingParameters
under 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 avalue
with.value
- TheInteger
parameter to put into thisTrainingParameters
instance.
-
put
Puts avalue
into the currentTrainingParameters
under a certainkey
. If the value was present before, the previous value will be overwritten with the specified one. Thenamespace
can be used to prefix thekey
.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be put. May benull
.key
- The identifying key to put or retrieve avalue
with.value
- TheDouble
parameter to put into thisTrainingParameters
instance.
-
put
Puts avalue
into the currentTrainingParameters
under 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 avalue
with.value
- TheDouble
parameter to put into thisTrainingParameters
instance.
-
put
Puts avalue
into the currentTrainingParameters
under a certainkey
. If the value was present before, the previous value will be overwritten with the specified one. Thenamespace
can be used to prefix thekey
.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be put. May benull
.key
- The identifying key to put or retrieve avalue
with.value
- TheBoolean
parameter to put into thisTrainingParameters
instance.
-
put
Puts avalue
into the currentTrainingParameters
under 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 avalue
with.value
- TheBoolean
parameter to put into thisTrainingParameters
instance.
-
serialize
Serializes aTrainingParameters
instance via a specifiedOutputStream
.- Parameters:
out
- A valid, openOutputStream
to write to.- Throws:
IOException
- Thrown if errors occurred.
-
getStringParameter
Obtains a training parameter value.Note:
ClassCastException
can be thrown if the value is notString
- Parameters:
key
- The identifying key to retrieve avalue
with.defaultValue
- The alternative value to use, ifkey
was not present.- Returns:
- The
training value
associated withkey
if present, or adefaultValue
if not.
-
getStringParameter
Obtains a training parameter value in the specified namespace.Note:
ClassCastException
can be thrown if the value is notString
- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be searched. May benull
.key
- The identifying key to retrieve avalue
with.defaultValue
- The alternative value to use, ifkey
was not present.- Returns:
- The
training value
associated withkey
if present, or adefaultValue
if not.
-
getIntParameter
Obtains a training parameter value.- Parameters:
key
- The identifying key to retrieve avalue
with.defaultValue
- The alternative value to use, ifkey
was not present.- Returns:
- The
training value
associated withkey
if present, or adefaultValue
if not.
-
getIntParameter
Obtains a training parameter value in the specified namespace.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be searched. May benull
.key
- The identifying key to retrieve avalue
with.defaultValue
- The alternative value to use, ifkey
was not present.- Returns:
- The
training value
associated withkey
if present, or adefaultValue
if not.
-
getDoubleParameter
Obtains a training parameter value.- Parameters:
key
- The identifying key to retrieve avalue
with.defaultValue
- The alternative value to use, ifkey
was not present.- Returns:
- The
training value
associated withkey
if present, or adefaultValue
if not.
-
getDoubleParameter
Obtains a training parameter value in the specified namespace.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be searched. May benull
.key
- The identifying key to retrieve avalue
with.defaultValue
- The alternative value to use, ifkey
was not present.- Returns:
- The
training value
associated withkey
if present, or adefaultValue
if not.
-
getBooleanParameter
Obtains a training parameter value.- Parameters:
key
- The identifying key to retrieve avalue
with.defaultValue
- The alternative value to use, ifkey
was not present.- Returns:
- The
training value
associated withkey
if present, or adefaultValue
if not.
-
getBooleanParameter
Obtains a training parameter value in the specified namespace.- Parameters:
namespace
- A prefix to declare or use a name space under whichkey
shall be searched. May benull
.key
- The identifying key to retrieve avalue
with.defaultValue
- The alternative value to use, ifkey
was not present.- Returns:
- The
training value
associated withkey
if present, or adefaultValue
if not.
-
defaultParams
- Returns:
- Retrieves a new
instance
initialized with default values.
-
setParams
-