Skip to content
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
3 changes: 3 additions & 0 deletions sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Change Log azure-ai-formrecognizer

## 1.0.0b4 (Unreleased)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good, you just forgot to remove mention of RecognizedReceipt from the readme: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer#formrecognizerclient

**Breaking Changes**

- Remove `RecognizedReceipts` Class.
- `begin_recognize_receipts` and `begin_recognize_receipts_from_url` now return `RecognizedForm`.

## 1.0.0b3 (2020-06-10)

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 @@ -122,8 +122,8 @@ See the full details regarding [authentication][cognitive_authentication] of cog
`FormRecognizerClient` provides operations for:

- Recognizing form fields and content using custom models trained to recognize your custom forms. These values are returned in a collection of `RecognizedForm` objects.
- Recognizing common fields from US receipts, using a pre-trained receipt model on the Form Recognizer service. These fields and meta-data are returned in a collection of `RecognizedForm` objects.
- Recognizing form content, including tables, lines and words, without the need to train a model. Form content is returned in a collection of `FormPage` objects.
- Recognizing common fields from US receipts, using a pre-trained receipt model on the Form Recognizer service. These fields and meta-data are returned in a collection of `RecognizedReceipt` objects.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still include this sentence, just say that it returns a collection of RecognizedForm


### FormTrainingClient
`FormTrainingClient` provides operations for:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
CustomFormModel,
CustomFormSubmodel,
CustomFormModelField,
RecognizedReceipt
)


Expand Down Expand Up @@ -60,7 +59,6 @@
'CustomFormModel',
'CustomFormSubmodel',
'CustomFormModelField',
'RecognizedReceipt'
]

__VERSION__ = VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ._polling import AnalyzePolling
if TYPE_CHECKING:
from azure.core.credentials import AzureKeyCredential, TokenCredential
from ._models import RecognizedReceipt, FormPage, RecognizedForm
from ._models import FormPage, RecognizedForm


class FormRecognizerClient(object):
Expand Down Expand Up @@ -80,7 +80,7 @@ def _receipt_callback(self, raw_response, _, headers): # pylint: disable=unused

@distributed_trace
def begin_recognize_receipts(self, receipt, **kwargs):
# type: (Union[bytes, IO[bytes]], Any) -> LROPoller[List[RecognizedReceipt]]
# type: (Union[bytes, IO[bytes]], Any) -> LROPoller[List[RecognizedForm]]
"""Extract field text and semantic values from a given US sales receipt.
The input document must be of one of the supported content types - 'application/pdf',
'image/jpeg', 'image/png' or 'image/tiff'.
Expand All @@ -97,8 +97,8 @@ def begin_recognize_receipts(self, receipt, **kwargs):
if no Retry-After header is present. Defaults to 5 seconds.
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:return: An instance of an LROPoller. Call `result()` on the poller
object to return a list[:class:`~azure.ai.formrecognizer.RecognizedReceipt`].
:rtype: ~azure.core.polling.LROPoller[list[~azure.ai.formrecognizer.RecognizedReceipt]]
object to return a list[:class:`~azure.ai.formrecognizer.RecognizedForm`].
:rtype: ~azure.core.polling.LROPoller[list[~azure.ai.formrecognizer.RecognizedForm]]
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down Expand Up @@ -135,7 +135,7 @@ def begin_recognize_receipts(self, receipt, **kwargs):

@distributed_trace
def begin_recognize_receipts_from_url(self, receipt_url, **kwargs):
# type: (str, Any) -> LROPoller[List[RecognizedReceipt]]
# type: (str, Any) -> LROPoller[List[RecognizedForm]]
"""Extract field text and semantic values from a given US sales receipt.
The input document must be the location (Url) of the receipt to be analyzed.

Expand All @@ -148,8 +148,8 @@ def begin_recognize_receipts_from_url(self, receipt_url, **kwargs):
if no Retry-After header is present. Defaults to 5 seconds.
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:return: An instance of an LROPoller. Call `result()` on the poller
object to return a list[:class:`~azure.ai.formrecognizer.RecognizedReceipt`].
:rtype: ~azure.core.polling.LROPoller[list[~azure.ai.formrecognizer.RecognizedReceipt]]
object to return a list[:class:`~azure.ai.formrecognizer.RecognizedForm`].
:rtype: ~azure.core.polling.LROPoller[list[~azure.ai.formrecognizer.RecognizedForm]]
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,29 +176,6 @@ def __repr__(self):
self.form_type, repr(self.fields), repr(self.page_range), repr(self.pages)
)[:1024]

class RecognizedReceipt(RecognizedForm):
"""Represents a receipt that has been recognized by a trained model.

:ivar str form_type:
The type of form the model identified the submitted form to be.
:ivar fields:
A dictionary of the fields found on the form. The fields dictionary
keys are the `name` of the field. For models trained with labels,
this is the training-time label of the field. For models trained
without labels, a unique name is generated for each field.
:vartype fields: dict[str, ~azure.ai.formrecognizer.FormField]
:ivar ~azure.ai.formrecognizer.FormPageRange page_range:
The first and last page number of the input form.
:ivar list[~azure.ai.formrecognizer.FormPage] pages:
A list of pages recognized from the input document. Contains lines,
words, tables and page metadata.
"""

def __repr__(self):
return "RecognizedReceipt(form_type={}, fields={}, page_range={}, pages={})".format(
self.form_type, repr(self.fields), repr(self.page_range), repr(self.pages)
)[:1024]


class FormField(object):
"""Represents a field recognized in an input form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
FormTable,
FormTableCell,
FormPageRange,
RecognizedForm,
RecognizedReceipt
RecognizedForm
)


Expand All @@ -26,14 +25,14 @@ def prepare_receipt(response):

for page in document_result:
if page.fields is None:
receipt = RecognizedReceipt(
receipt = RecognizedForm(
page_range=FormPageRange(first_page_number=page.page_range[0], last_page_number=page.page_range[1]),
pages=form_page[page.page_range[0]-1:page.page_range[1]],
form_type=page.doc_type,
)
receipts.append(receipt)
continue
receipt = RecognizedReceipt(
receipt = RecognizedForm(
page_range=FormPageRange(
first_page_number=page.page_range[0], last_page_number=page.page_range[1]
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from .._helpers import get_content_type, get_authentication_policy, error_map, POLLING_INTERVAL
from .._user_agent import USER_AGENT
from .._polling import AnalyzePolling
from .._models import RecognizedReceipt, FormPage, RecognizedForm
from .._models import FormPage, RecognizedForm
if TYPE_CHECKING:
from azure.core.credentials import AzureKeyCredential
from azure.core.credentials_async import AsyncTokenCredential
Expand Down Expand Up @@ -88,7 +88,7 @@ async def begin_recognize_receipts(
self,
receipt: Union[bytes, IO[bytes]],
**kwargs: Any
) -> AsyncLROPoller[List[RecognizedReceipt]]:
) -> AsyncLROPoller[List[RecognizedForm]]:
"""Extract field text and semantic values from a given US sales receipt.
The input document must be of one of the supported content types - 'application/pdf',
'image/jpeg', 'image/png' or 'image/tiff'.
Expand All @@ -105,8 +105,8 @@ async def begin_recognize_receipts(
if no Retry-After header is present. Defaults to 5 seconds.
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:return: An instance of an AsyncLROPoller. Call `result()` on the poller
object to return a list[:class:`~azure.ai.formrecognizer.RecognizedReceipt`].
:rtype: ~azure.core.polling.AsyncLROPoller[list[~azure.ai.formrecognizer.RecognizedReceipt]]
object to return a list[:class:`~azure.ai.formrecognizer.RecognizedForm`].
:rtype: ~azure.core.polling.AsyncLROPoller[list[~azure.ai.formrecognizer.RecognizedForm]]
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down Expand Up @@ -149,7 +149,7 @@ async def begin_recognize_receipts_from_url(
self,
receipt_url: str,
**kwargs: Any
) -> AsyncLROPoller[List[RecognizedReceipt]]:
) -> AsyncLROPoller[List[RecognizedForm]]:
"""Extract field text and semantic values from a given US sales receipt.
The input document must be the location (Url) of the receipt to be analyzed.

Expand All @@ -162,8 +162,8 @@ async def begin_recognize_receipts_from_url(
if no Retry-After header is present. Defaults to 5 seconds.
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:return: An instance of an AsyncLROPoller. Call `result()` on the poller
object to return a list[:class:`~azure.ai.formrecognizer.RecognizedReceipt`].
:rtype: ~azure.core.polling.AsyncLROPoller[list[~azure.ai.formrecognizer.RecognizedReceipt]]
object to return a list[:class:`~azure.ai.formrecognizer.RecognizedForm`].
:rtype: ~azure.core.polling.AsyncLROPoller[list[~azure.ai.formrecognizer.RecognizedForm]]
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:
Expand Down
9 changes: 0 additions & 9 deletions sdk/formrecognizer/azure-ai-formrecognizer/tests/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,6 @@ def test_recognized_form(self, form_field_one, page_range, form_page):
)[:1024]
assert repr(model) == model_repr

def test_recognized_receipt(self, form_field_one, page_range, form_page):
model = _models.RecognizedReceipt(
form_type="receipt", fields={"one": form_field_one[0]}, page_range=page_range[0], pages=[form_page[0]])
model_repr = "RecognizedReceipt(form_type=receipt, fields={{'one': {}}}, page_range={}, pages=[{}])".format(
form_field_one[1], page_range[1], form_page[1]
)[:1024]
assert repr(model) == model_repr


def test_custom_form_model(self, custom_form_sub_model, form_recognizer_error, training_document_info):
model = _models.CustomFormModel(
model_id=1,
Expand Down