| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | namespace Azure.AI.FormRecognizer.Models |
| | 5 | | { |
| | 6 | | /// <summary> |
| | 7 | | /// Represents a field recognized in the input form, where the field's value is of a known type. |
| | 8 | | /// </summary> |
| | 9 | | /// <typeparam name="T">The type of the value in the field this instance represents.</typeparam> |
| | 10 | | public class FormField<T> |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Initializes a new instance of the <see cref="FormField{T}"/> class. |
| | 14 | | /// </summary> |
| | 15 | | /// <param name="field">The weakly-typed field this instance is associated with.</param> |
| | 16 | | /// <param name="value">The strongly-typed value of this <see cref="FormField{T}"/>.</param> |
| 0 | 17 | | public FormField(FormField field, T value) |
| | 18 | | { |
| 0 | 19 | | Confidence = field.Confidence; |
| 0 | 20 | | LabelData = field.LabelData; |
| 0 | 21 | | Name = field.Name; |
| 0 | 22 | | ValueData = field.ValueData; |
| 0 | 23 | | Value = value; |
| 0 | 24 | | } |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// Canonical name; uniquely identifies a field within the form. |
| | 28 | | /// </summary> |
| 0 | 29 | | public string Name { get; } |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// Contains the text, bounding box and content of the label of the field in the form. |
| | 33 | | /// </summary> |
| 0 | 34 | | public FieldData LabelData { get; } |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Contains the text, bounding box and content of the value of the field in the form. |
| | 38 | | /// </summary> |
| 0 | 39 | | public FieldData ValueData { get; } |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// The strongly-typed value of this <see cref="FormField{T}"/>. |
| | 43 | | /// </summary> |
| 0 | 44 | | public T Value { get; } |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Measures the degree of certainty of the recognition result. Value is between [0.0, 1.0]. |
| | 48 | | /// </summary> |
| 0 | 49 | | public float Confidence { get; } |
| | 50 | |
|
| | 51 | | /// <summary> |
| | 52 | | /// Implicitly converts a <see cref="FormField{T}"/> instance into a <typeparamref name="T"/>, using the |
| | 53 | | /// value returned by <see cref="Value"/>. |
| | 54 | | /// </summary> |
| | 55 | | /// <param name="field">The instance to be converted into a <typeparamref name="T"/>.</param> |
| | 56 | | /// <returns>The <typeparamref name="T"/> corresponding to the value of the specified <see cref="FormField"/> in |
| 0 | 57 | | public static implicit operator T(FormField<T> field) => field.Value; |
| | 58 | | } |
| | 59 | | } |