Skip to content

Commit

Permalink
Rename bounding box model to FieldBoundingBox (Azure#14241)
Browse files Browse the repository at this point in the history
  • Loading branch information
samvaity authored Aug 20, 2020
1 parent 76fc7e8 commit a7c3acb
Show file tree
Hide file tree
Showing 22 changed files with 307 additions and 451 deletions.
2 changes: 1 addition & 1 deletion eng/jacoco-test-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-formrecognizer</artifactId>
<version>3.0.0-beta.2</version> <!-- {x-version-update;com.azure:azure-ai-formrecognizer;current} -->
<version>3.0.0</version> <!-- {x-version-update;com.azure:azure-ai-formrecognizer;current} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
Expand Down
2 changes: 1 addition & 1 deletion eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
com.azure:azure-sdk-all;1.0.0;1.0.0
com.azure:azure-sdk-parent;1.6.0;1.6.0
com.azure:azure-client-sdk-parent;1.7.0;1.7.0
com.azure:azure-ai-formrecognizer;3.0.0-beta.1;3.0.0-beta.2
com.azure:azure-ai-formrecognizer;3.0.0-beta.1;3.0.0
com.azure:azure-ai-textanalytics;5.0.0;5.1.0-beta.1
com.azure:azure-core;1.7.0;1.8.0-beta.1
com.azure:azure-core-amqp;1.4.0;1.5.0-beta.1
Expand Down
5 changes: 4 additions & 1 deletion sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Release History

## 3.0.0-beta.2 (Unreleased)
## 3.0.0 (2020-08-20)
First stable release of the azure-ai-formrecognizer client library supporting Azure Form Recognizer service API version v2.0.

### Breaking Changes
- Renamed `BoundingBox` model to `FieldBoundingBox`

## 3.0.0-beta.1 (2020-08-11)
This beta version targets Azure Form Recognizer service API version v2.0.
Expand Down
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 @@ -23,7 +23,7 @@ from form documents. It includes the following main functionalities:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-formrecognizer</artifactId>
<version>3.0.0-beta.1</version>
<version>3.0.0</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand Down
2 changes: 1 addition & 1 deletion sdk/formrecognizer/azure-ai-formrecognizer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>com.azure</groupId>
<artifactId>azure-ai-formrecognizer</artifactId>
<version>3.0.0-beta.2</version> <!-- {x-version-update;com.azure:azure-ai-formrecognizer;current} -->
<version>3.0.0</version> <!-- {x-version-update;com.azure:azure-ai-formrecognizer;current} -->

<name>Microsoft Azure client library for Form Recognizer</name>
<description>This package contains the Microsoft Azure Cognitive Services Form Recognizer SDK.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.azure.ai.formrecognizer.implementation.models.ReadResult;
import com.azure.ai.formrecognizer.implementation.models.TextLine;
import com.azure.ai.formrecognizer.implementation.models.TextWord;
import com.azure.ai.formrecognizer.models.BoundingBox;
import com.azure.ai.formrecognizer.models.FieldBoundingBox;
import com.azure.ai.formrecognizer.models.FieldData;
import com.azure.ai.formrecognizer.models.FieldValueType;
import com.azure.ai.formrecognizer.models.FormElement;
Expand Down Expand Up @@ -456,20 +456,20 @@ private static List<FormWord> toWords(List<TextWord> words, int pageNumber) {

/**
* Helper method to convert the service level modeled eight numbers representing the four points to SDK level
* {@link BoundingBox}.
* {@link FieldBoundingBox}.
*
* @param serviceBoundingBox A list of eight numbers representing the four points of a box.
*
* @return A {@link BoundingBox}.
* @return A {@link FieldBoundingBox}.
*/
private static BoundingBox toBoundingBox(List<Float> serviceBoundingBox) {
private static FieldBoundingBox toBoundingBox(List<Float> serviceBoundingBox) {
if (CoreUtils.isNullOrEmpty(serviceBoundingBox) || (serviceBoundingBox.size() % 2) != 0) {
return null;
}
List<Point> pointList = new ArrayList<>();
for (int i = 0; i < serviceBoundingBox.size(); i++) {
pointList.add(new Point(serviceBoundingBox.get(i), serviceBoundingBox.get(++i)));
}
return new BoundingBox(pointList);
return new FieldBoundingBox(pointList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
* Quadrangle bounding box, with coordinates specified relative to the top-left of the original image
*/
@Immutable
public final class BoundingBox {
public final class FieldBoundingBox {

/**
* The list of coordinates of the Bounding box.
* The list of coordinates of the field's bounding box.
*/
private final List<Point> points;

/**
* Constructs a Bounding box object.
* Constructs a Field Bounding box object.
*
* @param points The list of coordinates of the Bounding box.
* @param points The list of coordinates of the field's bounding box.
*/
public BoundingBox(final List<Point> points) {
public FieldBoundingBox(final List<Point> points) {
if (points == null) {
this.points = null;
} else {
Expand All @@ -36,16 +36,16 @@ public BoundingBox(final List<Point> points) {
/**
* Gets the list of all point coordinates of the bounding box.
*
* @return The unmodifiable list of all point coordinates of the Bounding box.
* @return The unmodifiable list of all point coordinates of the field's bounding box.
*/
public List<Point> getPoints() {
return this.points;
}

/**
* Returns a string representation of the {@link BoundingBox}.
* Returns a string representation of the {@link FieldBoundingBox}.
*
* @return the string representation of the {@link BoundingBox}.
* @return the string representation of the {@link FieldBoundingBox}.
*/
@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public final class FieldData extends FormElement {
* Creates raw OCR FieldData item.
*
* @param text The text content of ExtractedField.
* @param boundingBox The BoundingBox of ExtractedField.
* @param boundingBox The Bounding Box of the recognized field.
* @param pageNumber the 1 based page number.
* @param fieldElements The list of element references when includeFieldElements is set to true.
*/
public FieldData(String text, BoundingBox boundingBox, int pageNumber,
public FieldData(String text, FieldBoundingBox boundingBox, int pageNumber,
final List<FormElement> fieldElements) {
super(text, boundingBox, pageNumber);
this.fieldElements = fieldElements == null ? null : Collections.unmodifiableList(fieldElements);
Expand All @@ -37,7 +37,7 @@ public FieldData(String text, BoundingBox boundingBox, int pageNumber,
* {@inheritDoc}
*/
@Override
public BoundingBox getBoundingBox() {
public FieldBoundingBox getBoundingBox() {
return super.getBoundingBox();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public abstract class FormElement {
/*
* BoundingBox specifying relative coordinates of the element.
*/
private final BoundingBox boundingBox;
private final FieldBoundingBox boundingBox;

/**
* Creates raw OCR item.
* @param text The text content of the extracted element.
* @param boundingBox The BoundingBox specifying relative coordinates of the element.
* @param pageNumber the 1 based page number.
*/
FormElement(final String text, final BoundingBox boundingBox, final int pageNumber) {
FormElement(final String text, final FieldBoundingBox boundingBox, final int pageNumber) {
this.text = text;
this.boundingBox = boundingBox;
this.pageNumber = pageNumber;
Expand All @@ -43,7 +43,7 @@ public abstract class FormElement {
*
* @return the bounding box of the element.
*/
public BoundingBox getBoundingBox() {
public FieldBoundingBox getBoundingBox() {
return boundingBox;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class FormLine extends FormElement {
* @param pageNumber the page number.
* @param words The list of word element references.
*/
public FormLine(String text, BoundingBox boundingBox, Integer pageNumber,
public FormLine(String text, FieldBoundingBox boundingBox, Integer pageNumber,
final List<FormWord> words) {
super(text, boundingBox, pageNumber);
this.words = words == null ? null : Collections.unmodifiableList(words);
Expand All @@ -47,7 +47,7 @@ public List<FormWord> getWords() {
* {@inheritDoc}
*/
@Override
public BoundingBox getBoundingBox() {
public FieldBoundingBox getBoundingBox() {
return super.getBoundingBox();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class FormTableCell extends FormElement {
* @param fieldElements a list of references to the elements constituting this table cell.
*/
public FormTableCell(final int rowIndex, final int columnIndex, final int rowSpan,
final int columnSpan, final String text, final BoundingBox boundingBox,
final int columnSpan, final String text, final FieldBoundingBox boundingBox,
final float confidence, final boolean isHeader, final boolean isFooter, final int pageNumber,
final List<FormElement> fieldElements) {
super(text, boundingBox, pageNumber);
Expand Down Expand Up @@ -106,7 +106,7 @@ public int getPageNumber() {
* {@inheritDoc}
*/
@Override
public BoundingBox getBoundingBox() {
public FieldBoundingBox getBoundingBox() {
return super.getBoundingBox();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class FormWord extends FormElement {
* @param pageNumber the 1 based page number.
* @param confidence the confidence property of the Form Word.
*/
public FormWord(String text, BoundingBox boundingBox, int pageNumber, final float confidence) {
public FormWord(String text, FieldBoundingBox boundingBox, int pageNumber, final float confidence) {
super(text, boundingBox, pageNumber);
this.confidence = confidence;
}
Expand All @@ -42,7 +42,7 @@ public float getConfidence() {
* {@inheritDoc}
*/
@Override
public BoundingBox getBoundingBox() {
public FieldBoundingBox getBoundingBox() {
return super.getBoundingBox();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void main(String[] args) {
final List<FormPage> pages = recognizedForm.getPages();
for (int i1 = 0; i1 < pages.size(); i1++) {
final FormPage formPage = pages.get(i1);
System.out.printf("------- Recognizing info on page %s of Form -------%n", i1);
System.out.printf("------- Recognizing info on page %s of Form ------- %n", i1);
System.out.printf("Has width: %f, angle: %.2f, height: %f %n", formPage.getWidth(),
formPage.getTextAngle(), formPage.getHeight());
// Table information
Expand Down
Loading

0 comments on commit a7c3acb

Please sign in to comment.