/// <remarks> /// https://msdn.microsoft.com/en-us/library/Ff512411.aspx /// </remarks> private static void TestLanguageDetection(AuthenticationContext authenticationContext) { try { Console.WriteLine("Enter Text to detect language:"); string textToDetect = Console.ReadLine(); //textToDetect = "会場限定"; var languageDetector = new DetectorCommand(authenticationContext, textToDetect); languageDetector.Execute(); var detectedLanguage = languageDetector.Result; Console.WriteLine("Language Detected: {0}", detectedLanguage); Console.WriteLine("Press any key to continue..."); Console.ReadKey(true); } catch (WebException e) { ProcessWebException(e); Console.WriteLine("Press any key to continue..."); Console.ReadKey(true); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("Press any key to continue..."); Console.ReadKey(true); } }
private void btnSetCommand_Clicked(object sender, RoutedEventArgs e) { //byte[] temp = Encoding.ASCII.GetBytes(tbSetCommand.Text); //Logger.Info("===> SetCommand: {0} ---> bytes: {1}", tbSetCommand.Text, BitConverter.ToString(temp)); if (!StartedService) { return; } DetectorCommand msg = new DetectorCommand(tbSetCommand.Text); //this.mDetectorService.processInnerMessage(msg); }
/// <remarks> /// http://blogs.msdn.com/b/translation/p/gettingstarted2.aspx /// </remarks> private static void TestTranslating(AuthenticationContext authenticationContext) { Console.WriteLine("Enter Text to translate:"); string txtToTranslate = "안녕 세상아"; txtToTranslate = Console.ReadLine(); var languageDetector = new DetectorCommand(authenticationContext, txtToTranslate); languageDetector.Execute(); var detectedLanguage = languageDetector.Result; var translator = new Microsoft.Commands.TranslatorCommand(authenticationContext, new LanguageTranslatorArg(txtToTranslate, detectedLanguage)); translator.Execute(); var translatedText = translator.Result; Console.WriteLine("Detected Language : {0} and Translation is: {1}", detectedLanguage, translatedText); Console.WriteLine("Press any key to continue..."); Console.ReadKey(true); }