/**
   * @deprecated Use {@link TrainerFactory#getSequenceTrainer(Map, Map)} to get an {@link
   *     EventModelSequenceTrainer} instead.
   */
  public static MaxentModel train(
      SequenceStream events, Map<String, String> trainParams, Map<String, String> reportMap)
      throws IOException {

    if (!TrainerFactory.isSupportSequence(trainParams)) {
      throw new IllegalArgumentException("EventTrain is not supported");
    }
    EventModelSequenceTrainer trainer =
        TrainerFactory.getEventModelSequenceTrainer(trainParams, reportMap);

    return trainer.train(events);
  }
  public static POSModel train(
      String languageCode,
      ObjectStream<POSSample> samples,
      TrainingParameters trainParams,
      POSTaggerFactory posFactory)
      throws IOException {

    String beamSizeString = trainParams.getSettings().get(BeamSearch.BEAM_SIZE_PARAMETER);

    int beamSize = POSTaggerME.DEFAULT_BEAM_SIZE;
    if (beamSizeString != null) {
      beamSize = Integer.parseInt(beamSizeString);
    }

    POSContextGenerator contextGenerator = posFactory.getPOSContextGenerator();

    Map<String, String> manifestInfoEntries = new HashMap<String, String>();

    TrainerType trainerType = TrainerFactory.getTrainerType(trainParams.getSettings());

    MaxentModel posModel = null;
    SequenceClassificationModel<String> seqPosModel = null;
    if (TrainerType.EVENT_MODEL_TRAINER.equals(trainerType)) {
      ObjectStream<Event> es = new POSSampleEventStream(samples, contextGenerator);

      EventTrainer trainer =
          TrainerFactory.getEventTrainer(trainParams.getSettings(), manifestInfoEntries);
      posModel = trainer.train(es);
    } else if (TrainerType.EVENT_MODEL_SEQUENCE_TRAINER.equals(trainerType)) {
      POSSampleSequenceStream ss = new POSSampleSequenceStream(samples, contextGenerator);
      EventModelSequenceTrainer trainer =
          TrainerFactory.getEventModelSequenceTrainer(
              trainParams.getSettings(), manifestInfoEntries);
      posModel = trainer.train(ss);
    } else if (TrainerType.SEQUENCE_TRAINER.equals(trainerType)) {
      SequenceTrainer trainer =
          TrainerFactory.getSequenceModelTrainer(trainParams.getSettings(), manifestInfoEntries);

      // TODO: This will probably cause issue, since the feature generator uses the outcomes array

      POSSampleSequenceStream ss = new POSSampleSequenceStream(samples, contextGenerator);
      seqPosModel = trainer.train(ss);
    } else {
      throw new IllegalArgumentException("Trainer type is not supported: " + trainerType);
    }

    if (posModel != null) {
      return new POSModel(languageCode, posModel, beamSize, manifestInfoEntries, posFactory);
    } else {
      return new POSModel(languageCode, seqPosModel, manifestInfoEntries, posFactory);
    }
  }