Skip to content

Commit 4709b92

Browse files
authored
[DocumentIntelligence] Merging 1.0.0 features into main (Azure#47492)
* [DocumentIntelligence] Regenerating and applying architect feedback (Azure#47392) * [DocumentIntelligence] Applying architect feedback (Azure#47433) * [DocumentIntelligence] Addressing more architect feedback (Azure#47468) * [DocumentIntelligence] Some more architect feedback (Azure#47479) * [DocumentIntelligence] Recording tests targeting 2024-11-30 (Azure#47483)
1 parent 5030a35 commit 4709b92

File tree

150 files changed

+4926
-3624
lines changed

Some content is hidden

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

150 files changed

+4926
-3624
lines changed

sdk/documentintelligence/Azure.AI.DocumentIntelligence/CHANGELOG.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,59 @@
33
## 1.0.0-beta.4 (Unreleased)
44

55
### Features Added
6-
6+
- Added methods `GetAnalyzeBatchResult`, `GetAnalyzeBatchResults`, `DeleteAnalyzeBatchResult`, and `DeleteAnalyzeResult` to `DocumentIntelligenceClient`.
7+
- Added class `AnalyzeBatchOperationDetails` to be used as the output of the `GetAnalyzeBatchResult` and `GetAnalyzeBatchResults` APIs.
8+
- Added property `ModifiedOn` to `DocumentModelDetails` and to `DocumentClassifierDetails`.
9+
- Added member `Skipped` to `DocumentIntelligenceOperationStatus` (former `OperationStatus`).
710
- Exposed `JsonModelWriteCore` for model serialization procedure.
811

912
### Breaking Changes
13+
- Replaced the following `Content` classes with new corresponding `Options` classes:
14+
- `AnalyzeBatchDocumentsContent` to `AnalyzeBatchDocumentsOptions`.
15+
- `AnalyzeDocumentContent` to `AnalyzeDocumentOptions`.
16+
- `AuthorizeClassifierCopyContent` to `AuthorizeClassifierCopyOptions`.
17+
- `AuthorizeCopyContent` to `AuthorizeModelCopyOptions`.
18+
- `BuildDocumentClassifierContent` to `BuildClassifierOptions`.
19+
- `BuildDocumentModelContent` to `BuildDocumentModelOptions`.
20+
- `ClassifyDocumentContent` to `ClassifyDocumentOptions`.
21+
- `ComposeDocumentModelContent` to `ComposeModelOptions`.
22+
- Parameters of the `AnalyzeBatchDocuments`, `AnalyzeDocument`, and `ClassifyDocument` methods have been moved into their corresponding `Options` class.
23+
- Updated parameter `resultId` of methods `GetAnalyzeResultPdf` and `GetAnalyzeResultFigure` to take a `string` instead of a `Guid`.
24+
- Renamed all occurrences of property `UrlSource` to `UriSource`.
25+
- Renamed all occurrences of properties `DocType` and `DocTypes` to `DocumentType` and `DocumentTypes`, respectively.
26+
- In `DocumentField`, renamed properties `Type` and `ValueLong` to `FieldType` and `ValueInt64`, respectively.
27+
- Renamed property `Type` to `FieldType` in `DocumentFieldSchema`.
28+
- Renamed class `AzureBlobContentSource` to `BlobContentSource`.
29+
- Renamed class `AzureBlobFileListContentSource` to `BlobFileListContentSource`.
30+
- Renamed all occurrences of properties `AzureBlobSource` and `AzureBlobFileListSource` to `BlobSource` and `BlobFileListSource`, respectively.
31+
- Renamed all occurrences of property `ContainerUrl` to `ContainerUri`.
32+
- Renamed property `ResultContainerUrl` to `ResultContainerUri` in `AnalyzeBatchDocumentsContent`.
33+
- Renamed class `AnalyzeBatchOperationDetail` to `AnalyzeBatchResultDetails`.
34+
- In `AnalyzeBatchResultDetails` (former `AnalyzeBatchOperationDetail`), renamed properties `SourceUrl` and `ResultUrl` to `SourceUri` and `ResultUri`, respectively.
35+
- Removed member `Generative` from `DocumentBuildMode`.
36+
- Renamed member `StyleFonts` to `FontStyling` in `DocumentAnalysisFeature`.
37+
- In `ContentSourceKind`, renamed members `Url`, `Base64`, `AzureBlob`, and `AzureBlobFileList` to `Uri`, `Bytes`, `Blob`, and `BlobFileList`, respectively.
38+
- Renamed all occurrences of property `ExpirationDateTime` to `ExpiresOn`.
39+
- Renamed method `GetResourceInfo` to `GetResourceDetails` in `DocumentIntelligenceAdministrationClient`.
40+
- Renamed class `ResourceDetails` to `DocumentIntelligenceResourceDetails`.
41+
- Renamed type `ContentFormat` to `DocumentContentFormat`.
42+
- Renamed class `OperationDetails` to `DocumentIntelligenceOperationDetails`.
43+
- Renamed class `InnerError` to `DocumentIntelligenceInnerError`.
44+
- Renamed class `CopyAuthorization` to `ModelCopyAuthorization`.
45+
- Renamed type `OperationStatus` to `DocumentIntelligenceOperationStatus`.
46+
- Renamed property `Innererror` to `InnerError` in `DocumentIntelligenceError`.
47+
- Renamed property `InnerErrorObject` to `InnerError` in `DocumentIntelligenceInnerError` (former class `InnerError`).
48+
- Removed member `Completed` from `DocumentIntelligenceOperationStatus` (former `OperationStatus`).
49+
- Removed type `StringIndexType`.
50+
- Removed property `StringIndexType` in `AnalyzeResult`.
51+
- Updated property `Fields` in `AnalyzedDocument` to be a `DocumentFieldDictionary` instead of an `IReadOnly<string, DocumentField>`.
52+
- Updated property `ValueDictionary` in `DocumentField` to be a `DocumentFieldDictionary` instead of an `IReadOnly<string, DocumentField>`.
53+
- Made type `BoundingRegion` a `struct`.
54+
- Made type `DocumentSpan` a `struct`.
1055

1156
### Bugs Fixed
1257
- Fixed a bug where calling `Operation.Id` would sometimes return an `InvalidOperationException` with message "The operation ID was not present in the service response.".
58+
- Calling `Operation.Id` in an operation returned from the `AnalyzeBatchDocuments` and `ClassifyDocument` APIs won't throw a `NotSupportedException` anymore.
1359

1460
### Other Changes
1561

sdk/documentintelligence/Azure.AI.DocumentIntelligence/MigrationGuide.md

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,9 @@ Analyzing documents with `Azure.AI.DocumentIntelligence`:
215215
```C# Snippet:DocumentIntelligenceAnalyzeWithPrebuiltModelFromUriAsync
216216
Uri uriSource = new Uri("<uriSource>");
217217

218-
var content = new AnalyzeDocumentContent()
219-
{
220-
UrlSource = uriSource
221-
};
218+
var options = new AnalyzeDocumentOptions("prebuilt-invoice", uriSource);
222219

223-
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-invoice", content);
220+
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, options);
224221
AnalyzeResult result = operation.Value;
225222

226223
// To see the list of all the supported fields returned by service and its corresponding types for the
@@ -234,39 +231,39 @@ for (int i = 0; i < result.Documents.Count; i++)
234231
AnalyzedDocument document = result.Documents[i];
235232

236233
if (document.Fields.TryGetValue("VendorName", out DocumentField vendorNameField)
237-
&& vendorNameField.Type == DocumentFieldType.String)
234+
&& vendorNameField.FieldType == DocumentFieldType.String)
238235
{
239236
string vendorName = vendorNameField.ValueString;
240237
Console.WriteLine($"Vendor Name: '{vendorName}', with confidence {vendorNameField.Confidence}");
241238
}
242239

243240
if (document.Fields.TryGetValue("CustomerName", out DocumentField customerNameField)
244-
&& customerNameField.Type == DocumentFieldType.String)
241+
&& customerNameField.FieldType == DocumentFieldType.String)
245242
{
246243
string customerName = customerNameField.ValueString;
247244
Console.WriteLine($"Customer Name: '{customerName}', with confidence {customerNameField.Confidence}");
248245
}
249246

250247
if (document.Fields.TryGetValue("Items", out DocumentField itemsField)
251-
&& itemsField.Type == DocumentFieldType.List)
248+
&& itemsField.FieldType == DocumentFieldType.List)
252249
{
253250
foreach (DocumentField itemField in itemsField.ValueList)
254251
{
255252
Console.WriteLine("Item:");
256253

257-
if (itemField.Type == DocumentFieldType.Dictionary)
254+
if (itemField.FieldType == DocumentFieldType.Dictionary)
258255
{
259256
IReadOnlyDictionary<string, DocumentField> itemFields = itemField.ValueDictionary;
260257

261258
if (itemFields.TryGetValue("Description", out DocumentField itemDescriptionField)
262-
&& itemDescriptionField.Type == DocumentFieldType.String)
259+
&& itemDescriptionField.FieldType == DocumentFieldType.String)
263260
{
264261
string itemDescription = itemDescriptionField.ValueString;
265262
Console.WriteLine($" Description: '{itemDescription}', with confidence {itemDescriptionField.Confidence}");
266263
}
267264

268265
if (itemFields.TryGetValue("Amount", out DocumentField itemAmountField)
269-
&& itemAmountField.Type == DocumentFieldType.Currency)
266+
&& itemAmountField.FieldType == DocumentFieldType.Currency)
270267
{
271268
CurrencyValue itemAmount = itemAmountField.ValueCurrency;
272269
Console.WriteLine($" Amount: '{itemAmount.CurrencySymbol}{itemAmount.Amount}', with confidence {itemAmountField.Confidence}");
@@ -276,21 +273,21 @@ for (int i = 0; i < result.Documents.Count; i++)
276273
}
277274

278275
if (document.Fields.TryGetValue("SubTotal", out DocumentField subTotalField)
279-
&& subTotalField.Type == DocumentFieldType.Currency)
276+
&& subTotalField.FieldType == DocumentFieldType.Currency)
280277
{
281278
CurrencyValue subTotal = subTotalField.ValueCurrency;
282279
Console.WriteLine($"Sub Total: '{subTotal.CurrencySymbol}{subTotal.Amount}', with confidence {subTotalField.Confidence}");
283280
}
284281

285282
if (document.Fields.TryGetValue("TotalTax", out DocumentField totalTaxField)
286-
&& totalTaxField.Type == DocumentFieldType.Currency)
283+
&& totalTaxField.FieldType == DocumentFieldType.Currency)
287284
{
288285
CurrencyValue totalTax = totalTaxField.ValueCurrency;
289286
Console.WriteLine($"Total Tax: '{totalTax.CurrencySymbol}{totalTax.Amount}', with confidence {totalTaxField.Confidence}");
290287
}
291288

292289
if (document.Fields.TryGetValue("InvoiceTotal", out DocumentField invoiceTotalField)
293-
&& invoiceTotalField.Type == DocumentFieldType.Currency)
290+
&& invoiceTotalField.FieldType == DocumentFieldType.Currency)
294291
{
295292
CurrencyValue invoiceTotal = invoiceTotalField.ValueCurrency;
296293
Console.WriteLine($"Invoice Total: '{invoiceTotal.CurrencySymbol}{invoiceTotal.Amount}', with confidence {invoiceTotalField.Confidence}");
@@ -325,19 +322,16 @@ Classifying documents with `Azure.AI.DocumentIntelligence`:
325322
string classifierId = "<classifierId>";
326323
Uri uriSource = new Uri("<uriSource>");
327324

328-
var content = new ClassifyDocumentContent()
329-
{
330-
UrlSource = uriSource
331-
};
325+
var options = new ClassifyDocumentOptions(classifierId, uriSource);
332326

333-
Operation<AnalyzeResult> operation = await client.ClassifyDocumentAsync(WaitUntil.Completed, classifierId, content);
327+
Operation<AnalyzeResult> operation = await client.ClassifyDocumentAsync(WaitUntil.Completed, options);
334328
AnalyzeResult result = operation.Value;
335329

336330
Console.WriteLine($"Input was classified by the classifier with ID '{result.ModelId}'.");
337331

338332
foreach (AnalyzedDocument document in result.Documents)
339333
{
340-
Console.WriteLine($"Found a document of type: {document.DocType}");
334+
Console.WriteLine($"Found a document of type: {document.DocumentType}");
341335
}
342336
```
343337

@@ -386,19 +380,17 @@ Uri blobContainerUri = new Uri("<blobContainerUri>");
386380
// build modes and their differences, see:
387381
// https://aka.ms/azsdk/formrecognizer/buildmode
388382
389-
var content = new BuildDocumentModelContent(modelId, DocumentBuildMode.Template)
390-
{
391-
AzureBlobSource = new AzureBlobContentSource(blobContainerUri)
392-
};
383+
var blobSource = new BlobContentSource(blobContainerUri);
384+
var options = new BuildDocumentModelOptions(modelId, DocumentBuildMode.Template, blobSource);
393385

394-
Operation<DocumentModelDetails> operation = await client.BuildDocumentModelAsync(WaitUntil.Completed, content);
386+
Operation<DocumentModelDetails> operation = await client.BuildDocumentModelAsync(WaitUntil.Completed, options);
395387
DocumentModelDetails model = operation.Value;
396388

397389
Console.WriteLine($"Model ID: {model.ModelId}");
398390
Console.WriteLine($"Created on: {model.CreatedOn}");
399391

400392
Console.WriteLine("Document types the model can recognize:");
401-
foreach (KeyValuePair<string, DocumentTypeDetails> docType in model.DocTypes)
393+
foreach (KeyValuePair<string, DocumentTypeDetails> docType in model.DocumentTypes)
402394
{
403395
Console.WriteLine($" Document type: '{docType.Key}', which has the following fields:");
404396
foreach (KeyValuePair<string, DocumentFieldSchema> schema in docType.Value.FieldSchema)
@@ -414,16 +406,14 @@ foreach (KeyValuePair<string, DocumentTypeDetails> docType in model.DocTypes)
414406

415407
Currently neither `AnalyzeDocument` nor `ClassifyDocument` support submitting a document from a `Stream` input. As a temporary workaround, you can make use of the new Base64 input option. The following example illustrates how to submit a local file for analysis:
416408

417-
```C# Snippet:DocumentIntelligenceAnalyzeWithPrebuiltModelWithBase64Async
409+
```C# Snippet:DocumentIntelligenceAnalyzeWithPrebuiltModelFromBytesAsync
418410
string filePath = "<filePath>";
419411
byte[] fileBytes = File.ReadAllBytes(filePath);
420412

421-
var content = new AnalyzeDocumentContent()
422-
{
423-
Base64Source = BinaryData.FromBytes(fileBytes)
424-
};
413+
var bytesSource = BinaryData.FromBytes(fileBytes);
414+
var options = new AnalyzeDocumentOptions("prebuilt-invoice", bytesSource);
425415

426-
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-invoice", content);
416+
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, options);
427417
AnalyzeResult result = operation.Value;
428418

429419
// To see the list of all the supported fields returned by service and its corresponding types for the
@@ -437,39 +427,39 @@ for (int i = 0; i < result.Documents.Count; i++)
437427
AnalyzedDocument document = result.Documents[i];
438428

439429
if (document.Fields.TryGetValue("VendorName", out DocumentField vendorNameField)
440-
&& vendorNameField.Type == DocumentFieldType.String)
430+
&& vendorNameField.FieldType == DocumentFieldType.String)
441431
{
442432
string vendorName = vendorNameField.ValueString;
443433
Console.WriteLine($"Vendor Name: '{vendorName}', with confidence {vendorNameField.Confidence}");
444434
}
445435

446436
if (document.Fields.TryGetValue("CustomerName", out DocumentField customerNameField)
447-
&& customerNameField.Type == DocumentFieldType.String)
437+
&& customerNameField.FieldType == DocumentFieldType.String)
448438
{
449439
string customerName = customerNameField.ValueString;
450440
Console.WriteLine($"Customer Name: '{customerName}', with confidence {customerNameField.Confidence}");
451441
}
452442

453443
if (document.Fields.TryGetValue("Items", out DocumentField itemsField)
454-
&& itemsField.Type == DocumentFieldType.List)
444+
&& itemsField.FieldType == DocumentFieldType.List)
455445
{
456446
foreach (DocumentField itemField in itemsField.ValueList)
457447
{
458448
Console.WriteLine("Item:");
459449

460-
if (itemField.Type == DocumentFieldType.Dictionary)
450+
if (itemField.FieldType == DocumentFieldType.Dictionary)
461451
{
462452
IReadOnlyDictionary<string, DocumentField> itemFields = itemField.ValueDictionary;
463453

464454
if (itemFields.TryGetValue("Description", out DocumentField itemDescriptionField)
465-
&& itemDescriptionField.Type == DocumentFieldType.String)
455+
&& itemDescriptionField.FieldType == DocumentFieldType.String)
466456
{
467457
string itemDescription = itemDescriptionField.ValueString;
468458
Console.WriteLine($" Description: '{itemDescription}', with confidence {itemDescriptionField.Confidence}");
469459
}
470460

471461
if (itemFields.TryGetValue("Amount", out DocumentField itemAmountField)
472-
&& itemAmountField.Type == DocumentFieldType.Currency)
462+
&& itemAmountField.FieldType == DocumentFieldType.Currency)
473463
{
474464
CurrencyValue itemAmount = itemAmountField.ValueCurrency;
475465
Console.WriteLine($" Amount: '{itemAmount.CurrencySymbol}{itemAmount.Amount}', with confidence {itemAmountField.Confidence}");
@@ -479,21 +469,21 @@ for (int i = 0; i < result.Documents.Count; i++)
479469
}
480470

481471
if (document.Fields.TryGetValue("SubTotal", out DocumentField subTotalField)
482-
&& subTotalField.Type == DocumentFieldType.Currency)
472+
&& subTotalField.FieldType == DocumentFieldType.Currency)
483473
{
484474
CurrencyValue subTotal = subTotalField.ValueCurrency;
485475
Console.WriteLine($"Sub Total: '{subTotal.CurrencySymbol}{subTotal.Amount}', with confidence {subTotalField.Confidence}");
486476
}
487477

488478
if (document.Fields.TryGetValue("TotalTax", out DocumentField totalTaxField)
489-
&& totalTaxField.Type == DocumentFieldType.Currency)
479+
&& totalTaxField.FieldType == DocumentFieldType.Currency)
490480
{
491481
CurrencyValue totalTax = totalTaxField.ValueCurrency;
492482
Console.WriteLine($"Total Tax: '{totalTax.CurrencySymbol}{totalTax.Amount}', with confidence {totalTaxField.Confidence}");
493483
}
494484

495485
if (document.Fields.TryGetValue("InvoiceTotal", out DocumentField invoiceTotalField)
496-
&& invoiceTotalField.Type == DocumentFieldType.Currency)
486+
&& invoiceTotalField.FieldType == DocumentFieldType.Currency)
497487
{
498488
CurrencyValue invoiceTotal = invoiceTotalField.ValueCurrency;
499489
Console.WriteLine($"Invoice Total: '{invoiceTotal.CurrencySymbol}{invoiceTotal.Amount}', with confidence {invoiceTotalField.Confidence}");
@@ -533,12 +523,9 @@ Note that it's necessary to pass the `DocumentPage` containing the line to the m
533523
```C# Snippet:Migration_DocumentIntelligenceGetWordsUsage
534524
Uri uriSource = new Uri("<uriSource>");
535525

536-
var content = new AnalyzeDocumentContent()
537-
{
538-
UrlSource = uriSource
539-
};
526+
var options = new AnalyzeDocumentOptions("prebuilt-invoice", uriSource);
540527

541-
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-invoice", content);
528+
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, options);
542529
AnalyzeResult result = operation.Value;
543530

544531
DocumentPage firstPage = result.Pages[0];

0 commit comments

Comments
 (0)