Klasse TrainingParameters

java.lang.Object
opennlp.tools.util.TrainingParameters

public class TrainingParameters extends Object
Declares and handles default parameters used for or during training models.
  • Felddetails

  • Konstruktordetails

  • Methodendetails

    • algorithm

      public String algorithm(String namespace)
      Gibt zurück:
      Retrieves the training algorithm name for a given name space, or null if unset.
    • algorithm

      public String algorithm()
      Gibt zurück:
      Retrieves the training algorithm name. or @code null} if not set.
    • getObjectSettings

      public Map<String,Object> getObjectSettings(String namespace)
      Parameter:
      namespace - The name space to filter or narrow the search space. May be null.
      Gibt zurück:
      Retrieves a parameter Map which can be passed to the train and validate methods.
    • getObjectSettings

      public Map<String,Object> getObjectSettings()
      Gibt zurück:
      Retrieves a parameter Map of all parameters without narrowing.
    • getParameters

      public TrainingParameters getParameters(String namespace)
      Parameter:
      namespace - The name space to filter or narrow the search space. May be null.
      Gibt zurück:
      Retrieves TrainingParameters which can be passed to the train and validate methods.
    • putIfAbsent

      public void putIfAbsent(String namespace, String key, String value)
      Puts a value into the current TrainingParameters under a certain key, if the value was not present before. The namespace can be used to prefix the key.
      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be put. May be null.
      key - The identifying key to put or retrieve a value with.
      value - The String parameter to put into this TrainingParameters instance.
    • putIfAbsent

      public void putIfAbsent(String key, String value)
      Puts a value into the current TrainingParameters under a certain key, if the value was not present before.
      Parameter:
      key - The identifying key to put or retrieve a value with.
      value - The String parameter to put into this TrainingParameters instance.
    • putIfAbsent

      public void putIfAbsent(String namespace, String key, int value)
      Puts a value into the current TrainingParameters under a certain key, if the value was not present before. The namespace can be used to prefix the key.
      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be put. May be null.
      key - The identifying key to put or retrieve a value with.
      value - The Integer parameter to put into this TrainingParameters instance.
    • putIfAbsent

      public void putIfAbsent(String key, int value)
      Puts a value into the current TrainingParameters under a certain key, if the value was not present before.
      Parameter:
      key - The identifying key to put or retrieve a value with.
      value - The Integer parameter to put into this TrainingParameters instance.
    • putIfAbsent

      public void putIfAbsent(String namespace, String key, double value)
      Puts a value into the current TrainingParameters under a certain key, if the value was not present before. The namespace can be used to prefix the key.
      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be put. May be null.
      key - The identifying key to put or retrieve a value with.
      value - The Double parameter to put into this TrainingParameters instance.
    • putIfAbsent

      public void putIfAbsent(String key, double value)
      Puts a value into the current TrainingParameters under a certain key, if the value was not present before. The namespace can be used to prefix the key.
      Parameter:
      key - The identifying key to put or retrieve a value with.
      value - The Double parameter to put into this TrainingParameters instance.
    • putIfAbsent

      public void putIfAbsent(String namespace, String key, boolean value)
      Puts a value into the current TrainingParameters under a certain key, if the value was not present before. The namespace can be used to prefix the key.
      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be put. May be null.
      key - The identifying key to put or retrieve a value with.
      value - The Boolean parameter to put into this TrainingParameters instance.
    • putIfAbsent

      public void putIfAbsent(String key, boolean value)
      Puts a value into the current TrainingParameters under a certain key, if the value was not present before.
      Parameter:
      key - The identifying key to put or retrieve a value with.
      value - The Boolean parameter to put into this TrainingParameters instance.
    • put

      public void put(String namespace, String key, String value)
      Puts a value into the current TrainingParameters under a certain key. If the value was present before, the previous value will be overwritten with the specified one. The namespace can be used to prefix the key.
      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be put. May be null.
      key - The identifying key to put or retrieve a value with.
      value - The String parameter to put into this TrainingParameters instance.
    • put

      public void put(String key, String value)
      Puts a value into the current TrainingParameters under a certain key. If the value was present before, the previous value will be overwritten with the specified one.
      Parameter:
      key - The identifying key to put or retrieve a value with.
      value - The String parameter to put into this TrainingParameters instance.
    • put

      public void put(String namespace, String key, int value)
      Puts a value into the current TrainingParameters under a certain key. If the value was present before, the previous value will be overwritten with the specified one. The namespace can be used to prefix the key.
      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be put. May be null.
      key - The identifying key to put or retrieve a value with.
      value - The Integer parameter to put into this TrainingParameters instance.
    • put

      public void put(String key, int value)
      Puts a value into the current TrainingParameters under a certain key. If the value was present before, the previous value will be overwritten with the specified one.
      Parameter:
      key - The identifying key to put or retrieve a value with.
      value - The Integer parameter to put into this TrainingParameters instance.
    • put

      public void put(String namespace, String key, double value)
      Puts a value into the current TrainingParameters under a certain key. If the value was present before, the previous value will be overwritten with the specified one. The namespace can be used to prefix the key.
      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be put. May be null.
      key - The identifying key to put or retrieve a value with.
      value - The Double parameter to put into this TrainingParameters instance.
    • put

      public void put(String key, double value)
      Puts a value into the current TrainingParameters under a certain key. If the value was present before, the previous value will be overwritten with the specified one.
      Parameter:
      key - The identifying key to put or retrieve a value with.
      value - The Double parameter to put into this TrainingParameters instance.
    • put

      public void put(String namespace, String key, boolean value)
      Puts a value into the current TrainingParameters under a certain key. If the value was present before, the previous value will be overwritten with the specified one. The namespace can be used to prefix the key.
      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be put. May be null.
      key - The identifying key to put or retrieve a value with.
      value - The Boolean parameter to put into this TrainingParameters instance.
    • put

      public void put(String key, boolean value)
      Puts a value into the current TrainingParameters under a certain key. If the value was present before, the previous value will be overwritten with the specified one.
      Parameter:
      key - The identifying key to put or retrieve a value with.
      value - The Boolean parameter to put into this TrainingParameters instance.
    • serialize

      public void serialize(OutputStream out) throws IOException
      Serializes a TrainingParameters instance via a specified OutputStream.
      Parameter:
      out - A valid, open OutputStream to write to.
      Löst aus:
      IOException - Thrown if errors occurred.
    • getStringParameter

      public String getStringParameter(String key, String defaultValue)
      Obtains a training parameter value.

      Note: ClassCastException can be thrown if the value is not String

      Parameter:
      key - The identifying key to retrieve a value with.
      defaultValue - The alternative value to use, if key was not present.
      Gibt zurück:
      The training value associated with key if present, or a defaultValue if not.
    • getStringParameter

      public String getStringParameter(String namespace, String key, String defaultValue)
      Obtains a training parameter value in the specified namespace.

      Note: ClassCastException can be thrown if the value is not String

      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be searched. May be null.
      key - The identifying key to retrieve a value with.
      defaultValue - The alternative value to use, if key was not present.
      Gibt zurück:
      The training value associated with key if present, or a defaultValue if not.
    • getIntParameter

      public int getIntParameter(String key, int defaultValue)
      Obtains a training parameter value.

      Parameter:
      key - The identifying key to retrieve a value with.
      defaultValue - The alternative value to use, if key was not present.
      Gibt zurück:
      The training value associated with key if present, or a defaultValue if not.
    • getIntParameter

      public int getIntParameter(String namespace, String key, int defaultValue)
      Obtains a training parameter value in the specified namespace.

      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be searched. May be null.
      key - The identifying key to retrieve a value with.
      defaultValue - The alternative value to use, if key was not present.
      Gibt zurück:
      The training value associated with key if present, or a defaultValue if not.
    • getDoubleParameter

      public double getDoubleParameter(String key, double defaultValue)
      Obtains a training parameter value.

      Parameter:
      key - The identifying key to retrieve a value with.
      defaultValue - The alternative value to use, if key was not present.
      Gibt zurück:
      The training value associated with key if present, or a defaultValue if not.
    • getDoubleParameter

      public double getDoubleParameter(String namespace, String key, double defaultValue)
      Obtains a training parameter value in the specified namespace.

      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be searched. May be null.
      key - The identifying key to retrieve a value with.
      defaultValue - The alternative value to use, if key was not present.
      Gibt zurück:
      The training value associated with key if present, or a defaultValue if not.
    • getBooleanParameter

      public boolean getBooleanParameter(String key, boolean defaultValue)
      Obtains a training parameter value.

      Parameter:
      key - The identifying key to retrieve a value with.
      defaultValue - The alternative value to use, if key was not present.
      Gibt zurück:
      The training value associated with key if present, or a defaultValue if not.
    • getBooleanParameter

      public boolean getBooleanParameter(String namespace, String key, boolean defaultValue)
      Obtains a training parameter value in the specified namespace.

      Parameter:
      namespace - A prefix to declare or use a name space under which key shall be searched. May be null.
      key - The identifying key to retrieve a value with.
      defaultValue - The alternative value to use, if key was not present.
      Gibt zurück:
      The training value associated with key if present, or a defaultValue if not.
    • defaultParams

      public static TrainingParameters defaultParams()
      Gibt zurück:
      Retrieves a new instance initialized with default values.
    • setParams

      public static TrainingParameters setParams(String[] params)
      Parameter:
      params - The parameters to additionally apply into the new instance.
      Gibt zurück:
      Retrieves a new instance initialized with given parameter values.