forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#2 from ZulaMostafa/CLU-Samples
CLU Samples Markdowns
- Loading branch information
Showing
6 changed files
with
149 additions
and
3 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...ure.AI.Language.Conversations/samples/Sample1_AnalyzeConversationWithOptions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Ask a question | ||
|
||
This sample demonstrates how to analyze an utterance. To get started, you'll need to create a Cognitive Language service endpoint and an API key. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/README.md) for links and instructions. | ||
|
||
To analyze an utterance, you need to first create a `ConversationAnalysisClient` using an endpoint and API key. These can be stored in an environment variable, configuration setting, or any way that works for your application. | ||
|
||
```C# Snippet:ConversationAnalysisClient_Create | ||
Uri endpoint = new Uri("https://myaccount.api.cognitive.microsoft.com"); | ||
AzureKeyCredential credential = new AzureKeyCredential("{api-key}"); | ||
|
||
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential); | ||
``` | ||
|
||
Once you have created a client, you can call synchronous or asynchronous methods. | ||
|
||
## Synchronous | ||
|
||
```C# Snippet:ConversationAnalysis_AnalyzeConversationWithOptions | ||
AnalyzeConversationOptions options = new AnalyzeConversationOptions("Menu", "production", "We'll have 2 plates of seared salmon nigiri."); | ||
Response<AnalyzeConversationResult> response = client.AnalyzeConversation(options); | ||
|
||
Console.WriteLine($"Top intent: {response.Value.Prediction.TopIntent}"); | ||
``` | ||
|
||
## Asynchronous | ||
|
||
```C# Snippet:ConversationAnalysis_AnalyzeConversationWithOptionsAsync | ||
AnalyzeConversationOptions options = new AnalyzeConversationOptions("Menu", "production", "We'll have 2 plates of seared salmon nigiri."); | ||
Response<AnalyzeConversationResult> response = await client.AnalyzeConversationAsync(options); | ||
|
||
Console.WriteLine($"Top intent: {response.Value.Prediction.TopIntent}"); | ||
``` |
38 changes: 38 additions & 0 deletions
38
...re.AI.Language.Conversations/samples/Sample2_AnalyzeConversationWithLanguage.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Ask a question | ||
|
||
This sample demonstrates how to analyze an utterance. To get started, you'll need to create a Cognitive Language service endpoint and an API key. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/README.md) for links and instructions. | ||
|
||
To analyze an utterance, you need to first create a `ConversationAnalysisClient` using an endpoint and API key. These can be stored in an environment variable, configuration setting, or any way that works for your application. | ||
|
||
```C# Snippet:ConversationAnalysisClient_Create | ||
Uri endpoint = new Uri("https://myaccount.api.cognitive.microsoft.com"); | ||
AzureKeyCredential credential = new AzureKeyCredential("{api-key}"); | ||
|
||
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential); | ||
``` | ||
|
||
Once you have created a client, you can call synchronous or asynchronous methods. | ||
|
||
## Synchronous | ||
|
||
```C# Snippet:ConversationAnalysis_AnalyzeConversationWithLanguage | ||
AnalyzeConversationOptions options = new AnalyzeConversationOptions("Menu", "production", "Tendremos 2 platos de nigiri de salmón braseado.") | ||
{ | ||
anguage = "es" | ||
}; | ||
Response<AnalyzeConversationResult> response = client.AnalyzeConversation(options); | ||
|
||
Console.WriteLine($"Top intent: {response.Value.Prediction.TopIntent}"); | ||
``` | ||
|
||
## Asynchronous | ||
|
||
```C# Snippet:ConversationAnalysis_AnalyzeConversationAsync | ||
AnalyzeConversationOptions options = new AnalyzeConversationOptions("Menu", "production", "Tendremos 2 platos de nigiri de salmón braseado.") | ||
{ | ||
anguage = "es" | ||
}; | ||
Response<AnalyzeConversationResult> response = await client.AnalyzeConversationAsync(options); | ||
|
||
Console.WriteLine($"Top intent: {response.Value.Prediction.TopIntent}"); | ||
``` |
76 changes: 76 additions & 0 deletions
76
sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample3_Deepstack.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Ask a question | ||
|
||
This sample demonstrates how to analyze an utterance. To get started, you'll need to create a Cognitive Language service endpoint and an API key. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/README.md) for links and instructions. | ||
|
||
To analyze an utterance, you need to first create a `ConversationAnalysisClient` using an endpoint and API key. These can be stored in an environment variable, configuration setting, or any way that works for your application. | ||
|
||
```C# Snippet:ConversationAnalysisClient_Create | ||
Uri endpoint = new Uri("https://myaccount.api.cognitive.microsoft.com"); | ||
AzureKeyCredential credential = new AzureKeyCredential("{api-key}"); | ||
|
||
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential); | ||
``` | ||
|
||
Once you have created a client, you can call synchronous or asynchronous methods. | ||
|
||
## Synchronous | ||
|
||
```C# Snippet:ConversationAnalysis_AnalyzeConversationDeepstack | ||
Response<AnalyzeConversationResult> response = client.AnalyzeConversation( | ||
"Menu", | ||
"production", | ||
"We'll have 2 plates of seared salmon nigiri."); | ||
|
||
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(); | ||
} | ||
``` | ||
|
||
## Asynchronous | ||
|
||
```C# Snippet:ConversationAnalysis_AnalyzeConversationDeepstackAsync | ||
AnalyzeConversationOptions options = new AnalyzeConversationOptions("We'll have 2 plates of seared salmon nigiri."); | ||
|
||
Response<AnalyzeConversationResult> response = await client.AnalyzeConversationAsync( | ||
"Menu", | ||
"production", | ||
"We'll have 2 plates of seared salmon nigiri."); | ||
|
||
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(); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters