diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md b/sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md index faf116b6d03c..96aa385cff03 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md +++ b/sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md @@ -1,7 +1,10 @@ # Change Log azure-ai-formrecognizer ## 1.0.0b4 (Unreleased) +**Breaking Changes** +- Remove `RecognizedReceipts` Class. +- `begin_recognize_receipts` and `begin_recognize_receipts_from_url` now return `RecognizedForm`. ## 1.0.0b3 (2020-06-10) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/README.md b/sdk/formrecognizer/azure-ai-formrecognizer/README.md index 4b0cdfcedd38..9096cb5ba62e 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/README.md +++ b/sdk/formrecognizer/azure-ai-formrecognizer/README.md @@ -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. ### FormTrainingClient `FormTrainingClient` provides operations for: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/__init__.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/__init__.py index 51337f5f5395..475b8b041f03 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/__init__.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/__init__.py @@ -31,7 +31,6 @@ CustomFormModel, CustomFormSubmodel, CustomFormModelField, - RecognizedReceipt ) @@ -60,7 +59,6 @@ 'CustomFormModel', 'CustomFormSubmodel', 'CustomFormModelField', - 'RecognizedReceipt' ] __VERSION__ = VERSION diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_recognizer_client.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_recognizer_client.py index b5349668390e..315b3d328924 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_recognizer_client.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_recognizer_client.py @@ -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): @@ -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'. @@ -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: @@ -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. @@ -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: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_models.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_models.py index f364579193c5..ffaeaa2e0538 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_models.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_models.py @@ -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. diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_response_handlers.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_response_handlers.py index 90fe97582902..b1ec8c79a957 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_response_handlers.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_response_handlers.py @@ -13,8 +13,7 @@ FormTable, FormTableCell, FormPageRange, - RecognizedForm, - RecognizedReceipt + RecognizedForm ) @@ -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] ), diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_recognizer_client_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_recognizer_client_async.py index 3e26bd518e27..1f5c0d19d43b 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_recognizer_client_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_recognizer_client_async.py @@ -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 @@ -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'. @@ -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: @@ -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. @@ -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: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_repr.py b/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_repr.py index 9510f300bc59..4b53154b36b2 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_repr.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_repr.py @@ -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,