Exemple #1
0
        public void AnalyzeConversationOrchestrationPredictionLuis()
        {
            ConversationAnalysisClient client = Client;

            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "Book me flight from London to Paris",
                TestEnvironment.OrchestrationProject);

            OrchestratorPrediction orchestratorPrediction = response.Value.Prediction as OrchestratorPrediction;

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionLuis
            string             respondingProjectName = orchestratorPrediction.TopIntent;
            TargetIntentResult targetIntentResult    = orchestratorPrediction.Intents[respondingProjectName];

            if (targetIntentResult.TargetKind == TargetKind.Luis)
            {
                LuisTargetIntentResult luisTargetIntentResult = targetIntentResult as LuisTargetIntentResult;
                BinaryData             luisResponse           = luisTargetIntentResult.Result;

                Console.WriteLine($"LUIS Response: {luisResponse.ToString()}");
            }
            #endregion

            Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.Luis));
            Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("FlightBooking"));
        }
Exemple #2
0
        public async Task AnalyzeConversationOrchestrationPredictionQuestionAnsweringAsync()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionAsync
            string projectName    = "DomainOrchestrator";
            string deploymentName = "production";
#if !SNIPPET
            projectName    = TestEnvironment.OrchestrationProjectName;
            deploymentName = TestEnvironment.OrchestrationDeploymentName;
#endif

            var data = new
            {
                analysisInput = new
                {
                    conversationItem = new
                    {
                        text          = "How are you?",
                        id            = "1",
                        participantId = "1",
                    }
                },
                parameters = new
                {
                    projectName,
                    deploymentName,

                    // Use Utf16CodeUnit for strings in .NET.
                    stringIndexType = "Utf16CodeUnit",
                },
                kind = "Conversation",
            };

            Response response = await client.AnalyzeConversationAsync(RequestContent.Create(data));

            using JsonDocument result = await JsonDocument.ParseAsync(response.ContentStream);

            JsonElement conversationalTaskResult = result.RootElement;
            JsonElement orchestrationPrediction  = conversationalTaskResult.GetProperty("result").GetProperty("prediction");
            #endregion

            string      respondingProjectName = orchestrationPrediction.GetProperty("topIntent").GetString();
            JsonElement targetIntentResult    = orchestrationPrediction.GetProperty("intents").GetProperty(respondingProjectName);

            if (targetIntentResult.GetProperty("targetProjectKind").GetString() == "QuestionAnswering")
            {
                Console.WriteLine($"Top intent: {respondingProjectName}");

                JsonElement questionAnsweringResponse = targetIntentResult.GetProperty("result");
                Console.WriteLine($"Question Answering Response:");
                foreach (JsonElement answer in questionAnsweringResponse.GetProperty("answers").EnumerateArray())
                {
                    Console.WriteLine(answer.GetProperty("answer").GetString());
                }
            }

            Assert.That(targetIntentResult.GetProperty("targetProjectKind").GetString(), Is.EqualTo("QuestionAnswering"));
            Assert.That(respondingProjectName, Is.EqualTo("ChitChat-QnA"));
        }
        public async Task AnalyzeConversationWithLanguageAsync()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationWithLanguageAsync

#if SNIPPET
            AnalyzeConversationOptions options = new AnalyzeConversationOptions(
                "Menu",
                "production",
                "Tendremos 2 platos de nigiri de salmón braseado.")
            {
                Language = "es"
            };
            Response <AnalyzeConversationResult> response = await client.AnalyzeConversationAsync(options);
#else
            AnalyzeConversationOptions options = new AnalyzeConversationOptions(
                TestEnvironment.ProjectName,
                TestEnvironment.DeploymentName,
                "Tendremos 2 platos de nigiri de salmón braseado.")
            {
                Language = "es"
            };
            Response <AnalyzeConversationResult> response = await client.AnalyzeConversationAsync(options);
#endif

            Console.WriteLine($"Top intent: {response.Value.Prediction.TopIntent}");
            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(response.Value.Prediction.TopIntent, Is.EqualTo("Order"));
        }
Exemple #4
0
        public void AnalyzeConversationWithOptions()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationWithOptions

#if SNIPPET
            AnalyzeConversationOptions options = new AnalyzeConversationOptions(
                "Menu",
                "production",
                "We'll have 2 plates of seared salmon nigiri.");
            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(options);
#else
            AnalyzeConversationOptions options = new AnalyzeConversationOptions(
                TestEnvironment.ProjectName,
                TestEnvironment.DeploymentName,
                "We'll have 2 plates of seared salmon nigiri.");
            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(options);
#endif

            Console.WriteLine($"Top intent: {response.Value.Prediction.TopIntent}");

            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(response.Value.Prediction.TopIntent, Is.EqualTo("Order"));
        }
Exemple #5
0
        public void AnalyzeConversationWithLanguage()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationWithLanguage

#if SNIPPET
            ConversationsProject       conversationsProject = new ConversationsProject("Menu", "production");
            AnalyzeConversationOptions options = new AnalyzeConversationOptions()
            {
                Language = "es"
            };
            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "Tendremos 2 platos de nigiri de salmón braseado.",
                conversationsProject,
                options);
#else
            AnalyzeConversationOptions options = new AnalyzeConversationOptions()
            {
                Language = "es"
            };
            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "Tendremos 2 platos de nigiri de salmón braseado.",
                TestEnvironment.Project,
                options);
#endif

            Console.WriteLine($"Top intent: {response.Value.Prediction.TopIntent}");

            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(response.Value.Prediction.TopIntent, Is.EqualTo("Order"));
        }
        public AnalyzeConversationsProvider(string locale, string subscriptionKey, string region, ILogger log)
        {
            ConversationAnalysisClient = new ConversationAnalysisClient(new Uri($"https://{region}.api.cognitive.microsoft.com"), new AzureKeyCredential(subscriptionKey));

            Locale = locale;
            Log    = log;
        }
Exemple #7
0
        public async Task AnalyzeConversationOrchestrationPredictionQuestionAnsweringAsync()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionAsync
#if SNIPPET
            ConversationsProject orchestrationProject     = new ConversationsProject("DomainOrchestrator", "production");
            Response <AnalyzeConversationResult> response = await client.AnalyzeConversationAsync(
                "How are you?",
                orchestrationProject);
#else
            Response <AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync(
                "How are you?",
                TestEnvironment.OrchestrationProject);
#endif
            CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
            var orchestratorPrediction = customConversationalTaskResult.Result.Prediction as OrchestratorPrediction;
            #endregion

            string             respondingProjectName = orchestratorPrediction.TopIntent;
            TargetIntentResult targetIntentResult    = orchestratorPrediction.Intents[respondingProjectName];

            if (targetIntentResult.TargetProjectKind == TargetProjectKind.QuestionAnswering)
            {
                Console.WriteLine($"Top intent: {respondingProjectName}");

                QuestionAnsweringTargetIntentResult qnaTargetIntentResult = targetIntentResult as QuestionAnsweringTargetIntentResult;

                BinaryData questionAnsweringResponse = qnaTargetIntentResult.Result;
                Console.WriteLine($"Qustion Answering Response: {questionAnsweringResponse.ToString()}");
            }
            Assert.That(targetIntentResult.TargetProjectKind, Is.EqualTo(TargetProjectKind.QuestionAnswering));
            Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("ChitChat-QnA"));
        }
Exemple #8
0
        public async Task AnalyzeConversationOrchestrationPredictionLuisAsync()
        {
            ConversationAnalysisClient client = Client;

            Response <AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync(
                "Reserve a table for 2 at the Italian restaurant.",
                TestEnvironment.OrchestrationProject);

            CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
            var orchestratorPrediction = customConversationalTaskResult.Results.Prediction as OrchestratorPrediction;

            string             respondingProjectName = orchestratorPrediction.TopIntent;
            TargetIntentResult targetIntentResult    = orchestratorPrediction.Intents[respondingProjectName];

            if (targetIntentResult.TargetKind == TargetKind.Luis)
            {
                LuisTargetIntentResult luisTargetIntentResult = targetIntentResult as LuisTargetIntentResult;
                BinaryData             luisResponse           = luisTargetIntentResult.Result;

                Console.WriteLine($"LUIS Response: {luisResponse.ToString()}");
            }

            Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.Luis));
            Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("RestaurantIntent"));
        }
Exemple #9
0
        public async Task AnalyzeConversationAsync()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationAsync

#if SNIPPET
            ConversationsProject conversationsProject = new ConversationsProject("Menu", "production");

            Response <AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync(
                "Send an email to Carol about the tomorrow's demo.",
                conversationsProject);
#else
            Response <AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync(
                "Send an email to Carol about the tomorrow's demo.",
                TestEnvironment.Project);
#endif

            CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
            ConversationPrediction         conversationPrediction         = customConversationalTaskResult.Result.Prediction as ConversationPrediction;

            Console.WriteLine($"Project Kind: {customConversationalTaskResult.Result.Prediction.ProjectKind}");
            Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");

            Console.WriteLine("Intents:");
            foreach (ConversationIntent intent in conversationPrediction.Intents)
            {
                Console.WriteLine($"Category: {intent.Category}");
                Console.WriteLine($"Confidence: {intent.Confidence}");
                Console.WriteLine();
            }

            Console.WriteLine("Entities:");
            foreach (ConversationEntity entity in conversationPrediction.Entities)
            {
                Console.WriteLine($"Category: {entity.Category}");
                Console.WriteLine($"Text: {entity.Text}");
                Console.WriteLine($"Offset: {entity.Offset}");
                Console.WriteLine($"Length: {entity.Length}");
                Console.WriteLine($"Confidence: {entity.Confidence}");
                Console.WriteLine();

                foreach (BaseResolution resolution in entity.Resolutions)
                {
                    if (resolution is DateTimeResolution dateTimeResolution)
                    {
                        Console.WriteLine($"Datetime Sub Kind: {dateTimeResolution.DateTimeSubKind}");
                        Console.WriteLine($"Timex: {dateTimeResolution.Timex}");
                        Console.WriteLine($"Value: {dateTimeResolution.Value}");
                        Console.WriteLine();
                    }
                }
            }
            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(conversationPrediction.TopIntent, Is.EqualTo("Read"));
        }
Exemple #10
0
        protected ConversationAnalysisTestBase(bool isAsync, ConversationAnalysisClientOptions.ServiceVersion serviceVersion, RecordedTestMode?mode)
            : base(isAsync, mode)
        {
            // TODO: Compare bodies again when https://github.com/Azure/azure-sdk-for-net/issues/22219 is resolved.
            CompareBodies = false;

            SanitizedHeaders.Add(ConversationAnalysisClient.GetAuthorizationHeader());
            ServiceVersion = serviceVersion;
        }
Exemple #11
0
        public void AnalyzeConversationOrchestrationPredictionConversation()
        {
            ConversationAnalysisClient client = Client;
            Response <AnalyzeConversationTaskResult> response = client.AnalyzeConversation(
                "Send an email to Carol about the tomorrow's demo",
                TestEnvironment.OrchestrationProject);

            CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
            var orchestratorPrediction = customConversationalTaskResult.Results.Prediction as OrchestratorPrediction;

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionConversation
            string             respondingProjectName = orchestratorPrediction.TopIntent;
            TargetIntentResult targetIntentResult    = orchestratorPrediction.Intents[respondingProjectName];

            if (targetIntentResult.TargetKind == TargetKind.Conversation)
            {
                ConversationTargetIntentResult cluTargetIntentResult = targetIntentResult as ConversationTargetIntentResult;

                ConversationResult     conversationResult     = cluTargetIntentResult.Result;
                ConversationPrediction conversationPrediction = conversationResult.Prediction;

                Console.WriteLine($"Top Intent: {conversationResult.Prediction.TopIntent}");
                Console.WriteLine($"Intents:");
                foreach (ConversationIntent intent in conversationPrediction.Intents)
                {
                    Console.WriteLine($"Intent Category: {intent.Category}");
                    Console.WriteLine($"Confidence: {intent.Confidence}");
                    Console.WriteLine();
                }

                Console.WriteLine($"Entities:");
                foreach (ConversationEntity entity in conversationPrediction.Entities)
                {
                    Console.WriteLine($"Entity Text: {entity.Text}");
                    Console.WriteLine($"Entity Category: {entity.Category}");
                    Console.WriteLine($"Confidence: {entity.Confidence}");
                    Console.WriteLine($"Starting Position: {entity.Offset}");
                    Console.WriteLine($"Length: {entity.Length}");
                    Console.WriteLine();

                    foreach (BaseResolution resolution in entity.Resolutions)
                    {
                        if (resolution is DateTimeResolution dateTimeResolution)
                        {
                            Console.WriteLine($"Datetime Sub Kind: {dateTimeResolution.DateTimeSubKind}");
                            Console.WriteLine($"Timex: {dateTimeResolution.Timex}");
                            Console.WriteLine($"Value: {dateTimeResolution.Value}");
                            Console.WriteLine();
                        }
                    }
                }
            }
            #endregion
            Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.Conversation));
            Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("EmailIntent"));
        }
        public void StartAnalyzeConversation_ConversationSummarization()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:StartAnalyzeConversation_ConversationSummarization_Input
            var textConversationItems = new List <TextConversationItem>()
            {
                new TextConversationItem("1", "Agent", "Hello, how can I help you?"),
                new TextConversationItem("2", "Customer", "How to upgrade Office? I am getting error messages the whole day."),
                new TextConversationItem("3", "Agent", "Press the upgrade button please. Then sign in and follow the instructions."),
            };

            var input = new List <TextConversation>()
            {
                new TextConversation("1", "en", textConversationItems)
            };

            var conversationSummarizationTaskParameters = new ConversationSummarizationTaskParameters(new List <SummaryAspect>()
            {
                SummaryAspect.Issue, SummaryAspect.Resolution
            });

            var tasks = new List <AnalyzeConversationLROTask>()
            {
                new AnalyzeConversationSummarizationTask("1", AnalyzeConversationLROTaskKind.ConversationalSummarizationTask, conversationSummarizationTaskParameters),
            };
            #endregion

            #region Snippet:StartAnalyzeConversation_StartAnalayzing
            var analyzeConversationOperation = client.StartAnalyzeConversation(input, tasks);
            analyzeConversationOperation.WaitForCompletion();
            #endregion

            #region Snippet:StartAnalyzeConversation_ConversationSummarization_Results
            var jobResults = analyzeConversationOperation.Value;
            foreach (var result in jobResults.Tasks.Items)
            {
                var analyzeConversationSummarization = result as AnalyzeConversationSummarizationResult;

                var results = analyzeConversationSummarization.Results;

                Console.WriteLine("Conversations:");
                foreach (var conversation in results.Conversations)
                {
                    Console.WriteLine($"Conversation #:{conversation.Id}");
                    Console.WriteLine("Summaries:");
                    foreach (var summary in conversation.Summaries)
                    {
                        Console.WriteLine($"Text: {summary.Text}");
                        Console.WriteLine($"Aspect: {summary.Aspect}");
                    }
                    Console.WriteLine();
                }
            }
            #endregion
        }
Exemple #13
0
        public void AnalyzeConversationOrchestrationPredictionConversation()
        {
            ConversationAnalysisClient client = Client;

            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "We'll have 2 plates of seared salmon nigiri.",
                TestEnvironment.OrchestrationProject);

            OrchestratorPrediction orchestratorPrediction = response.Value.Prediction as OrchestratorPrediction;

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionConversation
            string             respondingProjectName = orchestratorPrediction.TopIntent;
            TargetIntentResult targetIntentResult    = orchestratorPrediction.Intents[respondingProjectName];

            if (targetIntentResult.TargetKind == TargetKind.Conversation)
            {
                ConversationTargetIntentResult cluTargetIntentResult = targetIntentResult as ConversationTargetIntentResult;

                ConversationResult     conversationResult     = cluTargetIntentResult.Result;
                ConversationPrediction conversationPrediction = conversationResult.Prediction;

                if (!String.IsNullOrEmpty(conversationResult.DetectedLanguage))
                {
                    Console.WriteLine($"Detected Language: {conversationResult.DetectedLanguage}");
                }

                Console.WriteLine($"Top Intent: {conversationResult.Prediction.TopIntent}");
                Console.WriteLine($"Intents:");
                foreach (ConversationIntent intent in conversationPrediction.Intents)
                {
                    Console.WriteLine($"Intent Category: {intent.Category}");
                    Console.WriteLine($"Confidence Score: {intent.ConfidenceScore}");
                    Console.WriteLine();
                }

                Console.WriteLine($"Entities:");
                foreach (ConversationEntity entitiy in conversationPrediction.Entities)
                {
                    Console.WriteLine($"Entity Text: {entitiy.Text}");
                    Console.WriteLine($"Entity Category: {entitiy.Category}");
                    Console.WriteLine($"Confidence Score: {entitiy.ConfidenceScore}");
                    Console.WriteLine($"Starting Position: {entitiy.Offset}");
                    Console.WriteLine($"Length: {entitiy.Length}");
                    Console.WriteLine();
                }
            }
            #endregion
            Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.Conversation));
            Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("SushiOrder"));
        }
Exemple #14
0
        public void AnalyzeConversationOrchestrationPredictionLuis()
        {
            ConversationAnalysisClient client = Client;
            var data = new
            {
                analysisInput = new
                {
                    conversationItem = new
                    {
                        text          = "Reserve a table for 2 at the Italian restaurant.",
                        id            = "1",
                        participantId = "1",
                    }
                },
                parameters = new
                {
                    projectName    = TestEnvironment.OrchestrationProjectName,
                    deploymentName = TestEnvironment.OrchestrationDeploymentName,

                    // Use Utf16CodeUnit for strings in .NET.
                    stringIndexType = "Utf16CodeUnit",
                },
                kind = "Conversation",
            };

            Response response = client.AnalyzeConversation(RequestContent.Create(data));

            using JsonDocument result = JsonDocument.Parse(response.ContentStream);
            JsonElement conversationalTaskResult = result.RootElement;
            JsonElement orchestrationPrediction  = conversationalTaskResult.GetProperty("result").GetProperty("prediction");

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionLuis
            string      respondingProjectName = orchestrationPrediction.GetProperty("topIntent").GetString();
            JsonElement targetIntentResult    = orchestrationPrediction.GetProperty("intents").GetProperty(respondingProjectName);

            if (targetIntentResult.GetProperty("targetProjectKind").GetString() == "Luis")
            {
                JsonElement luisResponse = targetIntentResult.GetProperty("result");
                Console.WriteLine($"LUIS Response: {luisResponse.GetRawText()}");
            }
            #endregion

            Assert.That(targetIntentResult.GetProperty("targetProjectKind").GetString(), Is.EqualTo("Luis"));
            Assert.That(orchestrationPrediction.GetProperty("topIntent").GetString(), Is.EqualTo("RestaurantIntent"));
        }
Exemple #15
0
        public void AnalyzeConversationOrchestrationPredictionQuestionAnswering()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPrediction
#if SNIPPET
            ConversationsProject orchestrationProject     = new ConversationsProject("DomainOrchestrator", "production");
            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "How are you?",
                orchestrationProject);
#else
            Response <AnalyzeConversationTaskResult> response = client.AnalyzeConversation(
                "How are you?",
                TestEnvironment.OrchestrationProject);
#endif
            CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
            var orchestratorPrediction = customConversationalTaskResult.Results.Prediction as OrchestratorPrediction;
            #endregion

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionQnA
            string             respondingProjectName = orchestratorPrediction.TopIntent;
            TargetIntentResult targetIntentResult    = orchestratorPrediction.Intents[respondingProjectName];

            if (targetIntentResult.TargetKind == TargetKind.QuestionAnswering)
            {
                Console.WriteLine($"Top intent: {respondingProjectName}");

                QuestionAnsweringTargetIntentResult qnaTargetIntentResult = targetIntentResult as QuestionAnsweringTargetIntentResult;

                KnowledgeBaseAnswers qnaAnswers = qnaTargetIntentResult.Result;

                Console.WriteLine("Answers: \n");
                foreach (KnowledgeBaseAnswer answer in qnaAnswers.Answers)
                {
                    Console.WriteLine($"Answer: {answer.Answer}");
                    Console.WriteLine($"Confidence: {answer.Confidence}");
                    Console.WriteLine($"Source: {answer.Source}");
                    Console.WriteLine();
                }
            }
            #endregion
            Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.QuestionAnswering));
            Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("ChitChat-QnA"));
        }
        public async Task AnalyzeConversationDeepstackAsync()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationDeepstackAsync

#if SNIPPET
            Response <AnalyzeConversationResult> response = await client.AnalyzeConversationAsync(
                "Menu",
                "production",
                "We'll have 2 plates of seared salmon nigiri.");
#else
            Response <AnalyzeConversationResult> response = await client.AnalyzeConversationAsync(
                TestEnvironment.ProjectName,
                TestEnvironment.DeploymentName,
                "We'll have 2 plates of seared salmon nigiri.");
#endif

            DeepstackPrediction deepstackPrediction = response.Value.Prediction as DeepstackPrediction;

            Console.WriteLine("Intents:");
            foreach (DeepstackIntent intent in deepstackPrediction.Intents)
            {
                Console.WriteLine($"Category:{intent.Category}");
                Console.WriteLine($"Confidence Score:{intent.ConfidenceScore}");
                Console.WriteLine();
            }

            Console.WriteLine("Entities:");
            foreach (DeepstackEntity entity in deepstackPrediction.Entities)
            {
                Console.WriteLine($"Category: {entity.Category}");
                Console.WriteLine($"Text: {entity.Text}");
                Console.WriteLine($"Offset: {entity.Offset}");
                Console.WriteLine($"Length: {entity.Length}");
                Console.WriteLine($"Confidence Score: {entity.ConfidenceScore}");
                Console.WriteLine();
            }
            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(deepstackPrediction.TopIntent, Is.EqualTo("Order"));
        }
        public void AnalyzeConversationWithConversationPredictionResult()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationWithConversationPrediction

#if SNIPPET
            ConversationsProject conversationsProject     = new ConversationsProject("Menu", "production");
            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "We'll have 2 plates of seared salmon nigiri.",
                conversationsProject);
#else
            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "We'll have 2 plates of seared salmon nigiri.",
                TestEnvironment.Project);
#endif

            ConversationPrediction conversationPrediction = response.Value.Prediction as ConversationPrediction;

            Console.WriteLine("Intents:");
            foreach (ConversationIntent intent in conversationPrediction.Intents)
            {
                Console.WriteLine($"Category:{intent.Category}");
                Console.WriteLine($"Confidence Score:{intent.ConfidenceScore}");
                Console.WriteLine();
            }

            Console.WriteLine("Entities:");
            foreach (ConversationEntity entity in conversationPrediction.Entities)
            {
                Console.WriteLine($"Category: {entity.Category}");
                Console.WriteLine($"Text: {entity.Text}");
                Console.WriteLine($"Offset: {entity.Offset}");
                Console.WriteLine($"Length: {entity.Length}");
                Console.WriteLine($"Confidence Score: {entity.ConfidenceScore}");
                Console.WriteLine();
            }
            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(conversationPrediction.TopIntent, Is.EqualTo("Order"));
        }
Exemple #18
0
        public void AnalyzeConversationOrchestrationPredictionQuestionAnswering()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPrediction

#if SNIPPET
            ConversationsProject orchestrationProject     = new ConversationsProject("DomainOrchestrator", "production");
            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "Where are the calories per recipe?",
                orchestrationProject);
#else
            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "Where are the calories per recipe?",
                TestEnvironment.OrchestrationProject);
#endif

            OrchestratorPrediction orchestratorPrediction = response.Value.Prediction as OrchestratorPrediction;
            #endregion
            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionQnA
            string             respondingProjectName = orchestratorPrediction.TopIntent;
            TargetIntentResult targetIntentResult    = orchestratorPrediction.Intents[respondingProjectName];

            if (targetIntentResult.TargetKind == TargetKind.QuestionAnswering)
            {
                QuestionAnsweringTargetIntentResult qnaTargetIntentResult = targetIntentResult as QuestionAnsweringTargetIntentResult;

                KnowledgeBaseAnswers qnaAnswers = qnaTargetIntentResult.Result;

                Console.WriteLine("Answers: \n");
                foreach (KnowledgeBaseAnswer answer in qnaAnswers.Answers)
                {
                    Console.WriteLine($"Answer: {answer.Answer}");
                    Console.WriteLine($"Confidence Score: {answer.ConfidenceScore}");
                    Console.WriteLine($"Source: {answer.Source}");
                    Console.WriteLine();
                }
            }
            #endregion
            Assert.That(targetIntentResult.TargetKind, Is.EqualTo(TargetKind.QuestionAnswering));
            Assert.That(orchestratorPrediction.TopIntent, Is.EqualTo("SushiMaking"));
        }
Exemple #19
0
        public void AnalyzeConversationWithOptions()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationWithOptions

#if SNIPPET
            ConversationsProject       conversationsProject = new ConversationsProject("Menu", "production");
            AnalyzeConversationOptions options = new AnalyzeConversationOptions()
            {
                IsLoggingEnabled = true,
                Verbose          = true,
            };

            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "We'll have 2 plates of seared salmon nigiri.",
                conversationsProject,
                options);
#else
            AnalyzeConversationOptions options = new AnalyzeConversationOptions()
            {
                IsLoggingEnabled = true,
                Verbose          = true,
            };

            Response <AnalyzeConversationResult> response = client.AnalyzeConversation(
                "We'll have 2 plates of seared salmon nigiri.",
                TestEnvironment.Project,
                options);
#endif

            Console.WriteLine($"Top intent: {response.Value.Prediction.TopIntent}");

            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(response.Value.Prediction.TopIntent, Is.EqualTo("Order"));
        }
Exemple #20
0
        public async Task AnalyzeConversationAsync()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationAsync

#if SNIPPET
            ConversationsProject conversationsProject = new ConversationsProject("Menu", "production");

            Response <AnalyzeConversationResult> response = await client.AnalyzeConversationAsync(
                "We'll have 2 plates of seared salmon nigiri.",
                conversationsProject);
#else
            Response <AnalyzeConversationResult> response = await client.AnalyzeConversationAsync(
                "We'll have 2 plates of seared salmon nigiri.",
                TestEnvironment.Project);
#endif

            Console.WriteLine($"Top intent: {response.Value.Prediction.TopIntent}");
            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(response.Value.Prediction.TopIntent, Is.EqualTo("Order"));
        }
 public AnalyzeConversation(ConversationAnalysisClient options) : base(options)
 {
 }
Exemple #22
0
        public void StartAnalyzeConversation_ConversationPII_Transcript()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:StartAnalyzeConversation_ConversationPII_Transcript_Input
            var transciprtConversationItemOne = new TranscriptConversationItem(
                id: "1",
                participantId: "speaker",
                itn: "hi",
                maskedItn: "hi",
                text: "Hi",
                lexical: "hi");
            transciprtConversationItemOne.AudioTimings.Add(new WordLevelTiming(4500000, 2800000, "hi"));

            var transciprtConversationItemTwo = new TranscriptConversationItem(
                id: "2",
                participantId: "speaker",
                itn: "jane doe",
                maskedItn: "jane doe",
                text: "Jane doe",
                lexical: "jane doe");
            transciprtConversationItemTwo.AudioTimings.Add(new WordLevelTiming(7100000, 4800000, "jane"));
            transciprtConversationItemTwo.AudioTimings.Add(new WordLevelTiming(12000000, 1700000, "jane"));

            var transciprtConversationItemThree = new TranscriptConversationItem(
                id: "3",
                participantId: "agent",
                itn: "hi jane what's your phone number",
                maskedItn: "hi jane what's your phone number",
                text: "Hi Jane, what's your phone number?",
                lexical: "hi jane what's your phone number");
            transciprtConversationItemThree.AudioTimings.Add(new WordLevelTiming(7700000, 3100000, "hi"));
            transciprtConversationItemThree.AudioTimings.Add(new WordLevelTiming(10900000, 5700000, "jane"));
            transciprtConversationItemThree.AudioTimings.Add(new WordLevelTiming(17300000, 2600000, "what's"));
            transciprtConversationItemThree.AudioTimings.Add(new WordLevelTiming(20000000, 1600000, "your"));
            transciprtConversationItemThree.AudioTimings.Add(new WordLevelTiming(21700000, 1700000, "phone"));
            transciprtConversationItemThree.AudioTimings.Add(new WordLevelTiming(23500000, 2300000, "number"));

            var transcriptConversationItems = new List <TranscriptConversationItem>()
            {
                transciprtConversationItemOne,
                transciprtConversationItemTwo,
                transciprtConversationItemThree,
            };

            var input = new List <TranscriptConversation>()
            {
                new TranscriptConversation("1", "en", transcriptConversationItems)
            };

            var conversationPIITaskParameters = new ConversationPIITaskParameters(false, "2022-05-15-preview", new List <ConversationPIICategory>()
            {
                ConversationPIICategory.All
            }, false, TranscriptContentType.Lexical);

            var tasks = new List <AnalyzeConversationLROTask>()
            {
                new AnalyzeConversationPIITask("analyze", AnalyzeConversationLROTaskKind.ConversationalPIITask, conversationPIITaskParameters),
            };
            #endregion

            var analyzeConversationOperation = client.StartAnalyzeConversation(input, tasks);
            analyzeConversationOperation.WaitForCompletion();

            #region Snippet:StartAnalyzeConversation_ConversationPII_Transcript_Results
            var jobResults = analyzeConversationOperation.Value;
            foreach (var result in jobResults.Tasks.Items)
            {
                var analyzeConversationPIIResult = result as AnalyzeConversationPIIResult;

                var results = analyzeConversationPIIResult.Results;

                Console.WriteLine("Conversations:");
                foreach (var conversation in results.Conversations)
                {
                    Console.WriteLine($"Conversation #:{conversation.Id}");
                    Console.WriteLine("Conversation Items: ");
                    foreach (var conversationItem in conversation.ConversationItems)
                    {
                        Console.WriteLine($"Conversation Item #:{conversationItem.Id}");

                        Console.WriteLine($"Redacted Text: {conversationItem.RedactedContent.Text}");
                        Console.WriteLine($"Redacted Lexical: {conversationItem.RedactedContent.Lexical}");
                        Console.WriteLine($"Redacted AudioTimings: {conversationItem.RedactedContent.AudioTimings}");
                        Console.WriteLine($"Redacted MaskedItn: {conversationItem.RedactedContent.MaskedItn}");

                        Console.WriteLine("Entities:");
                        foreach (var entity in conversationItem.Entities)
                        {
                            Console.WriteLine($"Text: {entity.Text}");
                            Console.WriteLine($"Offset: {entity.Offset}");
                            Console.WriteLine($"Category: {entity.Category}");
                            Console.WriteLine($"Confidence Score: {entity.ConfidenceScore}");
                            Console.WriteLine($"Length: {entity.Length}");
                            Console.WriteLine();
                        }
                    }
                    Console.WriteLine();
                }
            }
            #endregion
        }
        public async Task AnalyzeConversationWithLanguageAsync()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationWithLanguageAsync
            TextConversationItem input = new TextConversationItem(
                participantId: "1",
                id: "1",
                text: "Tendremos 2 platos de nigiri de salmón braseado.")
            {
                Language = "es"
            };
            AnalyzeConversationOptions options = new AnalyzeConversationOptions(input);

#if SNIPPET
            ConversationsProject conversationsProject = new ConversationsProject("Menu", "production");

            Response <AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync(
                textConversationItem,
                conversationsProject,
                options);
#else
            Response <AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync(
                "Tendremos 2 platos de nigiri de salmón braseado.",
                TestEnvironment.Project,
                options);
#endif

            CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
            ConversationPrediction         conversationPrediction         = customConversationalTaskResult.Result.Prediction as ConversationPrediction;

            Console.WriteLine($"Project Kind: {customConversationalTaskResult.Result.Prediction.ProjectKind}");
            Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");

            Console.WriteLine("Intents:");
            foreach (ConversationIntent intent in conversationPrediction.Intents)
            {
                Console.WriteLine($"Category: {intent.Category}");
                Console.WriteLine($"Confidence: {intent.Confidence}");
                Console.WriteLine();
            }

            Console.WriteLine("Entities:");
            foreach (ConversationEntity entity in conversationPrediction.Entities)
            {
                Console.WriteLine($"Category: {entity.Category}");
                Console.WriteLine($"Text: {entity.Text}");
                Console.WriteLine($"Offset: {entity.Offset}");
                Console.WriteLine($"Length: {entity.Length}");
                Console.WriteLine($"Confidence: {entity.Confidence}");
                Console.WriteLine();

                foreach (BaseResolution resolution in entity.Resolutions)
                {
                    if (resolution is DateTimeResolution dateTimeResolution)
                    {
                        Console.WriteLine($"Datetime Sub Kind: {dateTimeResolution.DateTimeSubKind}");
                        Console.WriteLine($"Timex: {dateTimeResolution.Timex}");
                        Console.WriteLine($"Value: {dateTimeResolution.Value}");
                        Console.WriteLine();
                    }
                }
            }

            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(conversationPrediction.TopIntent, Is.EqualTo("Read"));
        }
Exemple #24
0
        public async Task AnalyzeConversationWithOptionsAsync()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationWithOptionsAsync
            string projectName    = "Menu";
            string deploymentName = "production";
#if !SNIPPET
            projectName    = TestEnvironment.ProjectName;
            deploymentName = TestEnvironment.DeploymentName;
#endif

            var data = new
            {
                analysisInput = new
                {
                    conversationItem = new
                    {
                        text          = "Send an email to Carol about tomorrow's demo",
                        id            = "1",
                        participantId = "1",
                    }
                },
                parameters = new
                {
                    projectName,
                    deploymentName,
                    verbose = true,

                    // Use Utf16CodeUnit for strings in .NET.
                    stringIndexType = "Utf16CodeUnit",
                },
                kind = "Conversation",
            };

            Response response = await client.AnalyzeConversationAsync(RequestContent.Create(data));

            #endregion

            using JsonDocument result = await JsonDocument.ParseAsync(response.ContentStream);

            JsonElement conversationalTaskResult = result.RootElement;
            JsonElement conversationPrediction   = conversationalTaskResult.GetProperty("result").GetProperty("prediction");

            Console.WriteLine($"Project Kind: {conversationPrediction.GetProperty("projectKind").GetString()}");
            Console.WriteLine($"Top intent: {conversationPrediction.GetProperty("topIntent").GetString()}");

            Console.WriteLine("Intents:");
            foreach (JsonElement intent in conversationPrediction.GetProperty("intents").EnumerateArray())
            {
                Console.WriteLine($"Category: {intent.GetProperty("category").GetString()}");
                Console.WriteLine($"Confidence: {intent.GetProperty("confidenceScore").GetSingle()}");
                Console.WriteLine();
            }

            Console.WriteLine("Entities:");
            foreach (JsonElement entity in conversationPrediction.GetProperty("entities").EnumerateArray())
            {
                Console.WriteLine($"Category: {entity.GetProperty("category").GetString()}");
                Console.WriteLine($"Text: {entity.GetProperty("text").GetString()}");
                Console.WriteLine($"Offset: {entity.GetProperty("offset").GetInt32()}");
                Console.WriteLine($"Length: {entity.GetProperty("length").GetInt32()}");
                Console.WriteLine($"Confidence: {entity.GetProperty("confidenceScore").GetSingle()}");
                Console.WriteLine();

                if (!entity.TryGetProperty("resolutions", out JsonElement resolutions))
                {
                    continue;
                }

                foreach (JsonElement resolution in resolutions.EnumerateArray())
                {
                    if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
                    {
                        Console.WriteLine($"Datetime Sub Kind: {resolution.GetProperty("dateTimeSubKind").GetString()}");
                        Console.WriteLine($"Timex: {resolution.GetProperty("timex").GetString()}");
                        Console.WriteLine($"Value: {resolution.GetProperty("value").GetString()}");
                        Console.WriteLine();
                    }
                }
            }

            Assert.That(response.Status, Is.EqualTo(200));
            Assert.That(conversationPrediction.GetProperty("topIntent").GetString(), Is.EqualTo("Send"));
        }
        public void AnalyzeConversationWithOptions()
        {
            ConversationAnalysisClient client = Client;

            #region Snippet:ConversationAnalysis_AnalyzeConversationWithOptions
            TextConversationItem input = new TextConversationItem(
                participantId: "1",
                id: "1",
                text: "Send an email to Carol about the tomorrow's demo.");
            AnalyzeConversationOptions options = new AnalyzeConversationOptions(input)
            {
                IsLoggingEnabled = true,
                Verbose          = true
            };

#if SNIPPET
            ConversationsProject conversationsProject = new ConversationsProject("Menu", "production");

            Response <AnalyzeConversationTaskResult> response = client.AnalyzeConversation(
                "Send an email to Carol about the tomorrow's demo.",
                conversationsProject,
                options);
#else
            Response <AnalyzeConversationTaskResult> response = client.AnalyzeConversation(
                "Send an email to Carol about the tomorrow's demo.",
                TestEnvironment.Project,
                options);
#endif

            CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
            ConversationPrediction         conversationPrediction         = customConversationalTaskResult.Results.Prediction as ConversationPrediction;

            Console.WriteLine($"Project Kind: {customConversationalTaskResult.Results.Prediction.ProjectKind}");
            Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");

            Console.WriteLine("Intents:");
            foreach (ConversationIntent intent in conversationPrediction.Intents)
            {
                Console.WriteLine($"Category: {intent.Category}");
                Console.WriteLine($"Confidence: {intent.Confidence}");
                Console.WriteLine();
            }

            Console.WriteLine("Entities:");
            foreach (ConversationEntity entity in conversationPrediction.Entities)
            {
                Console.WriteLine($"Category: {entity.Category}");
                Console.WriteLine($"Text: {entity.Text}");
                Console.WriteLine($"Offset: {entity.Offset}");
                Console.WriteLine($"Length: {entity.Length}");
                Console.WriteLine($"Confidence: {entity.Confidence}");
                Console.WriteLine();

                foreach (BaseResolution resolution in entity.Resolutions)
                {
                    if (resolution is DateTimeResolution dateTimeResolution)
                    {
                        Console.WriteLine($"Datetime Sub Kind: {dateTimeResolution.DateTimeSubKind}");
                        Console.WriteLine($"Timex: {dateTimeResolution.Timex}");
                        Console.WriteLine($"Value: {dateTimeResolution.Value}");
                        Console.WriteLine();
                    }
                }
            }
            #endregion

            Assert.That(response.GetRawResponse().Status, Is.EqualTo(200));
            Assert.That(conversationPrediction.TopIntent, Is.EqualTo("Setup"));
        }
Exemple #26
0
        public void AnalyzeConversationOrchestrationPredictionConversation()
        {
            ConversationAnalysisClient client = Client;
            var data = new
            {
                analysisInput = new
                {
                    conversationItem = new
                    {
                        text          = "Send an email to Carol about tomorrow's demo",
                        id            = "1",
                        participantId = "1",
                    }
                },
                parameters = new
                {
                    projectName    = TestEnvironment.OrchestrationProjectName,
                    deploymentName = TestEnvironment.OrchestrationDeploymentName,

                    // Use Utf16CodeUnit for strings in .NET.
                    stringIndexType = "Utf16CodeUnit",
                },
                kind = "Conversation",
            };

            Response response = client.AnalyzeConversation(RequestContent.Create(data));

            using JsonDocument result = JsonDocument.Parse(response.ContentStream);
            JsonElement conversationalTaskResult = result.RootElement;
            JsonElement orchestrationPrediction  = conversationalTaskResult.GetProperty("result").GetProperty("prediction");

            #region Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionConversation
            string      respondingProjectName = orchestrationPrediction.GetProperty("topIntent").GetString();
            JsonElement targetIntentResult    = orchestrationPrediction.GetProperty("intents").GetProperty(respondingProjectName);

            if (targetIntentResult.GetProperty("targetProjectKind").GetString() == "Conversation")
            {
                JsonElement conversationResult     = targetIntentResult.GetProperty("result");
                JsonElement conversationPrediction = conversationResult.GetProperty("prediction");

                Console.WriteLine($"Top Intent: {conversationPrediction.GetProperty("topIntent").GetString()}");
                Console.WriteLine($"Intents:");
                foreach (JsonElement intent in conversationPrediction.GetProperty("intents").EnumerateArray())
                {
                    Console.WriteLine($"Intent Category: {intent.GetProperty("category").GetString()}");
                    Console.WriteLine($"Confidence: {intent.GetProperty("confidenceScore").GetSingle()}");
                    Console.WriteLine();
                }

                Console.WriteLine($"Entities:");
                foreach (JsonElement entity in conversationPrediction.GetProperty("entities").EnumerateArray())
                {
                    Console.WriteLine($"Entity Text: {entity.GetProperty("text").GetString()}");
                    Console.WriteLine($"Entity Category: {entity.GetProperty("category").GetString()}");
                    Console.WriteLine($"Confidence: {entity.GetProperty("confidenceScore").GetSingle()}");
                    Console.WriteLine($"Starting Position: {entity.GetProperty("offset").GetInt32()}");
                    Console.WriteLine($"Length: {entity.GetProperty("length").GetInt32()}");
                    Console.WriteLine();

                    if (!entity.TryGetProperty("resolutions", out JsonElement resolutions))
                    {
                        continue;
                    }

                    foreach (JsonElement resolution in resolutions.EnumerateArray())
                    {
                        if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
                        {
                            Console.WriteLine($"Datetime Sub Kind: {resolution.GetProperty("dateTimeSubKind").GetString()}");
                            Console.WriteLine($"Timex: {resolution.GetProperty("timex").GetString()}");
                            Console.WriteLine($"Value: {resolution.GetProperty("value").GetString()}");
                            Console.WriteLine();
                        }
                    }
                }
            }
            #endregion

            Assert.That(targetIntentResult.GetProperty("targetProjectKind").GetString(), Is.EqualTo("Conversation"));
            Assert.That(orchestrationPrediction.GetProperty("topIntent").GetString(), Is.EqualTo("EmailIntent"));
        }
Exemple #27
0
        public async Task StartAnalyzeConversationAsync_ConversationPII_Text()
        {
            ConversationAnalysisClient client = Client;

            var textConversationItems = new List <TextConversationItem>()
            {
                new TextConversationItem("1", "0", "Hi, I am John Doe."),
                new TextConversationItem("2", "1", "Hi John, how are you doing today?"),
                new TextConversationItem("3", "0", "Pretty good."),
            };

            var input = new List <TextConversation>()
            {
                new TextConversation("1", "en", textConversationItems)
            };

            var conversationPIITaskParameters = new ConversationPIITaskParameters(false, "2022-05-15-preview", new List <ConversationPIICategory>()
            {
                ConversationPIICategory.All
            }, false, null);

            List <AnalyzeConversationLROTask> tasks = new List <AnalyzeConversationLROTask>()
            {
                new AnalyzeConversationPIITask("analyze", AnalyzeConversationLROTaskKind.ConversationalPIITask, conversationPIITaskParameters),
            };

            var analyzeConversationOperation = await client.StartAnalyzeConversationAsync(input, tasks);

            await analyzeConversationOperation.WaitForCompletionAsync();

            var jobResults = analyzeConversationOperation.Value;

            foreach (var result in jobResults.Tasks.Items)
            {
                var analyzeConversationPIIResult = result as AnalyzeConversationPIIResult;

                var results = analyzeConversationPIIResult.Results;

                Console.WriteLine("Conversations:");
                foreach (var conversation in results.Conversations)
                {
                    Console.WriteLine($"Conversation #:{conversation.Id}");
                    Console.WriteLine("Conversation Items: ");
                    foreach (var conversationItem in conversation.ConversationItems)
                    {
                        Console.WriteLine($"Conversation Item #:{conversationItem.Id}");

                        Console.WriteLine($"Redacted Text: {conversationItem.RedactedContent.Text}");

                        Console.WriteLine("Entities:");
                        foreach (var entity in conversationItem.Entities)
                        {
                            Console.WriteLine($"Text: {entity.Text}");
                            Console.WriteLine($"Offset: {entity.Offset}");
                            Console.WriteLine($"Category: {entity.Category}");
                            Console.WriteLine($"Confidence Score: {entity.ConfidenceScore}");
                            Console.WriteLine($"Length: {entity.Length}");
                            Console.WriteLine();
                        }
                    }
                    Console.WriteLine();
                }
            }
        }