コード例 #1
0
        public async Task AnalyzeSentimentBatchWithOpinionMiningTest()
        {
            TextAnalyticsClient client = GetClient();
            var documents = new List <TextDocumentInput>
            {
                new TextDocumentInput("1", "The park was clean and pretty. The bathrooms and restaurant were not clean.")
                {
                    Language = "en",
                },
                new TextDocumentInput("2", "The food and service is not good.")
                {
                    Language = "en",
                }
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents, options : new AnalyzeSentimentOptions()
            {
                IncludeOpinionMining = true
            });

            foreach (AnalyzeSentimentResult docs in results)
            {
                CheckAnalyzeSentimentProperties(docs.DocumentSentiment, opinionMining: true);
            }

            Assert.AreEqual("Mixed", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());
        }
コード例 #2
0
        public async Task AnalyzeSentimentBatchTest()
        {
            TextAnalyticsClient client = GetClient();
            var documents = new List <TextDocumentInput>
            {
                new TextDocumentInput("1", "Pike Place Market is my favorite Seattle attraction.  We had so much fun there.")
                {
                    Language = "en",
                },
                new TextDocumentInput("2", "Esta comida no me gusta. Siempre que la como me enfermo.")
                {
                    Language = "es",
                }
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents);

            foreach (AnalyzeSentimentResult docs in results)
            {
                CheckAnalyzeSentimentProperties(docs.DocumentSentiment);
            }

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());
        }
        public void AnalyzeSentimentBatchConvenience()
        {
            string endpoint        = Environment.GetEnvironmentVariable("TEXT_ANALYTICS_ENDPOINT");
            string subscriptionKey = Environment.GetEnvironmentVariable("TEXT_ANALYTICS_SUBSCRIPTION_KEY");

            var client = new TextAnalyticsClient(new Uri(endpoint), subscriptionKey);

            var inputs = new List <string>
            {
                "That was the best day of my life!",
                "This food is very bad.",
                "I'm not sure how I feel about this product.",
                "Pike place market is my favorite Seattle attraction.",
            };

            Debug.WriteLine($"Analyzing sentiment for inputs:");
            foreach (string input in inputs)
            {
                Debug.WriteLine($"    {input}");
            }

            #region Snippet:TextAnalyticsSample2AnalyzeSentimentConvenience
            AnalyzeSentimentResultCollection results = client.AnalyzeSentiment(inputs);
            #endregion

            Debug.WriteLine($"Predicted sentiments are:");
            foreach (AnalyzeSentimentResult result in results)
            {
                TextSentiment sentiment = result.DocumentSentiment;
                Debug.WriteLine($"Document sentiment is {sentiment.SentimentClass.ToString()}, with scores: ");
                Debug.WriteLine($"    Positive score: {sentiment.PositiveScore:0.00}.");
                Debug.WriteLine($"    Neutral score: {sentiment.NeutralScore:0.00}.");
                Debug.WriteLine($"    Negative score: {sentiment.NegativeScore:0.00}.");
            }
        }
コード例 #4
0
        public async Task AnalyzeSentimentBatchConvenienceTest()
        {
            TextAnalyticsClient client = GetClient();
            var inputs = new List <string>
            {
                "That was the best day of my life!. I had a lot of fun at the park.",
                "I'm not sure how I feel about this product. It is complicated."
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(inputs);

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());

            foreach (AnalyzeSentimentResult docs in results)
            {
                DocumentSentiment docSentiment = docs.DocumentSentiment;
                Assert.IsNotNull(docSentiment.ConfidenceScores.Positive);
                Assert.IsNotNull(docSentiment.ConfidenceScores.Neutral);
                Assert.IsNotNull(docSentiment.ConfidenceScores.Negative);

                foreach (var sentence in docSentiment.Sentences)
                {
                    Assert.IsNotNull(sentence.ConfidenceScores.Positive);
                    Assert.IsNotNull(sentence.ConfidenceScores.Neutral);
                    Assert.IsNotNull(sentence.ConfidenceScores.Negative);
                    Assert.IsNotNull(sentence.Offset);
                    Assert.IsNotNull(sentence.Length);
                }
            }
        }
コード例 #5
0
        public async Task AnalyzeSentimentBatchWithStatisticsTest()
        {
            TextAnalyticsClient client = GetClient();
            var inputs = new List <TextDocumentInput>
            {
                new TextDocumentInput("1", "Pike Place Market is my favorite Seattle attraction.  We had so much fun there.")
                {
                    Language = "en",
                },
                new TextDocumentInput("2", "Esta comida no me gusta. Siempre que la como me enfermo.")
                {
                    Language = "es",
                }
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(inputs, new TextAnalyticsRequestOptions { IncludeStatistics = true });

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());

            Assert.IsNotNull(results.Statistics.ValidDocumentCount);
            Assert.IsNotNull(results.Statistics.DocumentCount);
            Assert.IsNotNull(results.Statistics.TransactionCount);
            Assert.IsNotNull(results.Statistics.InvalidDocumentCount);
        }
        public async Task AnalyzeSentimentBatchConvenienceAsync()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            // Instantiate a client that will be used to call the service.
            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            var documents = new List <string>
            {
                "That was the best day of my life!",
                "This food is very bad.",
                "I'm not sure how I feel about this product.",
                "Pike place market is my favorite Seattle attraction.",
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents);

            int i = 0;

            Console.WriteLine($"Results of Azure Text Analytics \"Sentiment Analysis\" Model, version: \"{results.ModelVersion}\"");
            Console.WriteLine("");

            foreach (AnalyzeSentimentResult result in results)
            {
                Console.WriteLine($"On document {documents[i++]}");

                if (result.HasError)
                {
                    Console.WriteLine($"    Document error: {result.Error.ErrorCode}.");
                    Console.WriteLine($"    Message: {result.Error.Message}.");
                }
                else
                {
                    Console.WriteLine($"Document sentiment is {result.DocumentSentiment.Sentiment}, with confidence scores: ");
                    Console.WriteLine($"    Positive confidence score: {result.DocumentSentiment.ConfidenceScores.Positive}.");
                    Console.WriteLine($"    Neutral confidence score: {result.DocumentSentiment.ConfidenceScores.Neutral}.");
                    Console.WriteLine($"    Negative confidence score: {result.DocumentSentiment.ConfidenceScores.Negative}.");

                    Console.WriteLine($"    Sentence sentiment results:");

                    foreach (SentenceSentiment sentenceSentiment in result.DocumentSentiment.Sentences)
                    {
                        Console.WriteLine($"    For sentence: \"{sentenceSentiment.Text}\"");
                        Console.WriteLine($"    Offset (in UTF-16 code units): {sentenceSentiment.Offset}, Length (in UTF-16 code units): {sentenceSentiment.Length}");
                        Console.WriteLine($"    Sentiment is {sentenceSentiment.Sentiment}, with confidence scores: ");
                        Console.WriteLine($"        Positive confidence score: {sentenceSentiment.ConfidenceScores.Positive}.");
                        Console.WriteLine($"        Neutral confidence score: {sentenceSentiment.ConfidenceScores.Neutral}.");
                        Console.WriteLine($"        Negative confidence score: {sentenceSentiment.ConfidenceScores.Negative}.");
                    }

                    Console.WriteLine($"    Document statistics:");
                    Console.WriteLine($"        Character count (in Unicode graphemes): {result.Statistics.CharacterCount}");
                    Console.WriteLine($"        Transaction count: {result.Statistics.TransactionCount}");
                    Console.WriteLine("");
                }
            }
        }
コード例 #7
0
        static AnalyzeSentimentResultCollection SentimentAnalysisWithOpinionMining(TextAnalyticsClient client, List <string> documents)
        {
            AnalyzeSentimentResultCollection reviews = client.AnalyzeSentimentBatch(documents, options: new AnalyzeSentimentOptions()
            {
                IncludeOpinionMining = true
            });

            return(reviews);
        }
        public async Task AnalyzeSentimentWithOpinionMiningAsync()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            // Instantiate a client that will be used to call the service.
            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey), CreateSampleOptions());

            string reviewA = @"The food and service were unacceptable, but the concierge were nice.
                             After talking to them about the quality of the food and the process
                             to get room service they refunded the money we spent at the restaurant
                             and gave us a voucher for nearby restaurants.";

            string reviewB = @"The rooms were beautiful. The AC was good and quiet, which was key for
                            us as outside it was 100F and our baby was getting uncomfortable because of the heat.
                            The breakfast was good too with good options and good servicing times.
                            The thing we didn't like was that the toilet in our bathroom was smelly.
                            It could have been that the toilet was not cleaned before we arrived.
                            Either way it was very uncomfortable.
                            Once we notified the staff, they came and cleaned it and left candles.";

            string reviewC = @"Nice rooms! I had a great unobstructed view of the Microsoft campus
                            but bathrooms were old and the toilet was dirty when we arrived. 
                            It was close to bus stops and groceries stores. If you want to be close to
                            campus I will recommend it, otherwise, might be better to stay in a cleaner one.";

            var documents = new List <string>
            {
                reviewA,
                reviewB,
                reviewC
            };

            var options = new AnalyzeSentimentOptions()
            {
                IncludeOpinionMining = true
            };
            Response <AnalyzeSentimentResultCollection> response = await client.AnalyzeSentimentBatchAsync(documents, options : options);

            AnalyzeSentimentResultCollection reviews = response.Value;

            Dictionary <string, int> complaints = GetComplaint(reviews);

            var negativeAspect = complaints.Aggregate((l, r) => l.Value > r.Value ? l : r).Key;

            Console.WriteLine($"Alert! major complaint is *{negativeAspect}*");
            Console.WriteLine();
            Console.WriteLine("---All complaints:");
            foreach (KeyValuePair <string, int> complaint in complaints)
            {
                Console.WriteLine($"   {complaint.Key}, {complaint.Value}");
            }
        }
コード例 #9
0
        private static async Task SentimentAnalysisWithOpinionMiningExampleAsync(TextAnalyticsClient client)
        {
            WriteLine("****** Opinion mining ******");
            WriteLine();

            var documents = new List <string>
            {
                "The food and service were unacceptable, but the concierge were nice."
            };

            AnalyzeSentimentResultCollection reviews = await client.AnalyzeSentimentBatchAsync(documents, options : new AnalyzeSentimentOptions()
            {
                AdditionalSentimentAnalyses = AdditionalSentimentAnalyses.OpinionMining
            });

            foreach (AnalyzeSentimentResult review in reviews)
            {
                WriteLine($"Document sentiment: {review.DocumentSentiment.Sentiment}\n");
                WriteLine($"\tPositive score: {review.DocumentSentiment.ConfidenceScores.Positive:0.00}");
                WriteLine($"\tNegative score: {review.DocumentSentiment.ConfidenceScores.Negative:0.00}");
                WriteLine($"\tNeutral score: {review.DocumentSentiment.ConfidenceScores.Neutral:0.00}\n");

                foreach (SentenceSentiment sentence in review.DocumentSentiment.Sentences)
                {
                    WriteLine($"\tText: \"{sentence.Text}\"");
                    WriteLine($"\tSentence sentiment: {sentence.Sentiment}");
                    WriteLine($"\tSentence positive score: {sentence.ConfidenceScores.Positive:0.00}");
                    WriteLine($"\tSentence negative score: {sentence.ConfidenceScores.Negative:0.00}");
                    WriteLine($"\tSentence neutral score: {sentence.ConfidenceScores.Neutral:0.00}\n");

                    foreach (MinedOpinion minedOpinion in sentence.MinedOpinions)
                    {
                        WriteLine($"\tAspect: {minedOpinion.Aspect.Text}, Value: {minedOpinion.Aspect.Sentiment}");
                        WriteLine($"\tAspect positive score: {minedOpinion.Aspect.ConfidenceScores.Positive:0.00}");
                        WriteLine($"\tAspect negative score: {minedOpinion.Aspect.ConfidenceScores.Negative:0.00}");

                        foreach (OpinionSentiment opinion in minedOpinion.Opinions)
                        {
                            WriteLine($"\t\tRelated Opinion: {opinion.Text}, Value: {opinion.Sentiment}");
                            WriteLine($"\t\tRelated Opinion positive score: {opinion.ConfidenceScores.Positive:0.00}");
                            WriteLine($"\t\tRelated Opinion negative score: {opinion.ConfidenceScores.Negative:0.00}");
                        }
                    }
                }
                WriteLine($"\n");
            }

            WriteLine();
        }
コード例 #10
0
        public async Task AnalyzeSentimentBatchConvenienceWithLanguageAndCancellationTest()
        {
            TextAnalyticsClient client = GetClient();
            var documents = batchConvenienceDocuments;

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents, "en", cancellationToken : default);

            foreach (AnalyzeSentimentResult docs in results)
            {
                CheckAnalyzeSentimentProperties(docs.DocumentSentiment);
            }

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());
        }
コード例 #11
0
        public async Task AnalyzeSentimentBatchTest()
        {
            TextAnalyticsClient      client    = GetClient();
            List <TextDocumentInput> documents = batchDocuments;

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents);

            foreach (AnalyzeSentimentResult docs in results)
            {
                CheckAnalyzeSentimentProperties(docs.DocumentSentiment);
            }

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());
        }
コード例 #12
0
        public async Task AnalyzeSentimentBatchWithNullTextTest()
        {
            TextAnalyticsClient client = GetClient();
            var documents = new List <TextDocumentInput> {
                new TextDocumentInput("1", null)
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents);

            var exceptionMessage = "Cannot access result for document 1, due to error InvalidDocument: Document text is empty.";

            Assert.IsTrue(results[0].HasError);
            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => results[0].DocumentSentiment.GetType());

            Assert.AreEqual(exceptionMessage, ex.Message);
        }
コード例 #13
0
        public async Task AnalyzeSentimentBatchWithErrorTest()
        {
            TextAnalyticsClient client = GetClient();
            var inputs = new List <string>
            {
                "That was the best day of my life!",
                "",
                "I'm not sure how I feel about this product."
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(inputs);

            Assert.IsTrue(!results[0].HasError);
            Assert.IsTrue(!results[2].HasError);

            Assert.IsTrue(results[1].HasError);
            Assert.Throws <InvalidOperationException>(() => results[1].DocumentSentiment.GetType());
        }
コード例 #14
0
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            var client = new TextAnalyticsClient(endpoint, credentials);

            //Uncomment to run Classic Sentiment Analysis
            //DocumentSentiment documentSentiment = ClassicSentimentAnalysis(client, turnContext.Activity.Text);
            //foreach (var sentence in documentSentiment.Sentences)
            //{
            //    var replyText = $"Sentiment: \"{sentence.Sentiment}\"";
            //    replyText += $"\nPositive score: \"{sentence.ConfidenceScores.Positive:0.00}\"";
            //    replyText += $"\nNegative score: \"{sentence.ConfidenceScores.Negative:0.00}\"";
            //    replyText += $"\nNeutral score: \"{sentence.ConfidenceScores.Neutral:0.00}\"";
            //    await turnContext.SendActivityAsync(MessageFactory.Text(replyText, replyText), cancellationToken);
            //}

            //SentimentAnalysisWithOpinionMining
            AnalyzeSentimentResultCollection reviews = SentimentAnalysisWithOpinionMining(client, new List <string> {
                turnContext.Activity.Text
            });

            foreach (AnalyzeSentimentResult review in reviews)
            {
                foreach (SentenceSentiment sentence in review.DocumentSentiment.Sentences)
                {
                    var sentenceText = $"Sentence Sentiment: \"{sentence.Sentiment}\"";
                    sentenceText += $"\n\nPositive score: \"{sentence.ConfidenceScores.Positive:0.00}\"";
                    sentenceText += $"\n\nNegative score: \"{sentence.ConfidenceScores.Negative:0.00}\"";
                    sentenceText += $"\n\nNeutral score: \"{sentence.ConfidenceScores.Neutral:0.00}\"";
                    await turnContext.SendActivityAsync(MessageFactory.Text(sentenceText, sentenceText), cancellationToken);

                    foreach (SentenceOpinion sentenceOpinion in sentence.Opinions)
                    {
                        var sentenceOpinionText = $"\n\nTarget: {sentenceOpinion.Target.Text}";
                        foreach (AssessmentSentiment assessment in sentenceOpinion.Assessments)
                        {
                            sentenceOpinionText += $"\n\nRelated Assessment: {assessment.Text}, Value: {assessment.Sentiment}";
                            sentenceOpinionText += $"\n\nPositive score: {assessment.ConfidenceScores.Positive:0.00}";
                            sentenceOpinionText += $"\n\nNegative score: {assessment.ConfidenceScores.Negative:0.00}";
                            await turnContext.SendActivityAsync(MessageFactory.Text(sentenceOpinionText, sentenceOpinionText), cancellationToken);
                        }
                    }
                }
            }
        }
コード例 #15
0
        public async Task AnalyzeSentimentBatchConvenienceTest()
        {
            TextAnalyticsClient client = GetClient();
            var documents = new List <string>
            {
                "That was the best day of my life!. I had a lot of fun at the park.",
                "I'm not sure how I feel about this product. It is complicated."
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents);

            foreach (AnalyzeSentimentResult docs in results)
            {
                CheckAnalyzeSentimentProperties(docs.DocumentSentiment);
            }

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());
        }
コード例 #16
0
        public async Task AnalyzeSentimentBatchConvenienceWithStatisticsTest()
        {
            TextAnalyticsClient client = GetClient();
            var inputs = new List <string>
            {
                "That was the best day of my life!. I had a lot of fun at the park.",
                "I'm not sure how I feel about this product. It is complicated."
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(inputs, "en", new TextAnalyticsRequestOptions { IncludeStatistics = true });

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());

            Assert.IsNotNull(results.Statistics.ValidDocumentCount);
            Assert.IsNotNull(results.Statistics.DocumentCount);
            Assert.IsNotNull(results.Statistics.TransactionCount);
            Assert.IsNotNull(results.Statistics.InvalidDocumentCount);
        }
コード例 #17
0
        private static async Task <LinesSentiment[]> GetSentimentLines(string[] texts)
        {
            AnalyzeSentimentResultCollection documentSentiment = await client.AnalyzeSentimentBatchAsync(texts);

            int count = texts.Length;

            LinesSentiment[] sentiments = new LinesSentiment[count];

            for (int i = 0; i < count; i++)
            {
                LinesSentiment currentsentiment = new LinesSentiment(
                    text: texts[i],
                    emoji: ConvertSentimentToEmoji(documentSentiment[i].DocumentSentiment.Sentiment)
                    );
                sentiments[i] = currentsentiment;
            }

            return(sentiments);
        }
コード例 #18
0
        public async Task AnalyzeSentimentBatchWithStatisticsTest()
        {
            TextAnalyticsClient      client    = GetClient();
            List <TextDocumentInput> documents = batchDocuments;

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents, new TextAnalyticsRequestOptions { IncludeStatistics = true });

            foreach (AnalyzeSentimentResult docs in results)
            {
                CheckAnalyzeSentimentProperties(docs.DocumentSentiment);
            }

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());

            Assert.IsNotNull(results.Statistics.ValidDocumentCount);
            Assert.IsNotNull(results.Statistics.DocumentCount);
            Assert.IsNotNull(results.Statistics.TransactionCount);
            Assert.IsNotNull(results.Statistics.InvalidDocumentCount);
        }
        private Dictionary <string, int> GetComplaint(AnalyzeSentimentResultCollection reviews)
        {
            var complaints = new Dictionary <string, int>();

            foreach (AnalyzeSentimentResult review in reviews)
            {
                foreach (SentenceSentiment sentence in review.DocumentSentiment.Sentences)
                {
                    foreach (SentenceOpinion opinion in sentence.Opinions)
                    {
                        if (opinion.Target.Sentiment == TextSentiment.Negative)
                        {
                            complaints.TryGetValue(opinion.Target.Text, out var value);
                            complaints[opinion.Target.Text] = value + 1;
                        }
                    }
                }
            }
            return(complaints);
        }
コード例 #20
0
        public async Task AnalyzeSentimentBatchWithErrorTest()
        {
            TextAnalyticsClient client = GetClient();
            var inputs = new List <string>
            {
                "That was the best day of my life!",
                "",
                "I'm not sure how I feel about this product."
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(inputs);

            Assert.IsTrue(!results[0].HasError);
            Assert.IsTrue(!results[2].HasError);

            var exceptionMessage = "Cannot access result for document 1, due to error InvalidDocument: Document text is empty.";

            Assert.IsTrue(results[1].HasError);
            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => results[1].DocumentSentiment.GetType());

            Assert.AreEqual(exceptionMessage, ex.Message);
        }
コード例 #21
0
        public async Task AnalyzeSentimentBatchConvenienceWithOpinionMiningTest()
        {
            TextAnalyticsClient client = GetClient();
            var documents = new List <string>
            {
                "The park was clean and pretty. The bathrooms and restaurant were not clean.",
                "The food and service is not good."
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents, options : new AnalyzeSentimentOptions()
            {
                AdditionalSentimentAnalyses = AdditionalSentimentAnalyses.OpinionMining
            });

            foreach (AnalyzeSentimentResult docs in results)
            {
                CheckAnalyzeSentimentProperties(docs.DocumentSentiment, opinionMining: true);
            }

            Assert.AreEqual("Mixed", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());
        }
コード例 #22
0
        public async Task AnalyzeOperationAnalyzeSentimentWithOpinionMining()
        {
            TextAnalyticsClient client = GetClient();

            var documents = new List <string>
            {
                "The park was clean and pretty. The bathrooms and restaurant were not clean.",
            };

            TextAnalyticsActions batchActions = new TextAnalyticsActions()
            {
                AnalyzeSentimentActions = new List <AnalyzeSentimentAction>()
                {
                    new AnalyzeSentimentAction()
                    {
                        IncludeOpinionMining = true
                    }
                },
                DisplayName = "AnalyzeOperationWithOpinionMining",
            };

            AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(documents, batchActions);

            await operation.WaitForCompletionAsync();

            //Take the first page
            AnalyzeActionsResult resultCollection = operation.Value.ToEnumerableAsync().Result.FirstOrDefault();

            IReadOnlyCollection <AnalyzeSentimentActionResult> analyzeSentimentActionsResults = resultCollection.AnalyzeSentimentActionsResults;

            Assert.IsNotNull(analyzeSentimentActionsResults);

            AnalyzeSentimentResultCollection analyzeSentimentResult = analyzeSentimentActionsResults.FirstOrDefault().Result;

            Assert.AreEqual(1, analyzeSentimentResult.Count);

            Assert.AreEqual(TextSentiment.Mixed, analyzeSentimentResult[0].DocumentSentiment.Sentiment);
        }
コード例 #23
0
        public async Task AnalyzeSentimentBatchConvenienceWithStatisticsAndCancellationTest()
        {
            TextAnalyticsClient client = GetClient();
            var documents = batchConvenienceDocuments;

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(documents, options : new AnalyzeSentimentOptions()
            {
                IncludeStatistics = true
            }, cancellationToken : default);

            foreach (AnalyzeSentimentResult docs in results)
            {
                CheckAnalyzeSentimentProperties(docs.DocumentSentiment);
            }

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());

            Assert.IsNotNull(results.Statistics.ValidDocumentCount);
            Assert.IsNotNull(results.Statistics.DocumentCount);
            Assert.IsNotNull(results.Statistics.TransactionCount);
            Assert.IsNotNull(results.Statistics.InvalidDocumentCount);
        }
コード例 #24
0
        public async Task AnalyzeSentimentBatchTest()
        {
            TextAnalyticsClient client = GetClient();
            var inputs = new List <TextDocumentInput>
            {
                new TextDocumentInput("1", "Pike Place Market is my favorite Seattle attraction.  We had so much fun there.")
                {
                    Language = "en",
                },
                new TextDocumentInput("2", "Esta comida no me gusta. Siempre que la como me enfermo.")
                {
                    Language = "es",
                }
            };

            AnalyzeSentimentResultCollection results = await client.AnalyzeSentimentBatchAsync(inputs);

            Assert.AreEqual("Positive", results[0].DocumentSentiment.Sentiment.ToString());
            Assert.AreEqual("Negative", results[1].DocumentSentiment.Sentiment.ToString());

            foreach (AnalyzeSentimentResult docs in results)
            {
                DocumentSentiment docSentiment = docs.DocumentSentiment;
                Assert.IsNotNull(docSentiment.ConfidenceScores.Positive);
                Assert.IsNotNull(docSentiment.ConfidenceScores.Neutral);
                Assert.IsNotNull(docSentiment.ConfidenceScores.Negative);

                foreach (var sentence in docSentiment.Sentences)
                {
                    Assert.IsNotNull(sentence.ConfidenceScores.Positive);
                    Assert.IsNotNull(sentence.ConfidenceScores.Neutral);
                    Assert.IsNotNull(sentence.ConfidenceScores.Negative);
                    Assert.IsNotNull(sentence.Offset);
                    Assert.IsNotNull(sentence.Length);
                }
            }
        }
        public void AnalyzeSentimentWithOpinionMining()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            // Instantiate a client that will be used to call the service.
            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            #region Snippet:TAAnalyzeSentimentWithOpinionMining
            var documents = new List <string>
            {
                "The food and service were unacceptable, but the concierge were nice.",
                "The rooms were beautiful. The AC was good and quiet.",
                "The breakfast was good, but the toilet was smelly.",
                "Loved this hotel - good breakfast - nice shuttle service - clean rooms.",
                "I had a great unobstructed view of the Microsoft campus.",
                "Nice rooms but bathrooms were old and the toilet was dirty when we arrived.",
                "We changed rooms as the toilet smelled."
            };

            AnalyzeSentimentResultCollection reviews = client.AnalyzeSentimentBatch(documents, options: new AnalyzeSentimentOptions()
            {
                AdditionalSentimentAnalyses = AdditionalSentimentAnalyses.OpinionMining
            });

            Dictionary <string, int> complaints = GetComplaints(reviews);

            var negativeAspect = complaints.Aggregate((l, r) => l.Value > r.Value ? l : r).Key;
            Console.WriteLine($"Alert! major complaint is *{negativeAspect}*");
            Console.WriteLine();
            Console.WriteLine("---All complaints:");
            foreach (KeyValuePair <string, int> complaint in complaints)
            {
                Console.WriteLine($"   {complaint.Key}, {complaint.Value}");
            }
            #endregion
        }
        public void AnalyzeSentimentBatchConvenience()
        {
            string endpoint = Environment.GetEnvironmentVariable("TEXT_ANALYTICS_ENDPOINT");
            string apiKey   = Environment.GetEnvironmentVariable("TEXT_ANALYTICS_API_KEY");

            // Instantiate a client that will be used to call the service.
            var client = new TextAnalyticsClient(new Uri(endpoint), new TextAnalyticsApiKeyCredential(apiKey));

            var inputs = new List <string>
            {
                "That was the best day of my life!",
                "This food is very bad.",
                "I'm not sure how I feel about this product.",
                "Pike place market is my favorite Seattle attraction.",
            };

            Debug.WriteLine($"Analyzing sentiment for inputs:");
            foreach (string input in inputs)
            {
                Debug.WriteLine($"    {input}");
            }

            #region Snippet:TextAnalyticsSample2AnalyzeSentimentConvenience
            AnalyzeSentimentResultCollection results = client.AnalyzeSentimentBatch(inputs);
            #endregion

            Debug.WriteLine($"Predicted sentiments are:");
            foreach (AnalyzeSentimentResult result in results)
            {
                DocumentSentiment docSentiment = result.DocumentSentiment;
                Debug.WriteLine($"Document sentiment is {docSentiment.Sentiment}, with confidence scores: ");
                Debug.WriteLine($"    Positive confidence score: {docSentiment.ConfidenceScores.Positive}.");
                Debug.WriteLine($"    Neutral confidence score: {docSentiment.ConfidenceScores.Neutral}.");
                Debug.WriteLine($"    Negative confidence score: {docSentiment.ConfidenceScores.Negative}.");
            }
        }
コード例 #27
0
        public async Task AnalyzeOperationWithMultipleActions()
        {
            TextAnalyticsClient client = GetClient();

            var batchDocuments = new List <TextDocumentInput>
            {
                new TextDocumentInput("1", "Microsoft was founded by Bill Gates and Paul Allen.")
                {
                    Language = "en",
                },
                new TextDocumentInput("2", "Mi perro y mi gato tienen que ir al veterinario.")
                {
                    Language = "es",
                }
            };

            TextAnalyticsActions batchActions = new TextAnalyticsActions()
            {
                ExtractKeyPhrasesActions = new List <ExtractKeyPhrasesAction>()
                {
                    new ExtractKeyPhrasesAction()
                },
                RecognizeEntitiesActions = new List <RecognizeEntitiesAction>()
                {
                    new RecognizeEntitiesAction()
                },
                RecognizePiiEntitiesActions = new List <RecognizePiiEntitiesAction>()
                {
                    new RecognizePiiEntitiesAction()
                },
                RecognizeLinkedEntitiesActions = new List <RecognizeLinkedEntitiesAction>()
                {
                    new RecognizeLinkedEntitiesAction()
                },
                AnalyzeSentimentActions = new List <AnalyzeSentimentAction>()
                {
                    new AnalyzeSentimentAction()
                },
                DisplayName = "AnalyzeOperationWithMultipleTasks"
            };

            AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(batchDocuments, batchActions);

            Assert.AreEqual(0, operation.ActionsFailed);
            Assert.AreEqual(0, operation.ActionsSucceeded);
            Assert.AreEqual(0, operation.ActionsInProgress);
            Assert.AreEqual(0, operation.ActionsTotal);

            await operation.WaitForCompletionAsync();

            Assert.AreEqual(0, operation.ActionsFailed);
            Assert.AreEqual(5, operation.ActionsSucceeded);
            Assert.AreEqual(0, operation.ActionsInProgress);
            Assert.AreEqual(5, operation.ActionsTotal);
            Assert.AreNotEqual(new DateTimeOffset(), operation.CreatedOn);
            Assert.AreNotEqual(new DateTimeOffset(), operation.LastModified);
            Assert.AreNotEqual(new DateTimeOffset(), operation.ExpiresOn);

            //Take the first page
            AnalyzeActionsResult resultCollection = operation.Value.ToEnumerableAsync().Result.FirstOrDefault();

            IReadOnlyCollection <RecognizeEntitiesActionResult>       entitiesActionsResults         = resultCollection.RecognizeEntitiesActionsResults;
            IReadOnlyCollection <ExtractKeyPhrasesActionResult>       keyPhrasesActionsResults       = resultCollection.ExtractKeyPhrasesActionsResults;
            IReadOnlyCollection <RecognizePiiEntitiesActionResult>    piiActionsResults              = resultCollection.RecognizePiiEntitiesActionsResults;
            IReadOnlyCollection <RecognizeLinkedEntitiesActionResult> entityLinkingActionsResults    = resultCollection.RecognizeLinkedEntitiesActionsResults;
            IReadOnlyCollection <AnalyzeSentimentActionResult>        analyzeSentimentActionsResults = resultCollection.AnalyzeSentimentActionsResults;

            Assert.IsNotNull(keyPhrasesActionsResults);
            Assert.IsNotNull(entitiesActionsResults);
            Assert.IsNotNull(piiActionsResults);
            Assert.IsNotNull(entityLinkingActionsResults);
            Assert.AreEqual("AnalyzeOperationWithMultipleTasks", operation.DisplayName);

            // Keyphrases
            ExtractKeyPhrasesResultCollection keyPhrasesResults = keyPhrasesActionsResults.FirstOrDefault().Result;

            Assert.AreEqual(2, keyPhrasesResults.Count);

            var keyPhrasesListId1 = new List <string> {
                "Bill Gates", "Paul Allen", "Microsoft"
            };
            var keyPhrasesListId2 = new List <string> {
                "gato", "perro", "veterinario"
            };

            foreach (string keyphrase in keyPhrasesResults[0].KeyPhrases)
            {
                Assert.IsTrue(keyPhrasesListId1.Contains(keyphrase));
            }

            foreach (string keyphrase in keyPhrasesResults[1].KeyPhrases)
            {
                Assert.IsTrue(keyPhrasesListId2.Contains(keyphrase));
            }

            // Entities
            RecognizeEntitiesResultCollection entitiesResult = entitiesActionsResults.FirstOrDefault().Result;

            Assert.AreEqual(2, entitiesResult.Count);

            Assert.AreEqual(3, entitiesResult[0].Entities.Count);

            var entitiesList = new List <string> {
                "Bill Gates", "Microsoft", "Paul Allen"
            };

            foreach (CategorizedEntity entity in entitiesResult[0].Entities)
            {
                Assert.IsTrue(entitiesList.Contains(entity.Text));
                Assert.IsNotNull(entity.Category);
                Assert.IsNotNull(entity.Offset);
                Assert.IsNotNull(entity.ConfidenceScore);
            }

            // PII
            RecognizePiiEntitiesResultCollection piiResult = piiActionsResults.FirstOrDefault().Result;

            Assert.AreEqual(2, piiResult.Count);

            Assert.AreEqual(3, piiResult[0].Entities.Count);
            Assert.IsNotNull(piiResult[0].Id);
            Assert.IsNotNull(piiResult[0].Entities);
            Assert.IsNotNull(piiResult[0].Error);

            // Entity Linking
            RecognizeLinkedEntitiesResultCollection entityLinkingResult = entityLinkingActionsResults.FirstOrDefault().Result;

            Assert.AreEqual(2, entityLinkingResult.Count);

            Assert.AreEqual(3, entityLinkingResult[0].Entities.Count);
            Assert.IsNotNull(entityLinkingResult[0].Id);
            Assert.IsNotNull(entityLinkingResult[0].Entities);
            Assert.IsNotNull(entityLinkingResult[0].Error);

            foreach (LinkedEntity entity in entityLinkingResult[0].Entities)
            {
                if (entity.Name == "Bill Gates")
                {
                    Assert.AreEqual("Bill Gates", entity.DataSourceEntityId);
                    Assert.AreEqual("Wikipedia", entity.DataSource);
                }

                if (entity.Name == "Microsoft")
                {
                    Assert.AreEqual("Microsoft", entity.DataSourceEntityId);
                    Assert.AreEqual("Wikipedia", entity.DataSource);
                }
            }

            // Analyze sentiment
            AnalyzeSentimentResultCollection analyzeSentimentResult = analyzeSentimentActionsResults.FirstOrDefault().Result;

            Assert.AreEqual(2, analyzeSentimentResult.Count);

            Assert.AreEqual(TextSentiment.Neutral, analyzeSentimentResult[0].DocumentSentiment.Sentiment);
            Assert.AreEqual(TextSentiment.Neutral, analyzeSentimentResult[1].DocumentSentiment.Sentiment);
        }
コード例 #28
0
        public void AnalyzeSentimentBatch()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            // Instantiate a client that will be used to call the service.
            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            #region Snippet:TextAnalyticsSample2AnalyzeSentimentBatch
            var documents = new List <TextDocumentInput>
            {
                new TextDocumentInput("1", "That was the best day of my life!")
                {
                    Language = "en",
                },
                new TextDocumentInput("2", "This food is very bad. Everyone who ate with us got sick.")
                {
                    Language = "en",
                },
                new TextDocumentInput("3", "I'm not sure how I feel about this product.")
                {
                    Language = "en",
                },
                new TextDocumentInput("4", "Pike Place Market is my favorite Seattle attraction.  We had so much fun there.")
                {
                    Language = "en",
                }
            };

            AnalyzeSentimentResultCollection results = client.AnalyzeSentimentBatch(documents, new TextAnalyticsRequestOptions {
                IncludeStatistics = true
            });
            #endregion

            int i = 0;
            Debug.WriteLine($"Results of Azure Text Analytics \"Sentiment Analysis\" Model, version: \"{results.ModelVersion}\"");
            Debug.WriteLine("");

            foreach (AnalyzeSentimentResult result in results)
            {
                TextDocumentInput document = documents[i++];

                Debug.WriteLine($"On document (Id={document.Id}, Language=\"{document.Language}\", Text=\"{document.Text}\"):");

                if (result.HasError)
                {
                    Debug.WriteLine($"    Document error: {result.Error.Code}.");
                    Debug.WriteLine($"    Message: {result.Error.Message}.");
                }
                else
                {
                    Debug.WriteLine($"Document sentiment is {result.DocumentSentiment.Sentiment}, with confidence scores: ");
                    Debug.WriteLine($"    Positive confidence score: {result.DocumentSentiment.ConfidenceScores.Positive}.");
                    Debug.WriteLine($"    Neutral confidence score: {result.DocumentSentiment.ConfidenceScores.Neutral}.");
                    Debug.WriteLine($"    Negative confidence score: {result.DocumentSentiment.ConfidenceScores.Negative}.");

                    Debug.WriteLine($"    Sentence sentiment results:");

                    foreach (SentenceSentiment sentenceSentiment in result.DocumentSentiment.Sentences)
                    {
                        Debug.WriteLine($"    Sentiment is {sentenceSentiment.Sentiment}, with confidence scores: ");
                        Debug.WriteLine($"        Positive confidence score: {sentenceSentiment.ConfidenceScores.Positive}.");
                        Debug.WriteLine($"        Neutral confidence score: {sentenceSentiment.ConfidenceScores.Neutral}.");
                        Debug.WriteLine($"        Negative confidence score: {sentenceSentiment.ConfidenceScores.Negative}.");
                    }

                    Debug.WriteLine($"    Document statistics:");
                    Debug.WriteLine($"        Character count (in Unicode graphemes): {result.Statistics.GraphemeCount}");
                    Debug.WriteLine($"        Transaction count: {result.Statistics.TransactionCount}");
                    Debug.WriteLine("");
                }
            }

            Debug.WriteLine($"Batch operation statistics:");
            Debug.WriteLine($"    Document count: {results.Statistics.DocumentCount}");
            Debug.WriteLine($"    Valid document count: {results.Statistics.ValidDocumentCount}");
            Debug.WriteLine($"    Invalid document count: {results.Statistics.InvalidDocumentCount}");
            Debug.WriteLine($"    Transaction count: {results.Statistics.TransactionCount}");
            Debug.WriteLine("");
        }
コード例 #29
0
        public async Task AnalyzeSentimentBatchConvenienceAsync()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            // Instantiate a client that will be used to call the service.
            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey), CreateSampleOptions());

            string documentA = @"The food and service were unacceptable, but the concierge were nice.
                                After talking to them about the quality of the food and the process
                                to get room service they refunded the money we spent at the restaurant and
                                gave us a voucher for nearby restaurants.";

            string documentB = @"Nice rooms! I had a great unobstructed view of the Microsoft campus but bathrooms
                                were old and the toilet was dirty when we arrived. It was close to bus stops and
                                groceries stores.
                                If you want to be close to campus I will recommend it, otherwise, might be
                                better to stay in a cleaner one";

            string documentC = @"The rooms were beautiful. The AC was good and quiet, which was key for us as outside
                                it was 100F and our baby was getting uncomfortable because of the heat. The breakfast
                                was good too with good options and good servicing times.
                                The thing we didn't like was that the toilet in our bathroom was smelly.
                                It could have been that the toilet was not cleaned before we arrived.";

            string documentD = string.Empty;

            var documents = new List <string>
            {
                documentA,
                documentB,
                documentC,
                documentD
            };

            Response <AnalyzeSentimentResultCollection> response = await client.AnalyzeSentimentBatchAsync(documents);

            AnalyzeSentimentResultCollection sentimentPerDocuments = response.Value;

            int i = 0;

            Console.WriteLine($"Results of \"Sentiment Analysis\" Model, version: \"{sentimentPerDocuments.ModelVersion}\"");
            Console.WriteLine("");

            foreach (AnalyzeSentimentResult sentimentInDocument in sentimentPerDocuments)
            {
                Console.WriteLine($"On document with Text: \"{documents[i++]}\"");
                Console.WriteLine("");

                if (sentimentInDocument.HasError)
                {
                    Console.WriteLine("  Error!");
                    Console.WriteLine($"  Document error: {sentimentInDocument.Error.ErrorCode}.");
                    Console.WriteLine($"  Message: {sentimentInDocument.Error.Message}");
                }
                else
                {
                    Console.WriteLine($"Document sentiment is {sentimentInDocument.DocumentSentiment.Sentiment}, with confidence scores: ");
                    Console.WriteLine($"  Positive confidence score: {sentimentInDocument.DocumentSentiment.ConfidenceScores.Positive}.");
                    Console.WriteLine($"  Neutral confidence score: {sentimentInDocument.DocumentSentiment.ConfidenceScores.Neutral}.");
                    Console.WriteLine($"  Negative confidence score: {sentimentInDocument.DocumentSentiment.ConfidenceScores.Negative}.");
                    Console.WriteLine("");
                    Console.WriteLine($"  Sentence sentiment results:");

                    foreach (SentenceSentiment sentimentInSentence in sentimentInDocument.DocumentSentiment.Sentences)
                    {
                        Console.WriteLine($"  For sentence: \"{sentimentInSentence.Text}\"");
                        Console.WriteLine($"  Sentiment is {sentimentInSentence.Sentiment}, with confidence scores: ");
                        Console.WriteLine($"    Positive confidence score: {sentimentInSentence.ConfidenceScores.Positive}.");
                        Console.WriteLine($"    Neutral confidence score: {sentimentInSentence.ConfidenceScores.Neutral}.");
                        Console.WriteLine($"    Negative confidence score: {sentimentInSentence.ConfidenceScores.Negative}.");
                        Console.WriteLine("");
                    }
                }
                Console.WriteLine("");
            }
        }
コード例 #30
0
        public void AnalyzeSentimentBatchAdvanced()
        {
            string endpoint        = Environment.GetEnvironmentVariable("TEXT_ANALYTICS_ENDPOINT");
            string subscriptionKey = Environment.GetEnvironmentVariable("TEXT_ANALYTICS_SUBSCRIPTION_KEY");

            // Instantiate a client that will be used to call the service.
            var client = new TextAnalyticsClient(new Uri(endpoint), subscriptionKey);

            var inputs = new List <TextDocumentInput>
            {
                new TextDocumentInput("1", "That was the best day of my life!")
                {
                    Language = "en",
                },
                new TextDocumentInput("2", "This food is very bad. Everyone who ate with us got sick.")
                {
                    Language = "en",
                },
                new TextDocumentInput("3", "I'm not sure how I feel about this product.")
                {
                    Language = "en",
                },
                new TextDocumentInput("4", "Pike Place Market is my favorite Seattle attraction.  We had so much fun there.")
                {
                    Language = "en",
                }
            };

            AnalyzeSentimentResultCollection results = client.AnalyzeSentiment(inputs, new TextAnalyticsRequestOptions {
                IncludeStatistics = true
            });

            int i = 0;

            Debug.WriteLine($"Results of Azure Text Analytics \"Sentiment Analysis\" Model, version: \"{results.ModelVersion}\"");
            Debug.WriteLine("");

            foreach (var result in results)
            {
                var document = inputs[i++];

                if (result.ErrorMessage != default)
                {
                    Debug.WriteLine($"On document (Id={document.Id}, Language=\"{document.Language}\", Text=\"{document.Text}\"):");
                }
                else
                {
                    Debug.WriteLine($"Document sentiment is {result.DocumentSentiment.SentimentClass.ToString()}, with scores: ");
                    Debug.WriteLine($"    Positive score: {result.DocumentSentiment.PositiveScore:0.00}.");
                    Debug.WriteLine($"    Neutral score: {result.DocumentSentiment.NeutralScore:0.00}.");
                    Debug.WriteLine($"    Negative score: {result.DocumentSentiment.NegativeScore:0.00}.");

                    Debug.WriteLine($"    Sentence sentiment results:");

                    foreach (var sentenceSentiment in result.SentenceSentiments)
                    {
                        Debug.WriteLine($"    On sentence \"{document.Text.Substring(sentenceSentiment.Offset, sentenceSentiment.Length)}\"");

                        Debug.WriteLine($"    Sentiment is {sentenceSentiment.SentimentClass.ToString()}, with scores: ");
                        Debug.WriteLine($"        Positive score: {sentenceSentiment.PositiveScore:0.00}.");
                        Debug.WriteLine($"        Neutral score: {sentenceSentiment.NeutralScore:0.00}.");
                        Debug.WriteLine($"        Negative score: {sentenceSentiment.NegativeScore:0.00}.");
                    }

                    Debug.WriteLine($"    Document statistics:");
                    Debug.WriteLine($"        Character count: {result.Statistics.CharacterCount}");
                    Debug.WriteLine($"        Transaction count: {result.Statistics.TransactionCount}");
                    Debug.WriteLine("");
                }
            }

            Debug.WriteLine($"Batch operation statistics:");
            Debug.WriteLine($"    Document count: {results.Statistics.DocumentCount}");
            Debug.WriteLine($"    Valid document count: {results.Statistics.ValidDocumentCount}");
            Debug.WriteLine($"    Invalid document count: {results.Statistics.InvalidDocumentCount}");
            Debug.WriteLine($"    Transaction count: {results.Statistics.TransactionCount}");
            Debug.WriteLine("");
        }