Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TA and Translatior] Update snippets #20552

Merged
merged 3 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@ public partial class Snippets: SamplesBase<TextAnalyticsTestEnvironment>
[Test]
public void CreateTextAnalyticsClient()
{
#region Snippet:CreateTextAnalyticsClient
#if SNIPPET
string endpoint = "<endpoint>";
string apiKey = "<apiKey>";
#else
string endpoint = TestEnvironment.Endpoint;
string apiKey = TestEnvironment.ApiKey;

#region Snippet:CreateTextAnalyticsClient
//@@ string endpoint = "<endpoint>";
//@@ string apiKey = "<apiKey>";
#endif
var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
#endregion
}

[Test]
public void CreateTextAnalyticsClientTokenCredential()
{
string endpoint = TestEnvironment.Endpoint;

#region Snippet:CreateTextAnalyticsClientTokenCredential
//@@ string endpoint = "<endpoint>";
#if SNIPPET
string endpoint = "<endpoint>";
#else
string endpoint = TestEnvironment.Endpoint;
#endif
var client = new TextAnalyticsClient(new Uri(endpoint), new DefaultAzureCredential());
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ public partial class SampleSnippets : SamplesBase<DocumentTranslationTestEnviron
[Ignore("Samples not working yet")]
public void CreateDocumentTranslationClient()
{
#region Snippet:CreateDocumentTranslationClient
#if SNIPPET
string endpoint = "<endpoint>";
string apiKey = "<apiKey>";
#else
string endpoint = TestEnvironment.Endpoint;
string apiKey = TestEnvironment.ApiKey;

#region Snippet:CreateDocumentTranslationClient
//@@ string endpoint = "<endpoint>";
//@@ string apiKey = "<apiKey>";
#endif
var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
#endregion
}
Expand All @@ -38,11 +40,12 @@ public void BadRequestSnippet()
var credentials = new AzureKeyCredential(apiKey);
var client = new DocumentTranslationClient(new Uri(endpoint), credentials);

var invalidInput = new DocumentTranslationInput(new TranslationSource(new Uri(endpoint)), new List<TranslationTarget>());

#region Snippet:BadRequest

//@@ var invalidInput = new DocumentTranslationInput(new TranslationSource(sourceSasUri, new List<TranslationTarget>());
#if SNIPPET
var invalidInput = new DocumentTranslationInput(new TranslationSource(sourceSasUri, new List<TranslationTarget>());
#else
var invalidInput = new DocumentTranslationInput(new TranslationSource(new Uri(endpoint)), new List<TranslationTarget>());
#endif

try
{
Expand All @@ -59,26 +62,30 @@ public void BadRequestSnippet()
[Ignore("Samples not working yet")]
public void DocumentTranslationInput()
{
#region Snippet:DocumentTranslationSingleInput
#if SNIPPET
Uri sourceSasUri = <source SAS URI>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: why not use the same format for the snippet as the actual executed code? At least it will compile, and you wouldn't even need the preproc condition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I was leaving it as is so when we turn on the samples we will pass real values. But not sure when we will do this, so I changed it based on your suggestions.
Thanks!

Uri frenchTargetSasUri = <french target SAS URI>;
#else
Uri sourceSasUri = new Uri("<source SAS URI>");
Uri frenchTargetSasUri = new Uri("<french target SAS URI>");
Uri arabicTargetSasUri = new Uri("<arabic target SAS URI>");
Uri spanishTargetSasUri = new Uri("<spanish target SAS URI>");

#region Snippet:DocumentTranslationSingleInput
//@@ Uri sourceSasUri = <source SAS URI>;
//@@ Uri frenchTargetSasUri = <french target SAS URI>;
#endif

var input = new DocumentTranslationInput(sourceSasUri, frenchTargetSasUri, "fr");
#endregion

#region Snippet:DocumentTranslationMultipleInputs
#if SNIPPET
Uri source1SasUri = <source1 SAS URI>;
maririos marked this conversation as resolved.
Show resolved Hide resolved
Uri source2SasUri = <source2 SAS URI>;
Uri frenchTargetSasUri = <french target SAS URI>;
Uri spanishTargetSasUri = <spanish target SAS URI>;
#else
Uri arabicTargetSasUri = new Uri("<arabic target SAS URI>");
Uri spanishTargetSasUri = new Uri("<spanish target SAS URI>");
Uri source1SasUri = new Uri("<source1 SAS URI>");
Uri source2SasUri = new Uri("<source2 SAS URI>");

#region Snippet:DocumentTranslationMultipleInputs
//@@ Uri source1SasUri = <source1 SAS URI>;
//@@ Uri source2SasUri = <source2 SAS URI>;
//@@ Uri frenchTargetSasUri = <french target SAS URI>;
//@@ Uri spanishTargetSasUri = <spanish target SAS URI>;
#endif

var inputs = new List<DocumentTranslationInput>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ public void MultipleInputs()

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

#region Snippet:MultipleInputs
#if SNIPPET
Uri source1SasUriUri = <source1 SAS URI>;
Uri source2SasUri = <source2 SAS URI>;
Uri frenchTargetSasUri = <french target SAS URI>;
Uri arabicTargetSasUri = <arabic target SAS URI>;
Uri spanishTargetSasUri = <spanish target SAS URI>;
Uri frenchGlossarySasUri = <french glossary SAS URI>;
#else
Uri source1SasUriUri = new Uri("<source1 SAS URI>");
Uri source2SasUri = new Uri("<source2 SAS URI>");
Uri frenchTargetSasUri = new Uri("<french target SAS URI>");
Uri arabicTargetSasUri = new Uri("<arabic target SAS URI>");
Uri spanishTargetSasUri = new Uri("<spanish target SAS URI>");
Uri frenchGlossarySasUri = new Uri("<french glossary SAS URI>");

#region Snippet:MultipleInputs

//@@ Uri source1SasUriUri = <source1 SAS URI>;
//@@ Uri source2SasUri = <source2 SAS URI>;
//@@ Uri frenchTargetSasUri = <french target SAS URI>;
//@@ Uri arabicTargetSasUri = <arabic target SAS URI>;
//@@ Uri spanishTargetSasUri = <spanish target SAS URI>;
//@@ Uri frenchGlossarySasUri = <french glossary SAS URI>;
#endif
var glossaryFormat = "TSV";

var input1 = new DocumentTranslationInput(source1SasUriUri, frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri, glossaryFormat));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ public async Task MultipleInputsAsync()

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

#region Snippet:MultipleInputsAsync

#if SNIPPET
Uri source1SasUriUri = <source1 SAS URI>;
maririos marked this conversation as resolved.
Show resolved Hide resolved
Uri source2SasUri = <source2 SAS URI>;
Uri frenchTargetSasUri = <french target SAS URI>;
Uri arabicTargetSasUri = <arabic target SAS URI>;
Uri spanishTargetSasUri = <spanish target SAS URI>;
Uri frenchGlossarySasUri = <french glossary SAS URI>;
#else
Uri source1SasUriUri = new Uri("<source1 SAS URI>");
Uri source2SasUri = new Uri("<source2 SAS URI>");
Uri frenchTargetSasUri = new Uri("<french target SAS URI>");
Uri arabicTargetSasUri = new Uri("<arabic target SAS URI>");
Uri spanishTargetSasUri = new Uri("<spanish target SAS URI>");
Uri frenchGlossarySasUri = new Uri("<french glossary SAS URI>");

#region Snippet:MultipleInputsAsync

//@@ Uri source1SasUriUri = <source1 SAS URI>;
//@@ Uri source2SasUri = <source2 SAS URI>;
//@@ Uri frenchTargetSasUri = <french target SAS URI>;
//@@ Uri arabicTargetSasUri = <arabic target SAS URI>;
//@@ Uri spanishTargetSasUri = <spanish target SAS URI>;
//@@ Uri frenchGlossarySasUri = <french glossary SAS URI>;
#endif
var glossaryFormat = "TSV";

var input1 = new DocumentTranslationInput(source1SasUriUri, frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri, glossaryFormat));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public void PollIndividualDocuments()

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

#region Snippet:PollIndividualDocuments
#if SNIPPET
Uri sourceUri = <source SAS URI>;
Uri targetUri = <target SAS URI>;
#else
Uri sourceUri = new Uri("<source SAS URI>");
Uri targetUri = new Uri("<target SAS URI>");

#region Snippet:PollIndividualDocuments

//@@ Uri sourceUri = <source SAS URI>;
//@@ Uri targetUri = <target SAS URI>;
#endif

var input = new DocumentTranslationInput(sourceUri, targetUri, "es");
DocumentTranslationOperation operation = client.StartTranslation(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public async Task PollIndividualDocumentsAsync()

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

#region Snippet:PollIndividualDocumentsAsync
#if SNIPPET
Uri sourceUri = <source SAS URI>;
Uri targetUri = <target SAS URI>;
#else
Uri sourceUri = new Uri("<source SAS URI>");
Uri targetUri = new Uri("<target SAS URI>");

#region Snippet:PollIndividualDocumentsAsync

//@@ Uri sourceUri = <source SAS URI>;
//@@ Uri targetUri = <target SAS URI>;
#endif

var input = new DocumentTranslationInput(sourceUri, targetUri, "es");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public void StartTranslation()

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

#region Snippet:StartTranslation
#if SNIPPET
Uri sourceUri = <source SAS URI>;
Uri targetUri = <target SAS URI>;
#else
Uri sourceUri = new Uri("<source SAS URI>");
Uri targetUri = new Uri("<target SAS URI>");

#region Snippet:StartTranslation

//@@ Uri sourceUri = <source SAS URI>;
//@@ Uri targetUri = <target SAS URI>;
#endif

var input = new DocumentTranslationInput(sourceUri, targetUri, "es");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public async Task StartTranslationAsync()

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

#region Snippet:StartTranslationAsync
#if SNIPPET
Uri sourceUri = <source SAS URI>;
Uri targetUri = <target SAS URI>;
#else
Uri sourceUri = new Uri("<source SAS URI>");
Uri targetUri = new Uri("<target SAS URI>");

#region Snippet:StartTranslationAsync

//@@ Uri sourceUri = <source SAS URI>;
//@@ Uri targetUri = <target SAS URI>;
#endif

var input = new DocumentTranslationInput(sourceUri, targetUri, "es");

Expand Down