Ejemplo n.º 1
0
        // Matt Text Analytics Part 3
        public static void CallTextAnalyticsKeyPhrasesAPI()
        {
            try
            {
                // Get the file name
                Console.WriteLine("Please enter a some text to analyze:");
                var message = Console.ReadLine();

                var document = new MultiLanguageInput()
                {
                    Id       = Guid.NewGuid().ToString(),
                    Language = "en-US",
                    Text     = message
                };
                var documentList = new List <MultiLanguageInput>();
                documentList.Add(document);
                var query  = new TextAnalyticsQuery(Constants.TEXT_ANALYTICS_URL, Constants.TEXT_ANALYTICS_KEY, documentList.ToArray());
                var result = TextAnalyticsService.callTextAnalyticsKeyPhrasesAPI(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;
            }
        }