public POSModel( string languageCode, IMaxentModel posModel, Dictionary <string, string> manifestInfoEntries, POSTaggerFactory posFactory) : this(languageCode, posModel, POSTaggerME.DefaultBeamSize, manifestInfoEntries, posFactory) { }
public POSModel( string languageCode, ISequenceClassificationModel <string> posModel, Dictionary <string, string> manifestInfoEntries, POSTaggerFactory posFactory) : base(ComponentName, languageCode, manifestInfoEntries, posFactory) { if (posModel == null) { throw new ArgumentNullException("posModel"); } // TODO: This fails probably for the sequence model ... ?! artifactMap[EntryName] = posModel; }
/// <summary> /// Trains a Part of Speech model with the given parameters. /// </summary> /// <param name="languageCode">The language code.</param> /// <param name="samples">The data samples.</param> /// <param name="parameters">The machine learnable parameters.</param> /// <param name="factory">The sentence detector factory.</param> /// <param name="monitor"> /// A evaluation monitor that can be used to listen the messages during the training or it can cancel the training operation. /// This argument can be a <c>null</c> value. /// </param> /// <returns>The trained <see cref="POSModel"/> object.</returns> /// <exception cref="System.NotSupportedException">Trainer type is not supported.</exception> public static POSModel Train(string languageCode, IObjectStream<POSSample> samples, TrainingParameters parameters, POSTaggerFactory factory, Monitor monitor) { //int beamSize = trainParams.Get(Parameters.BeamSize, NameFinderME.DefaultBeamSize); var contextGenerator = factory.GetPOSContextGenerator(); var manifestInfoEntries = new Dictionary<string, string>(); var trainerType = TrainerFactory.GetTrainerType(parameters); switch (trainerType) { case TrainerType.EventModelTrainer: var es = new POSSampleEventStream(samples, contextGenerator); var trainer = TrainerFactory.GetEventTrainer(parameters, manifestInfoEntries, monitor); var eventModel = trainer.Train(es); return new POSModel(languageCode, eventModel, manifestInfoEntries, factory); case TrainerType.EventModelSequenceTrainer: var ss = new POSSampleSequenceStream(samples, contextGenerator); var trainer2 = TrainerFactory.GetEventModelSequenceTrainer(parameters, manifestInfoEntries, monitor); var seqModel = trainer2.Train(ss); return new POSModel(languageCode, seqModel, manifestInfoEntries, factory); case TrainerType.SequenceTrainer: var trainer3 = TrainerFactory.GetSequenceModelTrainer(parameters, manifestInfoEntries, monitor); // TODO: This will probably cause issue, since the feature generator uses the outcomes array var ss2 = new POSSampleSequenceStream(samples, contextGenerator); var seqPosModel = trainer3.Train(ss2); return new POSModel(languageCode, seqPosModel, manifestInfoEntries, factory); default: throw new NotSupportedException("Trainer type is not supported."); } }
/// <summary> /// Trains a Part of Speech model with the given parameters. /// </summary> /// <param name="languageCode">The language code.</param> /// <param name="samples">The data samples.</param> /// <param name="parameters">The machine learnable parameters.</param> /// <param name="factory">The sentence detector factory.</param> /// <returns>The trained <see cref="POSModel"/> object.</returns> /// <exception cref="System.NotSupportedException">Trainer type is not supported.</exception> public static POSModel Train(string languageCode, IObjectStream<POSSample> samples, TrainingParameters parameters, POSTaggerFactory factory) { return Train(languageCode, samples, parameters, factory, null); }
public POSModel(string languageCode, IMaxentModel posModel, int beamSize, Dictionary <string, string> manifestInfoEntries, POSTaggerFactory posFactory) : base(ComponentName, languageCode, manifestInfoEntries, posFactory) { // TODO: fix the beamSize parameter or use it ! if (posModel == null) { throw new InvalidOperationException("The maxentPosModel param must not be null!"); } artifactMap[EntryName] = posModel; CheckArtifactMap(); }
public POSModel( string languageCode, ISequenceClassificationModel<string> posModel, Dictionary<string, string> manifestInfoEntries, POSTaggerFactory posFactory) : base(ComponentName, languageCode, manifestInfoEntries, posFactory) { if (posModel == null) throw new ArgumentNullException("posModel"); // TODO: This fails probably for the sequence model ... ?! artifactMap[EntryName] = posModel; }
public POSModel(string languageCode, IMaxentModel posModel, int beamSize, Dictionary<string, string> manifestInfoEntries, POSTaggerFactory posFactory) : base(ComponentName, languageCode, manifestInfoEntries, posFactory) { if (posModel == null) throw new InvalidOperationException("The maxentPosModel param must not be null!"); Manifest[Parameters.BeamSize] = beamSize.ToString(CultureInfo.InvariantCulture); artifactMap[EntryName] = posModel; CheckArtifactMap(); }
public POSModel( string languageCode, IMaxentModel posModel, Dictionary<string, string> manifestInfoEntries, POSTaggerFactory posFactory) : this(languageCode, posModel, POSTaggerME.DefaultBeamSize, manifestInfoEntries, posFactory) { }
/// <summary> /// Trains a Part of Speech model with the given parameters. /// </summary> /// <param name="languageCode">The language code.</param> /// <param name="samples">The data samples.</param> /// <param name="parameters">The machine learnable parameters.</param> /// <param name="factory">The sentence detector factory.</param> /// <param name="monitor"> /// A evaluation monitor that can be used to listen the messages during the training or it can cancel the training operation. /// This argument can be a <c>null</c> value. /// </param> /// <returns>The trained <see cref="POSModel"/> object.</returns> /// <exception cref="System.NotSupportedException">Trainer type is not supported.</exception> public static POSModel Train(string languageCode, IObjectStream <POSSample> samples, TrainingParameters parameters, POSTaggerFactory factory, Monitor monitor) { //int beamSize = trainParams.Get(Parameters.BeamSize, NameFinderME.DefaultBeamSize); var contextGenerator = factory.GetPOSContextGenerator(); var manifestInfoEntries = new Dictionary <string, string>(); var trainerType = TrainerFactory.GetTrainerType(parameters); IMaxentModel posModel = null; ML.Model.ISequenceClassificationModel <string> seqPosModel = null; switch (trainerType) { case TrainerType.EventModelTrainer: var es = new POSSampleEventStream(samples, contextGenerator); var trainer = TrainerFactory.GetEventTrainer(parameters, manifestInfoEntries, monitor); posModel = trainer.Train(es); break; case TrainerType.EventModelSequenceTrainer: var ss = new POSSampleSequenceStream(samples, contextGenerator); var trainer2 = TrainerFactory.GetEventModelSequenceTrainer(parameters, manifestInfoEntries, monitor); posModel = trainer2.Train(ss); break; case TrainerType.SequenceTrainer: var trainer3 = TrainerFactory.GetSequenceModelTrainer(parameters, manifestInfoEntries, monitor); // TODO: This will probably cause issue, since the feature generator uses the outcomes array var ss2 = new POSSampleSequenceStream(samples, contextGenerator); seqPosModel = trainer3.Train(ss2); break; default: throw new NotSupportedException("Trainer type is not supported."); } if (posModel != null) { return(new POSModel(languageCode, posModel, manifestInfoEntries, factory)); } return(new POSModel(languageCode, seqPosModel, manifestInfoEntries, factory)); }
/// <summary> /// Trains a Part of Speech model with the given parameters. /// </summary> /// <param name="languageCode">The language code.</param> /// <param name="samples">The data samples.</param> /// <param name="parameters">The machine learnable parameters.</param> /// <param name="factory">The sentence detector factory.</param> /// <returns>The trained <see cref="POSModel"/> object.</returns> /// <exception cref="System.NotSupportedException">Trainer type is not supported.</exception> public static POSModel Train(string languageCode, IObjectStream <POSSample> samples, TrainingParameters parameters, POSTaggerFactory factory) { return(Train(languageCode, samples, parameters, factory, null)); }
public POSModel(string languageCode, IMaxentModel posModel, int beamSize, Dictionary <string, string> manifestInfoEntries, POSTaggerFactory posFactory) : base(ComponentName, languageCode, manifestInfoEntries, posFactory) { if (posModel == null) { throw new InvalidOperationException("The maxentPosModel param must not be null!"); } Manifest[Parameters.BeamSize] = beamSize.ToString(CultureInfo.InvariantCulture); artifactMap[EntryName] = posModel; CheckArtifactMap(); }