public async Task ExtractKeyPhrasesAsync()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            string document = @"My cat might need to see a veterinarian. It has been sneezing more than normal, and although my 
                                little sister thinks it is funny, I am worried it has the cold that I got last week.
                                We are going to call tomorrow and try to schedule an appointment for this week. Hopefully it
                                will be covered by the cat's insurance.
                                It might be good to not let it sleep in my room for a while.";

            try
            {
                Response <KeyPhraseCollection> response = await client.ExtractKeyPhrasesAsync(document);

                KeyPhraseCollection keyPhrases = response.Value;

                Console.WriteLine($"Extracted {keyPhrases.Count} key phrases:");
                foreach (string keyPhrase in keyPhrases)
                {
                    Console.WriteLine($"  {keyPhrase}");
                }
            }
            catch (RequestFailedException exception)
            {
                Console.WriteLine($"Error Code: {exception.ErrorCode}");
                Console.WriteLine($"Message: {exception.Message}");
            }
        }
        public async Task ExtractKeyPhrasesWithLanguageTest()
        {
            TextAnalyticsClient client = GetClient();
            string document            = singleSpanish;

            KeyPhraseCollection keyPhrases = await client.ExtractKeyPhrasesAsync(document, "es");

            Assert.AreEqual(2, keyPhrases.Count);
        }
Esempio n. 3
0
        public async Task ExtractKeyPhrasesWithLanguageTest()
        {
            TextAnalyticsClient client = GetClient();
            string document            = "Mi perro está en el veterinario";

            KeyPhraseCollection keyPhrases = await client.ExtractKeyPhrasesAsync(document, "es");

            Assert.AreEqual(2, keyPhrases.Count);
        }
        public async Task ExtractKeyPhrasesWithLanguageTest()
        {
            TextAnalyticsClient client = GetClient();
            string input = "Mi perro está en el veterinario";

            Response <IReadOnlyCollection <string> > response = await client.ExtractKeyPhrasesAsync(input, "es");

            IReadOnlyCollection <string> keyPhrases = response.Value;

            Assert.AreEqual(2, keyPhrases.Count);
        }
        public async Task ExtractKeyPhrasesTest()
        {
            TextAnalyticsClient client = GetClient();
            string document            = singleEnglish;

            KeyPhraseCollection keyPhrases = await client.ExtractKeyPhrasesAsync(document);

            Assert.AreEqual(2, keyPhrases.Count);
            Assert.IsTrue(keyPhrases.Contains("cat"));
            Assert.IsTrue(keyPhrases.Contains("veterinarian"));
        }
Esempio n. 6
0
        public async Task ExtractKeyPhrasesWithWarningTest()
        {
            TextAnalyticsClient client = GetClient();
            string document            = "Anthony runs his own personal training business so thisisaverylongtokenwhichwillbetruncatedtoshowushowwarningsareemittedintheapi";

            KeyPhraseCollection keyPhrases = await client.ExtractKeyPhrasesAsync(document, "es");

            ValidateInDocumenResult(keyPhrases, 1);

            Assert.AreEqual(TextAnalyticsWarningCode.LongWordsInDocument, keyPhrases.Warnings.FirstOrDefault().WarningCode.ToString());
        }
Esempio n. 7
0
        public async Task ExtractKeyPhrasesWithLanguageTest()
        {
            TextAnalyticsClient client = GetClient();
            string document            = SingleSpanish;

            KeyPhraseCollection keyPhrases = await client.ExtractKeyPhrasesAsync(document, "es");

            ValidateInDocumenResult(keyPhrases, 2);

            Assert.IsTrue(keyPhrases.Contains("perro"));
            Assert.IsTrue(keyPhrases.Contains("veterinario"));
        }
Esempio n. 8
0
        public async Task ExtractKeyPhrasesTest()
        {
            TextAnalyticsClient client = GetClient();
            string document            = SingleEnglish;

            KeyPhraseCollection keyPhrases = await client.ExtractKeyPhrasesAsync(document);

            ValidateInDocumenResult(keyPhrases, 2);

            Assert.IsTrue(keyPhrases.Contains("cat"));
            Assert.IsTrue(keyPhrases.Contains("veterinarian"));
        }
        public async Task ExtractKeyPhrasesTest()
        {
            TextAnalyticsClient client = GetClient();
            string input = "My cat might need to see a veterinarian.";

            Response <IReadOnlyCollection <string> > response = await client.ExtractKeyPhrasesAsync(input);

            IReadOnlyCollection <string> keyPhrases = response.Value;

            Assert.AreEqual(2, keyPhrases.Count);
            Assert.IsTrue(keyPhrases.Contains("cat"));
            Assert.IsTrue(keyPhrases.Contains("veterinarian"));
        }
Esempio n. 10
0
        private static async Task <string[]> TextAnalisis(string text)
        {
            var KeyPhrases = await client.ExtractKeyPhrasesAsync(text);

            List <string> tags = new List <string>();

            foreach (string key in KeyPhrases.Value)
            {
                tags.Add(key);
            }

            return(tags.ToArray());
        }
Esempio n. 11
0
        static async Task Analyze(TextAnalyticsClient client, string text)
        {
            DocumentSentiment sentiment = await client.AnalyzeSentimentAsync(text);

            Console.WriteLine($"Sentiment: {sentiment.ConfidenceScores.Positive}:{sentiment.ConfidenceScores.Neutral}:{sentiment.ConfidenceScores.Negative} - {sentiment.Sentiment}");

            var keywords = await client.ExtractKeyPhrasesAsync(text);

            // Printing key phrases
            Console.WriteLine("Key phrases:");

            foreach (string keyphrase in keywords.Value)
            {
                Console.WriteLine($"\t{keyphrase}");
            }
        }
Esempio n. 12
0
        public async Task ExtractKeyPhrasesAsync()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            string document = "My cat might need to see a veterinarian.";

            KeyPhraseCollection keyPhrases = await client.ExtractKeyPhrasesAsync(document);

            Console.WriteLine($"Extracted {keyPhrases.Count} key phrases:");
            foreach (string keyPhrase in keyPhrases)
            {
                Console.WriteLine(keyPhrase);
            }
        }
        public async Task ExtractKeyPhrasesAsync()
        {
            string endpoint = Environment.GetEnvironmentVariable("TEXT_ANALYTICS_ENDPOINT");
            string apiKey   = Environment.GetEnvironmentVariable("TEXT_ANALYTICS_API_KEY");

            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            string document = "My cat might need to see a veterinarian.";

            Response <IReadOnlyCollection <string> > keyPhrases = await client.ExtractKeyPhrasesAsync(document);

            Console.WriteLine($"Extracted {keyPhrases.Value.Count} key phrases:");
            foreach (string keyPhrase in keyPhrases.Value)
            {
                Console.WriteLine(keyPhrase);
            }
        }
Esempio n. 14
0
        private static async Task KeyPhraseExtractionExampleAsync(TextAnalyticsClient client)
        {
            WriteLine("****** Key phrase extraction ******");
            WriteLine();

            var document = "My cat might need to see a veterinarian.";

            WriteLine($"Document: {document}");

            var response = await client.ExtractKeyPhrasesAsync(document);

            // Printing key phrases
            Console.WriteLine("Key phrases:");

            foreach (string keyphrase in response.Value)
            {
                Console.WriteLine($"\t{keyphrase}");
            }

            WriteLine();
        }
Esempio n. 15
0
        public async Task <KeyPhraseCollection> ExtractKeyPhrasesAsync(string document, CancellationToken cancellationToken = default)
        {
            var result = await _client.ExtractKeyPhrasesAsync(document, "en", cancellationToken : cancellationToken).ConfigureAwait(false);

            return(result.Value);
        }
        public async Task <KeyPhraseCollection> ExtractKeyPhrasesAsync(string text, string language = "en")
        {
            var result = await client.ExtractKeyPhrasesAsync(text, language);

            return(result.Value);
        }