Skip to content

Commit

Permalink
update selection mark state and enable tests (#16041)
Browse files Browse the repository at this point in the history
  • Loading branch information
maririos authored Oct 16, 2020
1 parent 568a086 commit 9876881
Show file tree
Hide file tree
Showing 22 changed files with 21,321 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public readonly partial struct FieldValue
public System.DateTime AsDate() { throw null; }
public System.Collections.Generic.IReadOnlyDictionary<string, Azure.AI.FormRecognizer.Models.FormField> AsDictionary() { throw null; }
public float AsFloat() { throw null; }
public Azure.AI.FormRecognizer.Models.FormSelectionMarkState AsFormSelectionMarkState() { throw null; }
public long AsInt64() { throw null; }
public System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Models.FormField> AsList() { throw null; }
public string AsPhoneNumber() { throw null; }
public Azure.AI.FormRecognizer.Models.SelectionMarkState AsSelectionMarkState() { throw null; }
public string AsString() { throw null; }
public System.TimeSpan AsTime() { throw null; }
}
Expand Down Expand Up @@ -203,7 +203,7 @@ public static partial class FormRecognizerModelFactory
public static Azure.AI.FormRecognizer.Models.FieldValue FieldValueWithInt64ValueType(long value) { throw null; }
public static Azure.AI.FormRecognizer.Models.FieldValue FieldValueWithListValueType(System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Models.FormField> value) { throw null; }
public static Azure.AI.FormRecognizer.Models.FieldValue FieldValueWithPhoneNumberValueType(string value) { throw null; }
public static Azure.AI.FormRecognizer.Models.FieldValue FieldValueWithSelectionMarkValueType(Azure.AI.FormRecognizer.Models.FormSelectionMarkState value) { throw null; }
public static Azure.AI.FormRecognizer.Models.FieldValue FieldValueWithSelectionMarkValueType(Azure.AI.FormRecognizer.Models.SelectionMarkState value) { throw null; }
public static Azure.AI.FormRecognizer.Models.FieldValue FieldValueWithStringValueType(string value) { throw null; }
public static Azure.AI.FormRecognizer.Models.FieldValue FieldValueWithTimeValueType(System.TimeSpan value) { throw null; }
public static Azure.AI.FormRecognizer.Models.FormField FormField(string name, Azure.AI.FormRecognizer.Models.FieldData labelData, Azure.AI.FormRecognizer.Models.FieldData valueData, Azure.AI.FormRecognizer.Models.FieldValue value, float confidence) { throw null; }
Expand All @@ -214,7 +214,7 @@ public static partial class FormRecognizerModelFactory
public static Azure.AI.FormRecognizer.Models.FormPageCollection FormPageCollection(System.Collections.Generic.IList<Azure.AI.FormRecognizer.Models.FormPage> list) { throw null; }
public static Azure.AI.FormRecognizer.Models.FormPageRange FormPageRange(int firstPageNumber, int lastPageNumber) { throw null; }
public static Azure.AI.FormRecognizer.Models.FormRecognizerError FormRecognizerError(string errorCode, string message) { throw null; }
public static Azure.AI.FormRecognizer.Models.FormSelectionMark FormSelectionMark(Azure.AI.FormRecognizer.Models.FieldBoundingBox boundingBox, int pageNumber, string text, float confidence, Azure.AI.FormRecognizer.Models.FormSelectionMarkState state) { throw null; }
public static Azure.AI.FormRecognizer.Models.FormSelectionMark FormSelectionMark(Azure.AI.FormRecognizer.Models.FieldBoundingBox boundingBox, int pageNumber, string text, float confidence, Azure.AI.FormRecognizer.Models.SelectionMarkState state) { throw null; }
public static Azure.AI.FormRecognizer.Models.FormTable FormTable(int pageNumber, int columnCount, int rowCount, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Models.FormTableCell> cells) { throw null; }
public static Azure.AI.FormRecognizer.Models.FormTableCell FormTableCell(Azure.AI.FormRecognizer.Models.FieldBoundingBox boundingBox, int pageNumber, string text, int columnIndex, int rowIndex, int columnSpan, int rowSpan, bool isHeader, bool isFooter, float confidence, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Models.FormElement> fieldElements) { throw null; }
public static Azure.AI.FormRecognizer.Models.FormWord FormWord(Azure.AI.FormRecognizer.Models.FieldBoundingBox boundingBox, int pageNumber, string text, float confidence) { throw null; }
Expand All @@ -230,12 +230,7 @@ public partial class FormSelectionMark : Azure.AI.FormRecognizer.Models.FormElem
{
internal FormSelectionMark() { }
public float Confidence { get { throw null; } }
public Azure.AI.FormRecognizer.Models.FormSelectionMarkState State { get { throw null; } }
}
public enum FormSelectionMarkState
{
Selected = 0,
Unselected = 1,
public Azure.AI.FormRecognizer.Models.SelectionMarkState State { get { throw null; } }
}
public partial class FormTable
{
Expand Down Expand Up @@ -333,6 +328,11 @@ public RecognizeReceiptsOperation(string operationId, Azure.AI.FormRecognizer.Fo
public override System.Threading.Tasks.ValueTask<Azure.Response<Azure.AI.FormRecognizer.Models.RecognizedFormCollection>> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public override System.Threading.Tasks.ValueTask<Azure.Response<Azure.AI.FormRecognizer.Models.RecognizedFormCollection>> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public enum SelectionMarkState
{
Selected = 0,
Unselected = 1,
}
}
namespace Azure.AI.FormRecognizer.Training
{
Expand Down
10 changes: 5 additions & 5 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/src/FieldValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ internal FieldValue(IReadOnlyDictionary<string, FormField> value)
/// Initializes a new instance of the <see cref="FieldValue"/> structure.
/// </summary>
/// <param name="value">The actual field value.</param>
internal FieldValue(FormSelectionMarkState value)
internal FieldValue(SelectionMarkState value)
: this()
{
ValueType = FieldValueType.SelectionMark;
Expand Down Expand Up @@ -170,7 +170,7 @@ internal FieldValue(FormSelectionMarkState value)
/// The <see cref="FieldValueSelectionMark"/> value of this instance. Values are usually extracted from
/// <see cref="_fieldValue"/>, so this property is exclusively used for mocking.
/// </summary>
private FormSelectionMarkState ValueSelectionMark { get; }
private SelectionMarkState ValueSelectionMark { get; }

/// <summary>
/// Gets the value of the field as a <see cref="string"/>.
Expand Down Expand Up @@ -375,11 +375,11 @@ public IReadOnlyDictionary<string, FormField> AsDictionary()
}

/// <summary>
/// Gets the value of the field as a <see cref="FormSelectionMarkState"/>.
/// Gets the value of the field as a <see cref="SelectionMarkState"/>.
/// </summary>
/// <returns>The value of the field converted to <see cref="FormSelectionMarkState"/>.</returns>
/// <returns>The value of the field converted to <see cref="SelectionMarkState"/>.</returns>
/// <exception cref="InvalidOperationException">Thrown when <see cref="ValueType"/> is not <see cref="FieldValueType.SelectionMark"/>.</exception>
public FormSelectionMarkState AsFormSelectionMarkState()
public SelectionMarkState AsSelectionMarkState()
{
if (ValueType != FieldValueType.SelectionMark)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal partial class FieldValue_internal
public long? ValueInteger { get; }

/// <summary> Selection mark value. </summary>
public FormSelectionMarkState? ValueSelectionMark { get; }
public SelectionMarkState? ValueSelectionMark { get; }

internal FieldValue_internal(string value)
{
Expand All @@ -39,7 +39,7 @@ internal FieldValue_internal(string value)
/// <param name="confidence"> Confidence score. </param>
/// <param name="elements"> When includeTextDetails is set to true, a list of references to the text elements constituting this field. </param>
/// <param name="page"> The 1-based page number in the input document. </param>
internal FieldValue_internal(FieldValueType type, string valueString, DateTimeOffset? valueDate, TimeSpan? valueTime, string valuePhoneNumber, float? valueNumber, long? valueInteger, IReadOnlyList<FieldValue_internal> valueArray, IReadOnlyDictionary<string, FieldValue_internal> valueObject, FormSelectionMarkState? valueSelectionMark, string text, IReadOnlyList<float> boundingBox, float? confidence, IReadOnlyList<string> elements, int? page)
internal FieldValue_internal(FieldValueType type, string valueString, DateTimeOffset? valueDate, TimeSpan? valueTime, string valuePhoneNumber, float? valueNumber, long? valueInteger, IReadOnlyList<FieldValue_internal> valueArray, IReadOnlyDictionary<string, FieldValue_internal> valueObject, SelectionMarkState? valueSelectionMark, string text, IReadOnlyList<float> boundingBox, float? confidence, IReadOnlyList<string> elements, int? page)
{
Type = type;
ValueString = valueString;
Expand All @@ -59,7 +59,7 @@ internal FieldValue_internal(FieldValueType type, string valueString, DateTimeOf

if (Type == FieldValueType.SelectionMark)
{
ValueSelectionMark = FormSelectionMarkStateExtensions.ToFormSelectionMarkState(text);
ValueSelectionMark = SelectionMarkStateExtensions.ToSelectionMarkState(text);
Text = ValueSelectionMark.ToString();
}
else
Expand Down
3 changes: 3 additions & 0 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace Azure.AI.FormRecognizer.Models
/// </summary>
public abstract class FormElement
{
internal FormElement(FieldBoundingBox boundingBox, int pageNumber)
: this(boundingBox, pageNumber, default) { }

internal FormElement(FieldBoundingBox boundingBox, int pageNumber, string text)
{
BoundingBox = boundingBox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public static FieldValue FieldValueWithDictionaryValueType(IReadOnlyDictionary<s
/// </summary>
/// <param name="value">The actual field value.</param>
/// <returns>A new <see cref="FieldValue"/> instance for mocking.</returns>
public static FieldValue FieldValueWithSelectionMarkValueType(FormSelectionMarkState value) =>
public static FieldValue FieldValueWithSelectionMarkValueType(SelectionMarkState value) =>
new FieldValue(value);

/// <summary>
Expand Down Expand Up @@ -451,7 +451,7 @@ public static RecognizedFormCollection RecognizedFormCollection(IList<Recognized
/// <param name="confidence">Measures the degree of certainty of the recognition result.</param>
/// <param name="state">Selection mark state value.</param>
/// <returns>A new <see cref="FormRecognizer.Models.FormSelectionMark"/> instance for mocking.</returns>
public static FormSelectionMark FormSelectionMark(FieldBoundingBox boundingBox, int pageNumber, string text, float confidence, FormSelectionMarkState state) =>
public static FormSelectionMark FormSelectionMark(FieldBoundingBox boundingBox, int pageNumber, string text, float confidence, SelectionMarkState state) =>
new FormSelectionMark(boundingBox, pageNumber, text, confidence, state);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ namespace Azure.AI.FormRecognizer.Models
public class FormSelectionMark : FormElement
{
internal FormSelectionMark(SelectionMark selectionMark, int pageNumber)
: base(new FieldBoundingBox(selectionMark.BoundingBox), pageNumber, selectionMark.State.ToString())
: base(new FieldBoundingBox(selectionMark.BoundingBox), pageNumber)
{
Confidence = selectionMark.Confidence;
State = selectionMark.State;
}

internal FormSelectionMark(FieldBoundingBox boundingBox, int pageNumber, string text, float confidence, FormSelectionMarkState state)
internal FormSelectionMark(FieldBoundingBox boundingBox, int pageNumber, string text, float confidence, SelectionMarkState state)
: base(boundingBox, pageNumber, text)
{
Confidence = confidence;
Expand All @@ -30,6 +30,6 @@ internal FormSelectionMark(FieldBoundingBox boundingBox, int pageNumber, string
/// <summary>
/// Selection mark state value.
/// </summary>
public FormSelectionMarkState State { get; }
public SelectionMarkState State { get; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
namespace Azure.AI.FormRecognizer.Models
{
/// <summary>
/// State of a selection mark.
/// State of a selection mark. i.e. Selected or Unselected.
/// </summary>
[CodeGenModel("SelectionMarkState")]
public enum FormSelectionMarkState
public enum SelectionMarkState
{
/// <summary>
/// Value is selected.
Expand Down
Binary file not shown.
Loading

0 comments on commit 9876881

Please sign in to comment.