Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Custom form recognition without labels can now handle multipaged forms.
- `RecognizedForm.Pages` now only contains pages whose numbers are within `RecognizedForm.PageRange`.
- `FieldText.TextContent` cannot be `null` anymore, and it will be empty when no element is returned from the service.
- Custom form recognition with labels can now parse results from forms that do not contain all of the expected labels ([#11821](https://github.com/Azure/azure-sdk-for-net/issues/11821)).

## 1.0.0-preview.2 (05-06-2020)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected FormTrainingClient()
/// <summary>
/// Initializes a new instance of the <see cref="FormTrainingClient"/> class.
/// </summary>
/// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service. The URI is likely to be similar to <c>{protocol}://{resourcename}.cognitiveservices.azure.com</c>.</param>
/// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param>
Comment thread
kinelski marked this conversation as resolved.
/// <param name="credential">A credential used to authenticate to an Azure Service.</param>
/// <remarks>
/// Both the <paramref name="endpoint"/> URI <c>string</c> and the <paramref name="credential"/> <c>string</c> key
Expand All @@ -48,7 +48,7 @@ protected FormTrainingClient()
/// <summary>
/// Initializes a new instance of the <see cref="FormTrainingClient"/> class.
/// </summary>
/// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service. The URI is likely to be similar to <c>{protocol}://{resourcename}.cognitiveservices.azure.com</c>.</param>
/// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param>
/// <param name="credential">A credential used to authenticate to an Azure Service.</param>
/// <param name="options">A set of options to apply when configuring the client.</param>
/// <remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ private static IReadOnlyDictionary<string, FormField> ConvertSupervisedFields(IR

foreach (var field in fields)
{
fieldDictionary[field.Key] = new FormField(field.Key, field.Value, readResults);
fieldDictionary[field.Key] = field.Value == null
? null
: new FormField(field.Key, field.Value, readResults);
}

return fieldDictionary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,33 @@ public async Task StartRecognizeCustomFormsWithLabelsCanParseMultipageForms(bool
}
}

[Test]
public async Task StartRecognizeCustomFormsWithLabelsCanParseDifferentTypeOfForm()
{
var client = CreateInstrumentedFormRecognizerClient();
RecognizeCustomFormsOperation operation;

// Use Form_<id>.<ext> files for training with labels.

await using var trainedModel = await CreateDisposableTrainedModelAsync(useTrainingLabels: true);

// Attempt to recognize a different type of form: Invoice_1.pdf. This form does not contain all the labels
// the newly trained model expects.

using var stream = new FileStream(FormRecognizerTestEnvironment.RetrieveInvoicePath(1, ContentType.Pdf), FileMode.Open);
using (Recording.DisableRequestBodyRecording())
{
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream);
}

RecognizedFormCollection forms = await operation.WaitForCompletionAsync();
var fields = forms.Single().Fields;

// Verify that we got back at least one null field to make sure we hit the code path we want to test.

Assert.IsTrue(fields.Any(kvp => kvp.Value == null));
}

/// <summary>
/// Verifies that the <see cref="FormRecognizerClient" /> is able to connect to the Form
/// Recognizer cognitive service and perform analysis based on a custom labeled model.
Expand Down
Loading