@Test public void testIsSequenceTrainerTrue() { mlParams.put(AbstractTrainer.ALGORITHM_PARAM, SimplePerceptronSequenceTrainer.PERCEPTRON_SEQUENCE_VALUE); TrainerType trainerType = TrainerFactory.getTrainerType(mlParams); Assert.assertTrue(TrainerType.EVENT_MODEL_SEQUENCE_TRAINER.equals(trainerType)); }
public static TrainerType getTrainerType(TrainingParameters trainParams) { String algorithmValue = trainParams.getStringParameter(AbstractTrainer.ALGORITHM_PARAM,null); if (algorithmValue == null) { return TrainerType.EVENT_MODEL_TRAINER; } Class<?> trainerClass = BUILTIN_TRAINERS.get(algorithmValue); if (trainerClass != null) { if (EventTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_TRAINER; } else if (EventModelSequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } else if (SequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.SEQUENCE_TRAINER; } } try { ExtensionLoader.instantiateExtension(EventTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(EventModelSequenceTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(SequenceTrainer.class, algorithmValue); return TrainerType.SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } return null; }
TrainerFactory { public static TrainerType getTrainerType(TrainingParameters trainParams) { String algorithmValue = trainParams.getStringParameter(AbstractTrainer.ALGORITHM_PARAM,null); if (algorithmValue == null) { return TrainerType.EVENT_MODEL_TRAINER; } Class<?> trainerClass = BUILTIN_TRAINERS.get(algorithmValue); if (trainerClass != null) { if (EventTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_TRAINER; } else if (EventModelSequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } else if (SequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.SEQUENCE_TRAINER; } } try { ExtensionLoader.instantiateExtension(EventTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(EventModelSequenceTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(SequenceTrainer.class, algorithmValue); return TrainerType.SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } return null; } }
TrainerFactory { public static TrainerType getTrainerType(TrainingParameters trainParams) { String algorithmValue = trainParams.getStringParameter(AbstractTrainer.ALGORITHM_PARAM,null); if (algorithmValue == null) { return TrainerType.EVENT_MODEL_TRAINER; } Class<?> trainerClass = BUILTIN_TRAINERS.get(algorithmValue); if (trainerClass != null) { if (EventTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_TRAINER; } else if (EventModelSequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } else if (SequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.SEQUENCE_TRAINER; } } try { ExtensionLoader.instantiateExtension(EventTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(EventModelSequenceTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(SequenceTrainer.class, algorithmValue); return TrainerType.SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } return null; }  }
TrainerFactory { public static TrainerType getTrainerType(TrainingParameters trainParams) { String algorithmValue = trainParams.getStringParameter(AbstractTrainer.ALGORITHM_PARAM,null); if (algorithmValue == null) { return TrainerType.EVENT_MODEL_TRAINER; } Class<?> trainerClass = BUILTIN_TRAINERS.get(algorithmValue); if (trainerClass != null) { if (EventTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_TRAINER; } else if (EventModelSequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } else if (SequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.SEQUENCE_TRAINER; } } try { ExtensionLoader.instantiateExtension(EventTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(EventModelSequenceTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(SequenceTrainer.class, algorithmValue); return TrainerType.SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } return null; }  static TrainerType getTrainerType(TrainingParameters trainParams); static SequenceTrainer getSequenceModelTrainer(TrainingParameters trainParams,
      Map<String, String> reportMap); static EventModelSequenceTrainer getEventModelSequenceTrainer(TrainingParameters trainParams,
      Map<String, String> reportMap); static EventTrainer getEventTrainer(TrainingParameters trainParams,
      Map<String, String> reportMap); static boolean isValid(TrainingParameters trainParams); }
TrainerFactory { public static TrainerType getTrainerType(TrainingParameters trainParams) { String algorithmValue = trainParams.getStringParameter(AbstractTrainer.ALGORITHM_PARAM,null); if (algorithmValue == null) { return TrainerType.EVENT_MODEL_TRAINER; } Class<?> trainerClass = BUILTIN_TRAINERS.get(algorithmValue); if (trainerClass != null) { if (EventTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_TRAINER; } else if (EventModelSequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } else if (SequenceTrainer.class.isAssignableFrom(trainerClass)) { return TrainerType.SEQUENCE_TRAINER; } } try { ExtensionLoader.instantiateExtension(EventTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(EventModelSequenceTrainer.class, algorithmValue); return TrainerType.EVENT_MODEL_SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } try { ExtensionLoader.instantiateExtension(SequenceTrainer.class, algorithmValue); return TrainerType.SEQUENCE_TRAINER; } catch (ExtensionNotLoadedException ignored) { } return null; }  static TrainerType getTrainerType(TrainingParameters trainParams); static SequenceTrainer getSequenceModelTrainer(TrainingParameters trainParams,
      Map<String, String> reportMap); static EventModelSequenceTrainer getEventModelSequenceTrainer(TrainingParameters trainParams,
      Map<String, String> reportMap); static EventTrainer getEventTrainer(TrainingParameters trainParams,
      Map<String, String> reportMap); static boolean isValid(TrainingParameters trainParams);  }