forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample2_AnalyzeConversationWithLanguage.cs
76 lines (65 loc) · 2.84 KB
/
Sample2_AnalyzeConversationWithLanguage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Threading.Tasks;
using Azure.AI.Language.Conversations.Models;
using Azure.Core.TestFramework;
using NUnit.Framework;
namespace Azure.AI.Language.Conversations.Tests.Samples
{
public partial class ConversationAnalysisWithLanguageSamples
{
[RecordedTest]
[SyncOnly]
public void AnalyzeConversationWithLanguage()
{
ConversationAnalysisClient client = Client;
#region Snippet:ConversationAnalysis_AnalyzeConversationWithLanguage
#if SNIPPET
AnalyzeConversationOptions options = new AnalyzeConversationOptions("Menu",
"production", "Tendremos 2 platos de nigiri de salmón braseado.")
{
Language = "es"
};
Response<AnalyzeConversationResult> response = client.AnalyzeConversation(options);
#else
AnalyzeConversationOptions options = new AnalyzeConversationOptions(TestEnvironment.ProjectName,
TestEnvironment.DeploymentName, "Tendremos 2 platos de nigiri de salmón braseado.")
{
Language = "es"
};
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"));
}
[RecordedTest]
[AsyncOnly]
public async Task AnalyzeConversationWithLanguageAsync()
{
ConversationAnalysisClient client = Client;
#region Snippet:ConversationAnalysis_AnalyzeConversationWithLanguage
#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"));
}
}
}