예제 #1
0
        // Matt Text Analytics Part 1
        public static void CallTextAnalyticsLanguageAPI()
        {
            try
            {
                // Get the file name
                Console.WriteLine("Please enter a some text to analyze:");
                var message = Console.ReadLine();

                var document = new Input()
                {
                    Id   = Guid.NewGuid().ToString(),
                    Text = message
                };
                var documentList = new List <Input>();
                documentList.Add(document);
                var query  = new TextAnalyticsLanguageQuery(Constants.TEXT_ANALYTICS_URL, Constants.TEXT_ANALYTICS_KEY, documentList.ToArray());
                var result = TextAnalyticsService.callTextAnalyticsDetectLangAPI(query).Result;
                ExportJSON(JsonConvert.SerializeObject(result));
                Console.WriteLine("\nPress Enter to exit ");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                Console.ReadLine();
                throw;
            }
        }