Beispiel #1
0
        public void TestWhisper()
        {
            var trans  = new WhisperTranslator();
            var result = trans.Whisper("The quick brown fox jumps over the lazy dogs.");

            Console.WriteLine(result);
        }
Beispiel #2
0
        public void TestTranslations()
        {
            var trans = new WhisperTranslator()
            {
                CookieJar = new CookieContainer()
            };

            Console.WriteLine(trans.TranslatePhrase("en", "fr", "The quick brown fox jumps over the lazy dog"));
            Console.WriteLine(trans.TranslatePhrase("en", "bn", "The quick brown fox jumps over the lazy dog"));
            Console.WriteLine(trans.TranslatePhrase("en", "ceb", "The quick brown fox jumps over the lazy dog"));
            Console.WriteLine(trans.TranslatePhrase("en", "zh-CN", "The quick brown fox jumps over the lazy dog"));
            Console.WriteLine(trans.TranslatePhrase("en", "cs", "The quick brown fox jumps over the lazy dog"));
            Console.WriteLine(trans.TranslatePhrase("en", "gl", "The quick brown fox jumps over the lazy dog"));
            Console.WriteLine(trans.TranslatePhrase("en", "ht", "The quick brown fox jumps over the lazy dog"));
            Console.WriteLine(trans.TranslatePhrase("en", "id", "The quick brown fox jumps over the lazy dog"));
        }
Beispiel #3
0
        public HttpResponseMessage GetDecision()
        {
            var question = Request.GetQueryNameValuePairs().Where(q => q.Key == "q").Select(q => q.Value).FirstOrDefault();

            if (question == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Bad Request"));
            }
            var translator  = new WhisperTranslator();
            var translation = translator.Whisper(question);
            var hash        = translation.GetHashCode();
            var yes         = hash % 2 == 0;

            return(Request.CreateResponse(HttpStatusCode.OK, new Decision()
            {
                IsYes = yes,
                Translation = translation
            }));
        }