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.
  • 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.