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

[formrecognizer] add locale to receipt samples #14292

Merged
merged 2 commits into from
Oct 6, 2020
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
4 changes: 4 additions & 0 deletions sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 3.1.0b1 (Unreleased)

**New features**

- Recognize receipt methods now take keyword argument `locale` to optionally indicate the locale of the receipt for
improved results

## 3.0.0 (2020-08-20)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ def begin_recognize_receipts(self, receipt, **kwargs):
:keyword int polling_interval: Waiting time between two polls for LRO operations
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.
:keyword str locale: Locale of the receipt. Defaults to en-US. Supported locales include:
en-US, en-AU, en-CA, en-GB, and en-IN.
:return: An instance of an LROPoller. Call `result()` on the poller
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:
.. versionadded:: v2.1-preview
The *locale* keyword argument

.. admonition:: Example:

Expand Down Expand Up @@ -142,10 +146,14 @@ def begin_recognize_receipts_from_url(self, receipt_url, **kwargs):
:keyword int polling_interval: Waiting time between two polls for LRO operations
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.
:keyword str locale: Locale of the receipt. Defaults to en-US. Supported locales include:
en-US, en-AU, en-CA, en-GB, and en-IN.
:return: An instance of an LROPoller. Call `result()` on the poller
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:
.. versionadded:: v2.1-preview
The *locale* keyword argument

.. admonition:: Example:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ async def begin_recognize_receipts(
:keyword int polling_interval: Waiting time between two polls for LRO operations
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.
:keyword str locale: Locale of the receipt. Defaults to en-US. Supported locales include:
en-US, en-AU, en-CA, en-GB, and en-IN.
:return: An instance of an AsyncLROPoller. Call `result()` on the poller
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:
.. versionadded:: v2.1-preview
The *locale* keyword argument

.. admonition:: Example:

Expand Down Expand Up @@ -145,10 +149,14 @@ async def begin_recognize_receipts_from_url(
:keyword int polling_interval: Waiting time between two polls for LRO operations
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.
:keyword str locale: Locale of the receipt. Defaults to en-US. Supported locales include:
en-US, en-AU, en-CA, en-GB, and en-IN.
:return: An instance of an AsyncLROPoller. Call `result()` on the poller
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:
.. versionadded:: v2.1-preview
The *locale* keyword argument

.. admonition:: Example:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def recognize_receipts(self):
) as form_recognizer_client:

with open(path_to_sample_forms, "rb") as f:
poller = await form_recognizer_client.begin_recognize_receipts(receipt=f)
poller = await form_recognizer_client.begin_recognize_receipts(receipt=f, locale="en-US")
Copy link
Contributor

Choose a reason for hiding this comment

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

also sorry for trampling on the reason of this PR, but is it necessary to include locale in the samples, esp since it's a kwarg and we're passing in the default value?

Copy link
Member Author

Choose a reason for hiding this comment

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

Wanted to show how to pass it at least somewhere so added to one of the samples. I don't think it would make sense to use a non-english example, so thought explicitly passing it here wouldn't hurt.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok that's fair


receipts = await poller.result()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def recognize_receipts(self):
endpoint=endpoint, credential=AzureKeyCredential(key)
)
with open(path_to_sample_forms, "rb") as f:
poller = form_recognizer_client.begin_recognize_receipts(receipt=f)
poller = form_recognizer_client.begin_recognize_receipts(receipt=f, locale="en-US")
receipts = poller.result()

for idx, receipt in enumerate(receipts):
Expand Down