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")); }
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")); }
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 async Task AnalyzeConversation() { AnalyzeConversationOptions options = new AnalyzeConversationOptions( TestEnvironment.ProjectName, TestEnvironment.DeploymentName, EnglishText); Response <AnalyzeConversationResult> response = await Client.AnalyzeConversationAsync(options); Assert.That(response.Value.Prediction.TopIntent, Is.EqualTo("Order")); Assert.That(response.Value.Prediction.ProjectKind, Is.EqualTo(ProjectKind.Conversation)); }
public async Task AnalyzeConversationWithLanguage() { AnalyzeConversationOptions options = new AnalyzeConversationOptions() { Language = "es" }; Response <AnalyzeConversationResult> response = await Client.AnalyzeConversationAsync(SpanishText, TestEnvironment.Project, options); Assert.That(response.Value.Prediction.TopIntent, Is.EqualTo("Order")); Assert.That(response.Value.Prediction.ProjectKind, Is.EqualTo(ProjectKind.Conversation)); }
public void AnalyzeConversationsInvalidArgument() { AnalyzeConversationOptions options = new AnalyzeConversationOptions( TestEnvironment.ProjectName, TestEnvironment.DeploymentName, ""); RequestFailedException ex = Assert.ThrowsAsync <RequestFailedException>(async() => { await Client.AnalyzeConversationAsync(options); }); Assert.That(ex.Status, Is.EqualTo(400)); Assert.That(ex.ErrorCode, Is.EqualTo("InvalidArgument")); }
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)); }
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")); }
public async Task AnalyzeConversationWithOptionsAsync() { ConversationAnalysisClient client = Client; #region Snippet:ConversationAnalysis_AnalyzeConversationWithOptionsAsync 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 = await client.AnalyzeConversationAsync( "Send an email to Carol about the tomorrow's demo.", conversationsProject, options); #else Response <AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync( "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")); }
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")); }