public void TrainSegment_TranslationCorrect() { using (var smtModel = new ThotSmtModel(TestHelpers.ToyCorpusConfigFileName)) using (ISmtEngine engine = smtModel.CreateEngine()) { TranslationResult result = engine.Translate("esto es una prueba .".Split()); Assert.That(result.TargetSegment, Is.EqualTo("esto is a prueba .".Split())); engine.TrainSegment("esto es una prueba .".Split(), "this is a test .".Split()); result = engine.Translate("esto es una prueba .".Split()); Assert.That(result.TargetSegment, Is.EqualTo("this is a test .".Split())); } }
public void TrainSegment_AlignmentSpecified_TranslationCorrect() { using (var smtModel = new ThotSmtModel(TestHelpers.ToyCorpusConfigFileName)) using (ISmtEngine engine = smtModel.CreateEngine()) { TranslationResult result = engine.Translate("maria no dio una bofetada a la bruja verde .".Split()); Assert.That(result.TargetSegment, Is.EqualTo("maria no dio a bofetada to bruja verde .".Split())); var matrix = new WordAlignmentMatrix(10, 7, AlignmentType.Unknown); SetAligned(matrix, 1, 1); SetAligned(matrix, 2, 2); SetAligned(matrix, 3, 2); SetAligned(matrix, 4, 2); SetSourceNotAligned(matrix, 5); SetAligned(matrix, 8, 4); engine.TrainSegment("maria no dio una bofetada a la bruja verde .".Split(), "mary didn't slap the green witch .".Split(), matrix); result = engine.Translate("maria es una bruja .".Split()); Assert.That(result.TargetSegment, Is.EqualTo("mary is a witch .".Split())); } }
private void TrainTuneCorpus(string trainTMPrefix, string trainLMPrefix, IReadOnlyList <IReadOnlyList <string> > tuneSourceCorpus, IReadOnlyList <IReadOnlyList <string> > tuneTargetCorpus, ThotTrainProgressReporter reporter) { reporter.Step("Finalizing", TrainingStepCount - 1); if (tuneSourceCorpus.Count == 0) { return; } ThotSmtParameters parameters = Parameters.Clone(); parameters.TranslationModelFileNamePrefix = trainTMPrefix; parameters.LanguageModelFileNamePrefix = trainLMPrefix; using (var smtModel = new ThotSmtModel(parameters)) using (ISmtEngine engine = smtModel.CreateEngine()) { for (int i = 0; i < tuneSourceCorpus.Count; i++) { engine.TrainSegment(tuneSourceCorpus[i], tuneTargetCorpus[i]); } } }
private void TrainTuneCorpus(string trainTMPrefix, string trainLMPrefix, IReadOnlyList <IReadOnlyList <string> > tuneSourceCorpus, IReadOnlyList <IReadOnlyList <string> > tuneTargetCorpus, IProgress <ProgressStatus> progress) { if (tuneSourceCorpus.Count == 0) { return; } ThotSmtParameters parameters = Parameters.Clone(); parameters.TranslationModelFileNamePrefix = trainTMPrefix; parameters.LanguageModelFileNamePrefix = trainLMPrefix; using (var smtModel = new ThotSmtModel(parameters)) using (ISmtEngine engine = smtModel.CreateEngine()) { for (int i = 0; i < tuneSourceCorpus.Count; i++) { progress.Report(new ProgressStatus(i, tuneSourceCorpus.Count)); engine.TrainSegment(tuneSourceCorpus[i], tuneTargetCorpus[i]); } progress.Report(new ProgressStatus(1.0)); } }