TrainerFactory (Apache OpenNLP :: Core :: Runtime 3.0.0-M4 API)
Description: declaration: package: opennlp.tools.ml, class: TrainerFactory

Package opennlp.tools.ml

# Class TrainerFactory

java.lang.Object
opennlp.tools.ml.TrainerFactory

public class TrainerFactory extends Object
A factory to initialize `Trainer` instances depending on a trainer type configured via `Parameters`.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `TrainerFactory.TrainerType`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TrainerFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T> opennlp.tools.ml.EventModelSequenceTrainer<T,opennlp.tools.util.TrainingParameters>`
  `getEventModelSequenceTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String,String> reportMap)`
  Retrieves an `EventModelSequenceTrainer` that fits the given parameters.
  `static opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters>`
  `getEventTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String,String> reportMap)`
  Works just like `getEventTrainer(TrainingParameters, Map, TrainingConfiguration)` except that `TrainingConfiguration` is initialized with default values.
  `static opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters>`
  `getEventTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String,String> reportMap, opennlp.tools.util.TrainingConfiguration config)`
  Retrieves an `EventTrainer` that fits the given parameters.
  `static opennlp.tools.ml.SequenceTrainer<opennlp.tools.util.TrainingParameters>`
  `getSequenceModelTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String,String> reportMap)`
  Retrieves a `SequenceTrainer` that fits the given parameters.
  `static TrainerFactory.TrainerType`
  `getTrainerType(opennlp.tools.util.Parameters trainParams)`
  Determines the `TrainerFactory.TrainerType` based on the `Parameters.ALGORITHM_PARAM` value.
  `static boolean`
  `isValid(opennlp.tools.util.Parameters trainParams)`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### TrainerFactory

    public TrainerFactory()

- ## Method Details

  - ### getTrainerType

    public static TrainerFactory.TrainerType getTrainerType(opennlp.tools.util.Parameters trainParams)
    Determines the `TrainerFactory.TrainerType` based on the `Parameters.ALGORITHM_PARAM` value.
    Parameters:
      `trainParams` - - A mapping of `training parameters`.
    Returns:
      The `TrainerFactory.TrainerType` or `null` if the type couldn't be determined.

  - ### getSequenceModelTrainer

    public static opennlp.tools.ml.SequenceTrainer<opennlp.tools.util.TrainingParameters> getSequenceModelTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String,String> reportMap)
    Retrieves a `SequenceTrainer` that fits the given parameters.
    Parameters:
      `trainParams` - The `Parameters` to check for the trainer type. Note: The entry `Parameters.ALGORITHM_PARAM` is used to determine the type.
      `reportMap` - A `Map` that shall be used during initialization of the `SequenceTrainer`.
    Returns:
      A valid `SequenceTrainer` for the configured `trainParams`.
    Throws:
      `IllegalArgumentException` - Thrown if the trainer type could not be determined.

  - ### getEventModelSequenceTrainer

    public static <T> opennlp.tools.ml.EventModelSequenceTrainer<T,opennlp.tools.util.TrainingParameters> getEventModelSequenceTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String,String> reportMap)
    Retrieves an `EventModelSequenceTrainer` that fits the given parameters.
    Parameters:
      `trainParams` - The `Parameters` to check for the trainer type. Note: The entry `Parameters.ALGORITHM_PARAM` is used to determine the type.
      `reportMap` - A `Map` that shall be used during initialization of the `EventModelSequenceTrainer`.
    Returns:
      A valid `EventModelSequenceTrainer` for the configured `trainParams`.
    Throws:
      `IllegalArgumentException` - Thrown if the trainer type could not be determined.

  - ### getEventTrainer

    public static opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters> getEventTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String,String> reportMap)
    Works just like `getEventTrainer(TrainingParameters, Map, TrainingConfiguration)` except that `TrainingConfiguration` is initialized with default values.

  - ### getEventTrainer

    public static opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters> getEventTrainer(opennlp.tools.util.TrainingParameters trainParams, Map<String,String> reportMap, opennlp.tools.util.TrainingConfiguration config)
    Retrieves an `EventTrainer` that fits the given parameters.
    Parameters:
      `trainParams` - The `Parameters` to check for the trainer type. Note: The entry `Parameters.ALGORITHM_PARAM` is used to determine the type. If the type is not defined, the `Parameters.ALGORITHM_DEFAULT_VALUE` will be used.
      `reportMap` - A `Map` that shall be used during initialization of the `EventTrainer`.
      `config` - The `TrainingConfiguration` to be used.
    Returns:
      A valid `EventTrainer` for the configured `trainParams`.

  - ### isValid

    public static boolean isValid(opennlp.tools.util.Parameters trainParams)
    Parameters:
      `trainParams` - The `Parameters` to validate. Must not be `null`.
    Returns:
      `true` if the `trainParams` could be validated, `false` otherwise.