Skip to content

Commit cad82db

Browse files
authored
[FormRecognizer] Making sure snippets can be compiled (Azure#27651)
1 parent dcfa430 commit cad82db

File tree

48 files changed

+120
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+120
-113
lines changed

sdk/formrecognizer/Azure.AI.FormRecognizer/MigrationGuide.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Differences between the versions:
9696

9797
Analyzing prebuilt models like business cards, identity documents, invoices, and receipts with `3.1.x`:
9898
```C# Snippet:FormRecognizerSampleRecognizeInvoicesUri
99-
Uri invoiceUri = <invoiceUri>;
99+
Uri invoiceUri = new Uri("<invoiceUri>");
100100
var options = new RecognizeInvoicesOptions() { Locale = "en-US" };
101101

102102
RecognizeInvoicesOperation operation = await client.StartRecognizeInvoicesFromUriAsync(invoiceUri, options);
@@ -222,7 +222,7 @@ Analyzing prebuilt models like business cards, identity documents, invoices, and
222222

223223
Analyzing prebuilt models like business cards, identity documents, invoices, and receipts with `4.0.x`:
224224
```C# Snippet:FormRecognizerAnalyzeWithPrebuiltModelFromUriAsync
225-
string fileUri = "<fileUri>";
225+
Uri fileUri = new Uri("<fileUri>");
226226

227227
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-invoice", fileUri);
228228

@@ -328,7 +328,7 @@ Analyzing document content with `3.1.x`:
328328
> NOTE: With version `3.1.x` of the library this method had an optional `Language` parameter to hint at the language for the document, whereas in version `4.0.x` of the library `Locale` is used for this purpose.
329329
330330
```C# Snippet:FormRecognizerSampleRecognizeContentFromUri
331-
Uri formUri = <formUri>;
331+
Uri formUri = new Uri("<formUri>");
332332

333333
Response<FormPageCollection> response = await client.StartRecognizeContentFromUriAsync(formUri).WaitForCompletionAsync();
334334
FormPageCollection formPages = response.Value;
@@ -384,7 +384,7 @@ foreach (FormPage page in formPages)
384384

385385
Analyzing document layout with `4.0.x`:
386386
```C# Snippet:FormRecognizerExtractLayoutFromUriAsync
387-
string fileUri = "<fileUri>";
387+
Uri fileUri = new Uri("<fileUri>");
388388

389389
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-layout", fileUri);
390390

@@ -459,7 +459,7 @@ Analyzing general prebuilt document types with `4.0.x`:
459459
> NOTE: Analyzing a document with the `prebuilt-document` model replaces training without labels in version `3.1.x` of the library.
460460
461461
```C# Snippet:FormRecognizerAnalyzePrebuiltDocumentFromUriAsync
462-
string fileUri = "<fileUri>";
462+
Uri fileUri = new Uri("<fileUri>");
463463

464464
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-document", fileUri);
465465

@@ -579,7 +579,7 @@ Train a custom model with `3.1.x`:
579579
// For instructions to create a label file for your training forms, please see:
580580
// https://docs.microsoft.com/azure/cognitive-services/form-recognizer/label-tool?tabs=v2-1
581581
582-
Uri trainingFileUri = <trainingFileUri>;
582+
Uri trainingFileUri = new Uri("<trainingFileUri>");
583583
string modelName = "My Model with labels";
584584
FormTrainingClient client = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
585585

@@ -620,7 +620,7 @@ Train a custom model with `4.0.x`:
620620
// For instructions to set up documents for training in an Azure Blob Storage Container, please see:
621621
// https://aka.ms/azsdk/formrecognizer/buildcustommodel
622622
623-
Uri trainingFileUri = <trainingFileUri>;
623+
Uri trainingFileUri = new Uri("<trainingFileUri>");
624624
var client = new DocumentModelAdministrationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
625625

626626
// We are selecting the Template build mode in this sample. For more information about the available
@@ -656,7 +656,7 @@ Differences between the versions:
656656
Analyze a document using a custom model with `3.1.x`:
657657
```C# Snippet:FormRecognizerSampleRecognizeCustomFormsFromUri
658658
string modelId = "<modelId>";
659-
Uri formUri = <formUri>;
659+
Uri formUri = new Uri("<formUri>");
660660
var options = new RecognizeCustomFormsOptions() { IncludeFieldElements = true };
661661

662662
RecognizeCustomFormsOperation operation = await client.StartRecognizeCustomFormsFromUriAsync(modelId, formUri, options);
@@ -714,7 +714,7 @@ foreach (RecognizedForm form in forms)
714714
Analyze a document using a custom model with `4.0.x`:
715715
```C# Snippet:FormRecognizerAnalyzeWithCustomModelFromUriAsync
716716
string modelId = "<modelId>";
717-
string fileUri = "<fileUri>";
717+
Uri fileUri = new Uri("<fileUri>");
718718

719719
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync(modelId, fileUri);
720720

sdk/formrecognizer/Azure.AI.FormRecognizer/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ The following section provides several code snippets illustrating common pattern
208208
Extract text, selection marks, text styles, and table structures, along with their bounding region coordinates from documents.
209209

210210
```C# Snippet:FormRecognizerExtractLayoutFromUriAsync
211-
string fileUri = "<fileUri>";
211+
Uri fileUri = new Uri("<fileUri>");
212212

213213
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-layout", fileUri);
214214

@@ -284,7 +284,7 @@ For more information and samples see [here][extract_layout].
284284
Analyze key-value pairs, entities, tables, and selection marks from documents using the general prebuilt document model.
285285

286286
```C# Snippet:FormRecognizerAnalyzePrebuiltDocumentFromUriAsync
287-
string fileUri = "<fileUri>";
287+
Uri fileUri = new Uri("<fileUri>");
288288

289289
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-document", fileUri);
290290

@@ -388,7 +388,7 @@ For more information and samples see [here][analyze_prebuilt_document].
388388
Analyze textual elements, such as page words and lines, styles, and text language information from documents using the prebuilt read model.
389389

390390
```C# Snippet:FormRecognizerAnalyzePrebuiltReadFromUriAsync
391-
string fileUri = "<fileUri>";
391+
Uri fileUri = new Uri("<fileUri>");
392392

393393
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-read", fileUri);
394394

@@ -572,7 +572,7 @@ Build a custom model on your own document type. The resulting model can be used
572572
// For instructions to set up documents for training in an Azure Blob Storage Container, please see:
573573
// https://aka.ms/azsdk/formrecognizer/buildcustommodel
574574
575-
Uri trainingFileUri = <trainingFileUri>;
575+
Uri trainingFileUri = new Uri("<trainingFileUri>");
576576
var client = new DocumentModelAdministrationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
577577

578578
// We are selecting the Template build mode in this sample. For more information about the available
@@ -605,7 +605,7 @@ Analyze text, field values, selection marks, and table data from custom document
605605

606606
```C# Snippet:FormRecognizerAnalyzeWithCustomModelFromUriAsync
607607
string modelId = "<modelId>";
608-
string fileUri = "<fileUri>";
608+
Uri fileUri = new Uri("<fileUri>");
609609

610610
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync(modelId, fileUri);
611611

@@ -661,7 +661,7 @@ await foreach (DocumentModelInfo modelInfo in models)
661661
}
662662

663663
// Create a new model to store in the account
664-
Uri trainingFileUri = <trainingFileUri>;
664+
Uri trainingFileUri = new Uri("<trainingFileUri>");
665665
BuildModelOperation operation = await client.StartBuildModelAsync(trainingFileUri, DocumentBuildMode.Template);
666666
Response<DocumentModel> operationResponse = await operation.WaitForCompletionAsync();
667667
DocumentModel model = operationResponse.Value;
@@ -707,7 +707,7 @@ foreach (DocumentModelInfo modelInfo in models.Take(10))
707707

708708
// Create a new model to store in the account
709709
710-
Uri trainingFileUri = <trainingFileUri>;
710+
Uri trainingFileUri = new Uri("<trainingFileUri>");
711711
BuildModelOperation operation = client.StartBuildModel(trainingFileUri, DocumentBuildMode.Template);
712712
Response<DocumentModel> operationResponse = await operation.WaitForCompletionAsync();
713713
DocumentModel model = operationResponse.Value;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var client = new DocumentAnalysisClient(new Uri(endpoint), credential);
2222
To analyze a given file at a URI, use the `StartAnalyzeDocumentFromUri` method and pass `prebuilt-document` as the model ID. The returned value is an `AnalyzeResult` object containing data about the submitted document.
2323

2424
```C# Snippet:FormRecognizerAnalyzePrebuiltDocumentFromUriAsync
25-
string fileUri = "<fileUri>";
25+
Uri fileUri = new Uri("<fileUri>");
2626

2727
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-document", fileUri);
2828

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var client = new DocumentAnalysisClient(new Uri(endpoint), credential);
2222
To analyze a given file at a URI, use the `StartAnalyzeDocumentFromUri` method and pass `prebuilt-read` as the model ID. The returned value is an `AnalyzeResult` object containing data about the submitted document.
2323

2424
```C# Snippet:FormRecognizerAnalyzePrebuiltReadFromUriAsync
25-
string fileUri = "<fileUri>";
25+
Uri fileUri = new Uri("<fileUri>");
2626

2727
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-read", fileUri);
2828

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To analyze a given file at a URI, use the `StartAnalyzeDocumentFromUri` method.
2323

2424
```C# Snippet:FormRecognizerAnalyzeWithCustomModelFromUriAsync
2525
string modelId = "<modelId>";
26-
string fileUri = "<fileUri>";
26+
Uri fileUri = new Uri("<fileUri>");
2727

2828
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync(modelId, fileUri);
2929

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To analyze a given file at a URI, use the `StartAnalyzeDocumentFromUri` method.
3636
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 the [Choosing the prebuilt model ID][choosing-the-prebuilt-model-id] section.
3737

3838
```C# Snippet:FormRecognizerAnalyzeWithPrebuiltModelFromUriAsync
39-
string fileUri = "<fileUri>";
39+
Uri fileUri = new Uri("<fileUri>");
4040

4141
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-invoice", fileUri);
4242

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ A `DocumentModel` is returned indicating the document types the model will recog
3838
// For instructions to set up documents for training in an Azure Blob Storage Container, please see:
3939
// https://aka.ms/azsdk/formrecognizer/buildcustommodel
4040
41-
Uri trainingFileUri = <trainingFileUri>;
41+
Uri trainingFileUri = new Uri("<trainingFileUri>");
4242
var client = new DocumentModelAdministrationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
4343

4444
// We are selecting the Template build mode in this sample. For more information about the available

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ You can set `endpoint` and `apiKey` based on an environment variable, a configur
2121
The source client that contains the custom model we want to copy.
2222

2323
```C# Snippet:FormRecognizerSampleCreateCopySourceClient
24-
string endpoint = "<source_endpoint>";
25-
string apiKey = "<source_apiKey>";
26-
var sourcecredential = new AzureKeyCredential(apiKey);
27-
var sourceClient = new DocumentModelAdministrationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
24+
string sourceEndpoint = "<source_endpoint>";
25+
string sourceApiKey = "<source_apiKey>";
26+
var sourcecredential = new AzureKeyCredential(sourceApiKey);
27+
var sourceClient = new DocumentModelAdministrationClient(new Uri(sourceEndpoint), new AzureKeyCredential(sourceApiKey));
2828
```
2929

3030
### Target client
3131
The target client where we want to copy the custom model to.
3232

3333
```C# Snippet:FormRecognizerSampleCreateCopyTargetClient
34-
string endpoint = "<target_endpoint>";
35-
string apiKey = "<target_apiKey>";
36-
var targetCredential = new AzureKeyCredential(apiKey);
37-
var targetClient = new DocumentModelAdministrationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
34+
string targetEndpoint = "<target_endpoint>";
35+
string targetApiKey = "<target_apiKey>";
36+
var targetCredential = new AzureKeyCredential(targetApiKey);
37+
var targetClient = new DocumentModelAdministrationClient(new Uri(targetEndpoint), new AzureKeyCredential(targetApiKey));
3838
```
3939

4040
### Authorize the copy

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var client = new DocumentAnalysisClient(new Uri(endpoint), credential);
2222
To extract the layout from a given file at a URI, use the `StartAnalyzeDocumentFromUri` method and pass `prebuilt-layout` as the model ID. The returned value is an `AnalyzeResult` object containing data about the submitted document.
2323

2424
```C# Snippet:FormRecognizerExtractLayoutFromUriAsync
25-
string fileUri = "<fileUri>";
25+
Uri fileUri = new Uri("<fileUri>");
2626

2727
AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentFromUriAsync("prebuilt-layout", fileUri);
2828

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ If the operation failed, the error information can be accessed using the `Error`
2828
var client = new DocumentModelAdministrationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
2929

3030
// Make sure there is at least one operation, so we are going to build a custom model.
31-
Uri trainingFileUri = <trainingFileUri>;
31+
Uri trainingFileUri = new Uri("<trainingFileUri>");
3232
BuildModelOperation operation = await client.StartBuildModelAsync(trainingFileUri, DocumentBuildMode.Template);
3333
await operation.WaitForCompletionAsync();
3434

0 commit comments

Comments
 (0)