Skip to content

Commit

Permalink
add reading_order kwarg to clients
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinaperalta committed Mar 31, 2021
1 parent 14cb04e commit 517d9cf
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ def begin_recognize_content(self, form, **kwargs):
Content supports auto language identification and multilanguage documents, so only
provide a language code if you would like to force the documented to be processed as
that specific language.
:keyword str reading_order: Reading order algorithm to sort the text lines returned. Supported
reading orders include: basic (default), natural. Set 'basic' to sort lines left to right and top
to bottom, although in some cases proximity is treated with higher priority. Set 'natural' to sort
lines by those which are more closely related to each other.
:keyword content_type: Content-type of the body sent to the API. Content-type is
auto-detected, but can be overridden by passing this keyword argument. For options,
see :class:`~azure.ai.formrecognizer.FormContentType`.
Expand All @@ -614,7 +618,7 @@ def begin_recognize_content(self, form, **kwargs):
:raises ~azure.core.exceptions.HttpResponseError:
.. versionadded:: v2.1-preview
The *pages* and *language* keyword arguments and support for image/bmp content
The *pages*, *language* and *reading_order* keyword arguments and support for image/bmp content
.. admonition:: Example:
Expand All @@ -628,6 +632,7 @@ def begin_recognize_content(self, form, **kwargs):
pages = kwargs.pop("pages", None)
language = kwargs.pop("language", None)
content_type = kwargs.pop("content_type", None)
reading_order = kwargs.pop("reading_order", None)
if content_type == "application/json":
raise TypeError(
"Call begin_recognize_content_from_url() to analyze a document from a URL."
Expand All @@ -646,6 +651,14 @@ def begin_recognize_content(self, form, **kwargs):
"'pages' is only available for API version V2_1_PREVIEW and up"
)

if reading_order:
if self._api_version == FormRecognizerApiVersion.V2_1_PREVIEW:
kwargs.update({"reading_order": reading_order})
else:
raise ValueError(
"'reading_order' is only available for API version V2_1_PREVIEW and up"
)

if language:
if self._api_version == FormRecognizerApiVersion.V2_1_PREVIEW:
kwargs.update({"language": language})
Expand Down Expand Up @@ -679,6 +692,10 @@ def begin_recognize_content_from_url(self, form_url, **kwargs):
Content supports auto language identification and multilanguage documents, so only
provide a language code if you would like to force the documented to be processed as
that specific language.
:keyword str reading_order: Reading order algorithm to sort the text lines returned. Supported
reading orders include: basic (default), natural. Set 'basic' to sort lines left to right and top
to bottom, although in some cases proximity is treated with higher priority. Set 'natural' to sort
lines by those which are more closely related to each other.
: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.
Expand All @@ -688,10 +705,11 @@ def begin_recognize_content_from_url(self, form_url, **kwargs):
:raises ~azure.core.exceptions.HttpResponseError:
.. versionadded:: v2.1-preview
The *pages* and *language* keyword arguments and support for image/bmp content
The *pages*, *language* and *reading_order* keyword arguments and support for image/bmp content
"""
pages = kwargs.pop("pages", None)
language = kwargs.pop("language", None)
reading_order = kwargs.pop("reading_order", None)

# FIXME: part of this code will be removed once autorest can handle diff mixin
# signatures across API versions
Expand All @@ -703,6 +721,14 @@ def begin_recognize_content_from_url(self, form_url, **kwargs):
"'pages' is only available for API version V2_1_PREVIEW and up"
)

if reading_order:
if self._api_version == FormRecognizerApiVersion.V2_1_PREVIEW:
kwargs.update({"reading_order": reading_order})
else:
raise ValueError(
"'reading_order' is only available for API version V2_1_PREVIEW and up"
)

if language:
if self._api_version == FormRecognizerApiVersion.V2_1_PREVIEW:
kwargs.update({"language": language})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ async def begin_recognize_content(
Content supports auto language identification and multilanguage documents, so only
provide a language code if you would like to force the documented to be processed as
that specific language.
:keyword str reading_order: Reading order algorithm to sort the text lines returned. Supported
reading orders include: basic (default), natural. Set 'basic' to sort lines left to right and top
to bottom, although in some cases proximity is treated with higher priority. Set 'natural' to sort
lines by those which are more closely related to each other.
:keyword content_type: Content-type of the body sent to the API. Content-type is
auto-detected, but can be overridden by passing this keyword argument. For options,
see :class:`~azure.ai.formrecognizer.FormContentType`.
Expand All @@ -626,7 +630,7 @@ async def begin_recognize_content(
:raises ~azure.core.exceptions.HttpResponseError:
.. versionadded:: v2.1-preview
The *pages* and *language* keyword arguments and support for image/bmp content
The *pages*, *language* and *reading_order* keyword arguments and support for image/bmp content
.. admonition:: Example:
Expand All @@ -639,6 +643,7 @@ async def begin_recognize_content(
"""
pages = kwargs.pop("pages", None)
language = kwargs.pop("language", None)
reading_order = kwargs.pop("reading_order", None)
content_type = kwargs.pop("content_type", None)
if content_type == "application/json":
raise TypeError(
Expand All @@ -658,6 +663,14 @@ async def begin_recognize_content(
"'pages' is only available for API version V2_1_PREVIEW and up"
)

if reading_order:
if self._api_version == FormRecognizerApiVersion.V2_1_PREVIEW:
kwargs.update({"reading_order": reading_order})
else:
raise ValueError(
"'reading_order' is only available for API version V2_1_PREVIEW and up"
)

if language:
if self._api_version == FormRecognizerApiVersion.V2_1_PREVIEW:
kwargs.update({"language": language})
Expand Down Expand Up @@ -692,6 +705,10 @@ async def begin_recognize_content_from_url(
Content supports auto language identification and multilanguage documents, so only
provide a language code if you would like to force the documented to be processed as
that specific language.
:keyword str reading_order: Reading order algorithm to sort the text lines returned. Supported
reading orders include: basic (default), natural. Set 'basic' to sort lines left to right and top
to bottom, although in some cases proximity is treated with higher priority. Set 'natural' to sort
lines by those which are more closely related to each other.
: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.
Expand All @@ -701,10 +718,11 @@ async def begin_recognize_content_from_url(
:raises ~azure.core.exceptions.HttpResponseError:
.. versionadded:: v2.1-preview
The *pages* and *language* keyword arguments and support for image/bmp content
The *pages*, *language* and *reading_order* keyword arguments and support for image/bmp content
"""
pages = kwargs.pop("pages", None)
language = kwargs.pop("language", None)
reading_order = kwargs.pop("reading_order", None)

# FIXME: part of this code will be removed once autorest can handle diff mixin
# signatures across API versions
Expand All @@ -716,6 +734,14 @@ async def begin_recognize_content_from_url(
"'pages' is only available for API version V2_1_PREVIEW and up"
)

if reading_order:
if self._api_version == FormRecognizerApiVersion.V2_1_PREVIEW:
kwargs.update({"reading_order": reading_order})
else:
raise ValueError(
"'reading_order' is only available for API version V2_1_PREVIEW and up"
)

if language:
if self._api_version == FormRecognizerApiVersion.V2_1_PREVIEW:
kwargs.update({"language": language})
Expand Down

0 comments on commit 517d9cf

Please sign in to comment.