Example #1
0
        public async Task <TranslationResult> TranslateAsync(string engineId, IReadOnlyList <string> segment)
        {
            CheckDisposed();

            using (await _lock.ReaderLockAsync())
            {
                if (!await _engines.ExistsAsync(engineId))
                {
                    return(null);
                }
                EngineRuntime runtime = GetOrCreateRuntime(engineId);
                return(await runtime.TranslateAsync(segment));
            }
        }
Example #2
0
        public async Task TranslateAsync()
        {
            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();

                TranslationResult result = await runtime.TranslateAsync("esto es una prueba .".Split());

                Assert.That(result.TargetSegment, Is.EqualTo("this is a test .".Split()));
            }
        }