Skip to content

Commit

Permalink
PR feedback and disable test
Browse files Browse the repository at this point in the history
  • Loading branch information
maririos committed Sep 28, 2020
1 parent e4d3fa7 commit 57e3d79
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 30,796 deletions.
2 changes: 1 addition & 1 deletion sdk/formrecognizer/Azure.AI.FormRecognizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The following section provides several code snippets illustrating common pattern
* [Manage Custom Models Synchronously](#manage-custom-models-synchronously)

### Recognize Content
Recognize text, table, and and selection marks like radio buttons and check boxes data, along with their bounding box coordinates, from documents.
Recognize text, tables, and selection marks like radio buttons and check boxes data, along with their bounding box coordinates, from documents.

```C# Snippet:FormRecognizerSampleRecognizeContentFromUri
FormPageCollection formPages = await client.StartRecognizeContentFromUriAsync(invoiceUri).WaitForCompletionAsync();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Recognize form content

This sample demonstrates how to recognize tables, lines, words, and selection marks like radio buttons and check boxes in forms documents in documents, without the need to train a model.
This sample demonstrates how to recognize tables, lines, words, and selection marks like radio buttons and check boxes in forms documents, without the need to train a model.

To get started you'll need a Cognitive Services resource or a Form Recognizer resource. See [README][README] for prerequisites and instructions.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using Azure.Core;

namespace Azure.AI.FormRecognizer.Models
Expand All @@ -20,5 +22,45 @@ internal FieldValue_internal(string value)
ValueString = value;
Text = value;
}

/// <summary> Initializes a new instance of FieldValue_internal. </summary>
/// <param name="type"> Type of field value. </param>
/// <param name="valueString"> String value. </param>
/// <param name="valueDate"> Date value. </param>
/// <param name="valueTime"> Time value. </param>
/// <param name="valuePhoneNumber"> Phone number value. </param>
/// <param name="valueNumber"> Floating point value. </param>
/// <param name="valueInteger"> Integer value. </param>
/// <param name="valueArray"> Array of field values. </param>
/// <param name="valueObject"> Dictionary of named field values. </param>
/// <param name="valueSelectionMark"> Selection mark value. </param>
/// <param name="text"> Text content of the extracted field. </param>
/// <param name="boundingBox"> Bounding box of the field value, if appropriate. </param>
/// <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)
{
Type = type;
ValueString = valueString;
ValueDate = valueDate;
ValueTime = valueTime;
ValuePhoneNumber = valuePhoneNumber;
ValueNumber = valueNumber;
ValueInteger = valueInteger;
ValueArray = valueArray;
ValueObject = valueObject;
ValueSelectionMark = valueSelectionMark;

BoundingBox = boundingBox;
Confidence = confidence;
Elements = elements;
Page = page;

if (Type == FieldValueType.SelectionMark)
Text = FormSelectionMarkStateExtensions.ToFormSelectionMarkState(text).ToString();
else
Text = text;
}
}
}

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 @@ -383,6 +383,7 @@ public void StartRecognizeContentFromUriThrowsForNonExistingContent()
}

[Test]
[Ignore("Need to get an approved file to test")]
public async Task StartRecognizeContentWithSelectionMarks()
{
var client = CreateFormRecognizerClient();
Expand Down Expand Up @@ -865,6 +866,7 @@ public async Task StartRecognizeCustomFormsWithLabels(bool useStream, bool inclu
[Test]
[TestCase(true)]
[TestCase(false)]
[Ignore("Need to get an approved file to test")]
public async Task StartRecognizeCustomFormsWithLabelsAndSelectionMarks(bool includeFieldElements)
{
var client = CreateFormRecognizerClient();
Expand All @@ -891,12 +893,11 @@ public async Task StartRecognizeCustomFormsWithLabelsAndSelectionMarks(bool incl

// Testing that we shuffle things around correctly so checking only once per property.
Assert.IsNotEmpty(form.FormType);
Assert.AreEqual(1, form.Pages.Count);
Assert.IsNotNull(form.Fields);
var name = "Checkbox_Paramedic Subscription_Amount Enclosed";
Assert.IsNotNull(form.Fields[name]);
Assert.AreEqual(FieldValueType.SelectionMark, form.Fields[name].Value.ValueType);
Assert.AreEqual("selected", form.Fields[name].ValueData.Text);
Assert.AreEqual("Selected", form.Fields[name].ValueData.Text);
}

[Test]
Expand Down Expand Up @@ -1399,6 +1400,7 @@ private void ValidateFormPage(FormPage formPage, bool includeFieldElements, int
Assert.NotNull(selectionMark.BoundingBox.Points);
Assert.AreEqual(4, selectionMark.BoundingBox.Points.Length);
Assert.NotNull(selectionMark.Text);
Assert.That(selectionMark.Text, Is.EqualTo("Selected").Or.EqualTo("Unselected"));
Assert.NotNull(selectionMark.State);
Assert.That(selectionMark.Confidence, Is.GreaterThanOrEqualTo(0.0).Within(0.01));
Assert.That(selectionMark.Confidence, Is.LessThanOrEqualTo(1.0).Within(0.01));
Expand Down
Loading

0 comments on commit 57e3d79

Please sign in to comment.