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"));
        }
Ejemplo n.º 2
0
        public async Task AnalyzeConversationsDeepstack()
        {
            AnalyzeConversationOptions options = new AnalyzeConversationOptions(
                TestEnvironment.ProjectName,
                TestEnvironment.DeploymentName,
                EnglishText);

            Response <AnalyzeConversationResult> response = await Client.AnalyzeConversationAsync(options);

            DeepstackPrediction deepstackPrediction = response.Value.Prediction as DeepstackPrediction;

            Assert.That(response.Value.Prediction.ProjectKind, Is.EqualTo(ProjectKind.Conversation));

            Assert.That(deepstackPrediction.TopIntent, Is.EqualTo("Order"));

            IList <string> entitiesText = deepstackPrediction.Entities.Select(entity => entity.Text).ToList();

            Assert.That(entitiesText, Has.Count.EqualTo(2));
            Assert.That(entitiesText, Is.EquivalentTo(ExpectedOutput));
        }