Skip to content

Commit 7915d24

Browse files
authored
update snippets (Azure#20530)
1 parent 16f6b49 commit 7915d24

21 files changed

+155
-88
lines changed

sdk/formrecognizer/Azure.AI.FormRecognizer/samples/Sample11_RecognizeIdDocuments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To recognize ID documents from a URI, use the `StartRecognizeIdDocumentsFromUriA
2424
For simplicity, we are not showing all the fields that the service returns. To see the list of all the supported fields returned by service and its corresponding types, consult: [here](https://aka.ms/formrecognizer/iddocumentfields).
2525

2626
```C# Snippet:FormRecognizerSampleRecognizeIdDocumentsUri
27-
string sourceUri = "<sourceUri>";
27+
Uri sourceUri = "<sourceUri>";
2828

2929
RecognizeIdDocumentsOperation operation = await client.StartRecognizeIdDocumentsFromUriAsync(sourceUri);
3030
Response<RecognizedFormCollection> operationResponse = await operation.WaitForCompletionAsync();

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/samples/Sample11_ComposedModel.cs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ public async Task CreateComposedModel()
2525

2626
FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2727

28-
Uri officeSuppliesUri = new Uri(trainingFileUrl);
29-
Uri officeEquipmentUri = new Uri(trainingFileUrl);
30-
Uri furnitureUri = new Uri(trainingFileUrl);
31-
Uri cleaningSuppliesUri = new Uri(trainingFileUrl);
32-
3328
#region Snippet:FormRecognizerSampleTrainVariousModels
3429
// For this sample, you can use the training forms found in the `trainingFiles` folder.
3530
// Upload the forms to your storage container and then generate a container SAS URL.
@@ -38,28 +33,44 @@ public async Task CreateComposedModel()
3833

3934
bool useLabels = true;
4035

41-
//@@ Uri officeSuppliesUri = <purchaseOrderOfficeSuppliesUri>;
36+
#if SNIPPET
37+
Uri officeSuppliesUri = <purchaseOrderOfficeSuppliesUri>;
38+
#else
39+
Uri officeSuppliesUri = new Uri(trainingFileUrl);
40+
#endif
4241
string suppliesModelName = "Purchase order - Office supplies";
4342

4443
TrainingOperation suppliesOperation = await client.StartTrainingAsync(officeSuppliesUri, useLabels, suppliesModelName);
4544
Response<CustomFormModel> suppliesOperationResponse = await suppliesOperation.WaitForCompletionAsync();
4645
CustomFormModel officeSuppliesModel = suppliesOperationResponse.Value;
4746

48-
//@@ Uri officeEquipmentUri = <purchaseOrderOfficeEquipmentUri>;
47+
#if SNIPPET
48+
Uri officeEquipmentUri = <purchaseOrderOfficeEquipmentUri>;
49+
#else
50+
Uri officeEquipmentUri = new Uri(trainingFileUrl);
51+
#endif
4952
string equipmentModelName = "Purchase order - Office Equipment";
5053

5154
TrainingOperation equipmentOperation = await client.StartTrainingAsync(officeEquipmentUri, useLabels, equipmentModelName);
5255
Response<CustomFormModel> equipmentOperationResponse = await equipmentOperation.WaitForCompletionAsync();
5356
CustomFormModel officeEquipmentModel = equipmentOperationResponse.Value;
5457

55-
//@@ Uri furnitureUri = <purchaseOrderFurnitureUri>;
58+
#if SNIPPET
59+
Uri furnitureUri = <purchaseOrderFurnitureUri>;
60+
#else
61+
Uri furnitureUri = new Uri(trainingFileUrl);
62+
#endif
5663
string furnitureModelName = "Purchase order - Furniture";
5764

5865
TrainingOperation furnitureOperation = await client.StartTrainingAsync(furnitureUri, useLabels, furnitureModelName);
5966
Response<CustomFormModel> furnitureOperationResponse = await furnitureOperation.WaitForCompletionAsync();
6067
CustomFormModel furnitureModel = furnitureOperationResponse.Value;
6168

62-
//@@ Uri cleaningSuppliesUri = <purchaseOrderCleaningSuppliesUri>;
69+
#if SNIPPET
70+
Uri cleaningSuppliesUri = <purchaseOrderCleaningSuppliesUri>;
71+
#else
72+
Uri cleaningSuppliesUri = new Uri(trainingFileUrl);
73+
#endif
6374
string cleaningModelName = "Purchase order - Cleaning Supplies";
6475

6576
TrainingOperation cleaningOperation = await client.StartTrainingAsync(cleaningSuppliesUri, useLabels, cleaningModelName);
@@ -112,11 +123,13 @@ public async Task CreateComposedModel()
112123

113124
#endregion
114125

115-
string purchaseOrderFilePath = FormRecognizerTestEnvironment.CreatePath("Form_1.jpg");
116-
117126
#region Snippet:FormRecognizerSampleRecognizeCustomFormWithComposedModel
118127

119-
//@@ string purchaseOrderFilePath = "<purchaseOrderFilePath>";
128+
#if SNIPPET
129+
string purchaseOrderFilePath = "<purchaseOrderFilePath>";
130+
#else
131+
string purchaseOrderFilePath = FormRecognizerTestEnvironment.CreatePath("Form_1.jpg");
132+
#endif
120133
FormRecognizerClient recognizeClient = client.GetFormRecognizerClient();
121134
using var stream = new FileStream(purchaseOrderFilePath, FileMode.Open);
122135

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/samples/Sample12_RecognizeBusinessCardsFromFile.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ public async Task RecognizeBusinessCardsFromFile()
2222

2323
FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2424

25-
string businessCardsPath = FormRecognizerTestEnvironment.CreatePath("businessCard.jpg");
26-
2725
#region Snippet:FormRecognizerSampleRecognizeBusinessCardFileStream
28-
//@@ string businessCardsPath = "<businessCardsPath>";
26+
#if SNIPPET
27+
string businessCardsPath = "<businessCardsPath>";
28+
#else
29+
string businessCardsPath = FormRecognizerTestEnvironment.CreatePath("businessCard.jpg");
30+
#endif
2931

3032
using var stream = new FileStream(businessCardsPath, FileMode.Open);
3133
var options = new RecognizeBusinessCardsOptions() { Locale = "en-US" };

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/samples/Sample12_RecognizeBusinessCardsFromUri.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ public async Task RecognizeBusinessCardsFromUri()
2121

2222
FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2323

24-
Uri businessCardUri = FormRecognizerTestEnvironment.CreateUri("businessCard.jpg");
25-
2624
#region Snippet:FormRecognizerSampleRecognizeBusinessCardsFromUri
27-
//@@ Uri businessCardUri = <businessCardUri>;
25+
#if SNIPPET
26+
Uri businessCardUri = <businessCardUri>;
27+
#else
28+
Uri businessCardUri = FormRecognizerTestEnvironment.CreateUri("businessCard.jpg");
29+
#endif
2830

2931
RecognizeBusinessCardsOperation operation = await client.StartRecognizeBusinessCardsFromUriAsync(businessCardUri);
3032
Response<RecognizedFormCollection> operationResponse = await operation.WaitForCompletionAsync();

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/samples/Sample13_RecognizeInvoicesFromFile.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ public async Task RecognizeInvoicesFromFile()
2323

2424
FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2525

26-
string invoicePath = FormRecognizerTestEnvironment.CreatePath("recommended_invoice.jpg");
27-
2826
#region Snippet:FormRecognizerSampleRecognizeInvoicesFileStream
29-
//@@ string invoicePath = "<invoicePath>";
27+
#if SNIPPET
28+
string invoicePath = "<invoicePath>";
29+
#else
30+
string invoicePath = FormRecognizerTestEnvironment.CreatePath("recommended_invoice.jpg");
31+
#endif
3032

3133
using var stream = new FileStream(invoicePath, FileMode.Open);
3234
var options = new RecognizeInvoicesOptions() { Locale = "en-US" };

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/samples/Sample13_RecognizeInvoicesFromUri.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ public async Task RecognizeInvoicesFromUri()
2222

2323
FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2424

25-
Uri invoiceUri = FormRecognizerTestEnvironment.CreateUri("recommended_invoice.jpg");
26-
2725
#region Snippet:FormRecognizerSampleRecognizeInvoicesUri
28-
//@@ Uri invoiceUri = <invoiceUri>;
26+
#if SNIPPET
27+
Uri invoiceUri = <invoiceUri>;
28+
#else
29+
Uri invoiceUri = FormRecognizerTestEnvironment.CreateUri("recommended_invoice.jpg");
30+
#endif
2931
var options = new RecognizeInvoicesOptions() { Locale = "en-US" };
3032

3133
RecognizeInvoicesOperation operation = await client.StartRecognizeInvoicesFromUriAsync(invoiceUri, options);

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/samples/Sample15_RecognizeIdDocumentsFromFile.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ public async Task RecognizeIdDocumentsFromFile()
2222

2323
FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2424

25-
string sourcePath = FormRecognizerTestEnvironment.CreatePath("license.jpg");
26-
2725
#region Snippet:FormRecognizerSampleRecognizeIdDocumentsFileStream
28-
//@@ string sourcePath = "<sourcePath>";
26+
#if SNIPPET
27+
string sourcePath = "<sourcePath>";
28+
#else
29+
string sourcePath = FormRecognizerTestEnvironment.CreatePath("license.jpg");
30+
#endif
2931

3032
using var stream = new FileStream(sourcePath, FileMode.Open);
3133

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/samples/Sample15_RecognizeIdDocumentsFromUri.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ public async Task RecognizeIdDocumentsFromUri()
2121

2222
FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2323

24-
Uri sourceUri = FormRecognizerTestEnvironment.CreateUri("license.jpg");
25-
2624
#region Snippet:FormRecognizerSampleRecognizeIdDocumentsUri
27-
//@@ string sourceUri = "<sourceUri>";
25+
#if SNIPPET
26+
Uri sourceUri = "<sourceUri>";
27+
#else
28+
Uri sourceUri = FormRecognizerTestEnvironment.CreateUri("license.jpg");
29+
#endif
2830

2931
RecognizeIdDocumentsOperation operation = await client.StartRecognizeIdDocumentsFromUriAsync(sourceUri);
3032
Response<RecognizedFormCollection> operationResponse = await operation.WaitForCompletionAsync();

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/samples/Sample1_RecognizeContentFromFile.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ public async Task RecognizeContentFromFile()
2121

2222
FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2323

24-
string filePath = FormRecognizerTestEnvironment.CreatePath("Invoice_1.pdf");
25-
2624
#region Snippet:FormRecognizerRecognizeFormContentFromFile
27-
//@@ string filePath = "filePath";
25+
#if SNIPPET
26+
string filePath = "filePath";
27+
#else
28+
string filePath = FormRecognizerTestEnvironment.CreatePath("Invoice_1.pdf");
29+
#endif
2830
using var stream = new FileStream(filePath, FileMode.Open);
2931

3032
Response<FormPageCollection> response = await client.StartRecognizeContentAsync(stream).WaitForCompletionAsync();

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/samples/Sample1_RecognizeContentFromUri.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ public async Task RecognizeContentFromUri()
2020

2121
FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2222

23-
Uri formUri = FormRecognizerTestEnvironment.CreateUri("Invoice_1.pdf");
24-
2523
#region Snippet:FormRecognizerSampleRecognizeContentFromUri
26-
//@@ Uri formUri = <formUri>;
24+
#if SNIPPET
25+
Uri formUri = <formUri>;
26+
#else
27+
Uri formUri = FormRecognizerTestEnvironment.CreateUri("Invoice_1.pdf");
28+
#endif
2729

2830
Response<FormPageCollection> response = await client.StartRecognizeContentFromUriAsync(formUri).WaitForCompletionAsync();
2931
FormPageCollection formPages = response.Value;

0 commit comments

Comments
 (0)