예제 #1
0
        public async Task <bool> TrainSegmentAsync(string engineId, IReadOnlyList <string> sourceSegment,
                                                   IReadOnlyList <string> targetSegment)
        {
            CheckDisposed();

            using (await _lock.ReaderLockAsync())
            {
                if (!await _engines.ExistsAsync(engineId))
                {
                    return(false);
                }
                EngineRuntime runtime = GetOrCreateRuntime(engineId);
                await runtime.TrainSegmentPairAsync(sourceSegment, targetSegment);

                return(true);
            }
        }
예제 #2
0
        public async Task CommitAsync_LoadedActive()
        {
            using (var env = new EngineServiceTestEnvironment())
            {
                env.EngineOptions.InactiveEngineTimeout = TimeSpan.FromHours(1);
                env.CreateEngineService();
                Engine engine = await env.CreateEngineAsync();

                EngineRuntime runtime = env.GetRuntime(engine.Id);
                await runtime.InitNewAsync();

                await runtime.TrainSegmentPairAsync("esto es una prueba .".Split(), "this is a test .".Split());

                await runtime.CommitAsync();

                env.SmtModel.Received().Save();
                Assert.That(runtime.IsLoaded, Is.True);
            }
        }