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 `TrainingParameters`.

- ## 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> EventModelSequenceTrainer<T>`
  `getEventModelSequenceTrainer(TrainingParameters trainParams, Map<String,String> reportMap)`
  Retrieves an `EventModelSequenceTrainer` that fits the given parameters.
  `static EventTrainer`
  `getEventTrainer(TrainingParameters trainParams, Map<String,String> reportMap)`
  Retrieves an `EventTrainer` that fits the given parameters.
  `static SequenceTrainer`
  `getSequenceModelTrainer(TrainingParameters trainParams, Map<String,String> reportMap)`
  Retrieves a `SequenceTrainer` that fits the given parameters.
  `static TrainerFactory.TrainerType`
  `getTrainerType(TrainingParameters trainParams)`
  Determines the `TrainerFactory.TrainerType` based on the `AbstractTrainer.ALGORITHM_PARAM` value.
  `static boolean`
  `isValid(TrainingParameters 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(TrainingParameters trainParams)
    Determines the `TrainerFactory.TrainerType` based on the `AbstractTrainer.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 SequenceTrainer getSequenceModelTrainer(TrainingParameters trainParams, Map<String,String> reportMap)
    Retrieves a `SequenceTrainer` that fits the given parameters.
    Parameters:
      `trainParams` - The `TrainingParameters` to check for the trainer type. Note: The entry `AbstractTrainer.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> EventModelSequenceTrainer<T> getEventModelSequenceTrainer(TrainingParameters trainParams, Map<String,String> reportMap)
    Retrieves an `EventModelSequenceTrainer` that fits the given parameters.
    Parameters:
      `trainParams` - The `TrainingParameters` to check for the trainer type. Note: The entry `AbstractTrainer.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 EventTrainer getEventTrainer(TrainingParameters trainParams, Map<String,String> reportMap)
    Retrieves an `EventTrainer` that fits the given parameters.
    Parameters:
      `trainParams` - The `TrainingParameters` to check for the trainer type. Note: The entry `AbstractTrainer.ALGORITHM_PARAM` is used to determine the type. If the type is not defined, the `GISTrainer.MAXENT_VALUE` will be used.
      `reportMap` - A `Map` that shall be used during initialization of the `EventTrainer`.
    Returns:
      A valid `EventTrainer` for the configured `trainParams`.

  - ### isValid

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