Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Flatten TextSyle in TextAppearance #20857

Merged
merged 2 commits into from
May 5, 2021
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
2 changes: 2 additions & 0 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ By default the SDK targets latest supported service version.
### Breaking changes
- Renamed `Id` for `Identity` in all the `StartRecognizeIdDocuments` functionalities. For example, the name of the method is now `StartRecognizeIdentityDocuments`.
- Renamed the model `ReadingOrder` to `FormReadingOrder`.
- The model `TextAppearance` now includes the properties `StyleName` and `StyleConfidence` that were part of the `TextStyle` object.
- Removed the model `TextStyle`.

## 3.0.1 (2021-04-09)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ public static partial class FormRecognizerModelFactory
public static Azure.AI.FormRecognizer.Models.RecognizedForm RecognizedForm(string formType, Azure.AI.FormRecognizer.Models.FormPageRange pageRange, System.Collections.Generic.IReadOnlyDictionary<string, Azure.AI.FormRecognizer.Models.FormField> fields, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Models.FormPage> pages) { throw null; }
public static Azure.AI.FormRecognizer.Models.RecognizedForm RecognizedForm(string formType, Azure.AI.FormRecognizer.Models.FormPageRange pageRange, System.Collections.Generic.IReadOnlyDictionary<string, Azure.AI.FormRecognizer.Models.FormField> fields, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Models.FormPage> pages, string modelId, float? formTypeConfidence) { throw null; }
public static Azure.AI.FormRecognizer.Models.RecognizedFormCollection RecognizedFormCollection(System.Collections.Generic.IList<Azure.AI.FormRecognizer.Models.RecognizedForm> list) { throw null; }
public static Azure.AI.FormRecognizer.Models.TextAppearance TextAppearance(Azure.AI.FormRecognizer.Models.TextStyle style) { throw null; }
public static Azure.AI.FormRecognizer.Models.TextStyle TextStyle(Azure.AI.FormRecognizer.Models.TextStyleName name, float confidence) { throw null; }
public static Azure.AI.FormRecognizer.Models.TextAppearance TextAppearance(Azure.AI.FormRecognizer.Models.TextStyleName styleName, float styleConfidence) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.AI.FormRecognizer.Training.TrainingDocumentInfo TrainingDocumentInfo(string name, int pageCount, System.Collections.Generic.IEnumerable<Azure.AI.FormRecognizer.Models.FormRecognizerError> errors, Azure.AI.FormRecognizer.Training.TrainingStatus status) { throw null; }
public static Azure.AI.FormRecognizer.Training.TrainingDocumentInfo TrainingDocumentInfo(string name, int pageCount, System.Collections.Generic.IEnumerable<Azure.AI.FormRecognizer.Models.FormRecognizerError> errors, Azure.AI.FormRecognizer.Training.TrainingStatus status, string modelId) { throw null; }
Expand Down Expand Up @@ -548,13 +547,8 @@ public enum SelectionMarkState
public partial class TextAppearance
{
internal TextAppearance() { }
public Azure.AI.FormRecognizer.Models.TextStyle Style { get { throw null; } }
}
public partial class TextStyle
{
internal TextStyle() { }
public float Confidence { get { throw null; } }
public Azure.AI.FormRecognizer.Models.TextStyleName Name { get { throw null; } }
public float StyleConfidence { get { throw null; } }
public Azure.AI.FormRecognizer.Models.TextStyleName StyleName { get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct TextStyleName : System.IEquatable<Azure.AI.FormRecognizer.Models.TextStyleName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,19 +478,11 @@ public static RecognizedFormCollection RecognizedFormCollection(IList<Recognized
/// <summary>
/// Initializes a new instance of the <see cref="FormRecognizer.Models.TextAppearance"/> class.
/// </summary>
/// <param name="style">An object representing the style of the text line.</param>
/// <param name="styleName">The text line style name.</param>
/// <param name="styleConfidence">Measures the degree of certainty of the recognition result.</param>
/// <returns>A new <see cref="FormRecognizer.Models.TextAppearance"/> instance for mocking.</returns>
public static TextAppearance TextAppearance(TextStyle style) =>
style == null ? new TextAppearance() : new TextAppearance(style);

/// <summary>
/// Initializes a new instance of the <see cref="FormRecognizer.Models.TextStyle"/> class.
/// </summary>
/// <param name="name">The text line style name.</param>
/// <param name="confidence">Measures the degree of certainty of the recognition result.</param>
/// <returns>A new <see cref="FormRecognizer.Models.TextStyle"/> instance for mocking.</returns>
public static TextStyle TextStyle(TextStyleName name, float confidence) =>
new TextStyle(name, confidence);
public static TextAppearance TextAppearance(TextStyleName styleName, float styleConfidence) =>
new TextAppearance(styleName, styleConfidence);

/// <summary>
/// Initializes a new instance of the <see cref="Training.TrainingDocumentInfo"/> class.
Expand Down

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.

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

18 changes: 17 additions & 1 deletion sdk/formrecognizer/Azure.AI.FormRecognizer/src/TextAppearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,24 @@ public partial class TextAppearance
/// Initializes a new instance of <see cref="TextAppearance"/>. This constructor
/// is intended to be used for mocking only.
/// </summary>
internal TextAppearance()
internal TextAppearance(TextStyleName styleName, float styleConfidence)
{
Style = new Style(styleName, styleConfidence);
}

/// <summary>
/// An object representing the style of the text line.
/// </summary>
internal Style Style { get; }

/// <summary>
/// The text line style name, including handwriting and other.
/// </summary>
public TextStyleName StyleName => Style.Name;

/// <summary>
/// The confidence of text line style.
/// </summary>
public float StyleConfidence => Style.Confidence;
}
}
12 changes: 0 additions & 12 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/src/TextStyle.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public void FormRecognizerModelFactoryCanInstantiateFormLine()
var pageNumber = 389;
var text = "Bhaskara";
var words = new List<FormWord>() { formWord };
var appearance = new TextAppearance();
var appearance = new TextAppearance(default, default);

var formLine = FormRecognizerModelFactory.FormLine(boundingBox, pageNumber, text, words, appearance);

Expand Down Expand Up @@ -644,24 +644,14 @@ public void FormRecognizerModelFactoryCanInstantiateRecognizedFormCollection()

[Test]
public void FormRecognizerModelFactoryCanInstantiateTextAppearance()
{
var style = new TextStyle(default, default);

var textAppearance = FormRecognizerModelFactory.TextAppearance(style);

Assert.AreEqual(style, textAppearance.Style);
}

[Test]
public void FormRecognizerModelFactoryCanInstantiateTextStyle()
{
var name = TextStyleName.Handwriting;
var confidence = 0.299792f;

var textStyle = FormRecognizerModelFactory.TextStyle(name, confidence);
var textAppearance = FormRecognizerModelFactory.TextAppearance(name, confidence);

Assert.AreEqual(name, textStyle.Name);
Assert.AreEqual(confidence, textStyle.Confidence);
Assert.AreEqual(name, textAppearance.StyleName);
Assert.AreEqual(confidence, textAppearance.StyleConfidence);
}

[Test]
Expand Down