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] fix sphinx errors and unify transform testcase for FormFields #15056

Merged
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
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 @@ -476,7 +476,7 @@ These code samples show common scenario operations with the Azure Form Recognize
* Train a model with labels: [sample_train_model_with_labels.py][sample_train_model_with_labels]
* Manage custom models: [sample_manage_custom_models.py][sample_manage_custom_models]
* Copy a model between Form Recognizer resources: [sample_copy_model.py][sample_copy_model]
* Create a composed model from a collection of models trained with labels: |[sample_create_composed_model.py][sample_create_composed_model]
* Create a composed model from a collection of models trained with labels: [sample_create_composed_model.py][sample_create_composed_model]

### Async APIs
This library also includes a complete async API supported on Python 3.5+. To use it, you must
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def begin_recognize_receipts(self, receipt, **kwargs):
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

Expand Down Expand Up @@ -156,6 +157,7 @@ def begin_recognize_receipts_from_url(self, receipt_url, **kwargs):
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

Expand Down Expand Up @@ -219,6 +221,9 @@ def begin_recognize_business_cards(
:rtype: ~azure.core.polling.LROPoller[list[~azure.ai.formrecognizer.RecognizedForm]]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *begin_recognize_business_cards* client method

.. admonition:: Example:

.. literalinclude:: ../samples/sample_recognize_business_cards.py
Expand Down Expand Up @@ -281,6 +286,10 @@ def begin_recognize_business_cards_from_url(
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 *begin_recognize_business_cards_from_url* client method

"""

include_field_elements = kwargs.pop("include_field_elements", False)
Expand Down Expand Up @@ -334,6 +343,9 @@ def begin_recognize_invoices(
:rtype: ~azure.core.polling.LROPoller[list[~azure.ai.formrecognizer.RecognizedForm]]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *begin_recognize_invoices* client method

.. admonition:: Example:

.. literalinclude:: ../samples/sample_recognize_invoices.py
Expand Down Expand Up @@ -393,6 +405,9 @@ def begin_recognize_invoices_from_url(
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 *begin_recognize_invoices_from_url* client method
"""

include_field_elements = kwargs.pop("include_field_elements", False)
Expand Down Expand Up @@ -446,6 +461,7 @@ def begin_recognize_content(self, form, **kwargs):
object to return a list[:class:`~azure.ai.formrecognizer.FormPage`].
:rtype: ~azure.core.polling.LROPoller[list[~azure.ai.formrecognizer.FormPage]]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *pages* and *language* keyword arguments

Expand Down Expand Up @@ -513,6 +529,7 @@ def begin_recognize_content_from_url(self, form_url, **kwargs):
object to return a list[:class:`~azure.ai.formrecognizer.FormPage`].
:rtype: ~azure.core.polling.LROPoller[list[~azure.ai.formrecognizer.FormPage]]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *pages* and *language* keyword arguments
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def begin_training(self, training_files_url, use_training_labels, **kwargs):
:raises ~azure.core.exceptions.HttpResponseError:
Note that if the training fails, the exception is raised, but a model with an
"invalid" status is still created. You can delete this model by calling :func:`~delete_model()`

.. versionadded:: v2.1-preview
The *model_name* keyword argument

Expand Down Expand Up @@ -403,6 +404,9 @@ def begin_create_composed_model(
:rtype: ~azure.core.polling.LROPoller[~azure.ai.formrecognizer.CustomFormModel]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *begin_create_composed_model* client method

.. admonition:: Example:

.. literalinclude:: ../samples/sample_create_composed_model.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class RecognizedForm(object):
:ivar list[~azure.ai.formrecognizer.FormPage] pages:
A list of pages recognized from the input document. Contains lines,
words, tables and page metadata.

.. versionadded:: v2.1-preview
The *form_type_confidence* and *model_id* properties
"""
Expand Down Expand Up @@ -370,6 +371,7 @@ class FormPage(object):
logic should be built upon the actual line location instead of order.
:ivar selection_marks: List of selection marks extracted from the page.
:vartype selection_marks: list[~azure.ai.formrecognizer.FormSelectionMark]

.. versionadded:: v2.1-preview
*selection_marks* property
"""
Expand Down Expand Up @@ -415,6 +417,7 @@ class FormLine(FormElement):
:ivar str kind: For FormLine, this is "line".
:ivar appearance: Text appearance properties.
:vartype appearance: ~azure.ai.formrecognizer.Appearance

.. versionadded:: v2.1-preview
*appearance* property
"""
Expand Down Expand Up @@ -549,6 +552,7 @@ class FormTable(object):
that outlines the table. The points are listed in clockwise
order: top-left, top-right, bottom-right, bottom-left.
Units are in pixels for images and inches for PDF.

.. versionadded:: v2.1-preview
The *bounding_box* property.
"""
Expand Down Expand Up @@ -669,6 +673,7 @@ class CustomFormModel(object):
:ivar str model_name: Optional user defined model name.
:ivar properties: Optional model properties.
:vartype properties: ~azure.ai.formrecognizer.CustomFormModelProperties

.. versionadded:: v2.1-preview
The *model_name* and *properties* properties.
"""
Expand Down Expand Up @@ -747,6 +752,7 @@ class CustomFormSubmodel(object):
is generated for each field.
:vartype fields: dict[str, ~azure.ai.formrecognizer.CustomFormModelField]
:ivar str form_type: Type of form this submodel recognizes.

.. versionadded:: v2.1-preview
The *model_id* property
"""
Expand Down Expand Up @@ -861,6 +867,7 @@ class TrainingDocumentInfo(object):
List of any errors for document.
:ivar str model_id:
The model ID that used the document to train.

.. versionadded:: v2.1-preview
The *model_id* property
"""
Expand Down Expand Up @@ -947,6 +954,7 @@ class CustomFormModelInfo(object):
:vartype model_name: str
:ivar properties: Optional model properties.
:vartype properties: ~azure.ai.formrecognizer.CustomFormModelProperties

.. versionadded:: v2.1-preview
The *model_name* and *properties* properties
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ async def begin_recognize_receipts(
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

Expand Down Expand Up @@ -159,6 +160,7 @@ async def begin_recognize_receipts_from_url(
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

Expand Down Expand Up @@ -222,6 +224,9 @@ async def begin_recognize_business_cards(
:rtype: ~azure.core.polling.AsyncLROPoller[list[~azure.ai.formrecognizer.RecognizedForm]]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *begin_recognize_business_cards* client method

.. admonition:: Example:

.. literalinclude:: ../samples/async_samples/sample_recognize_business_cards_async.py
Expand Down Expand Up @@ -283,6 +288,10 @@ async def begin_recognize_business_cards_from_url(
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 *begin_recognize_business_cards_from_url* client method

"""
include_field_elements = kwargs.pop("include_field_elements", False)

Expand Down Expand Up @@ -334,6 +343,8 @@ async def begin_recognize_invoices(
:rtype: ~azure.core.polling.AsyncLROPoller[list[~azure.ai.formrecognizer.RecognizedForm]]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *begin_recognize_invoices* client method

.. admonition:: Example:

Expand Down Expand Up @@ -393,6 +404,9 @@ async def begin_recognize_invoices_from_url(
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 *begin_recognize_invoices_from_url* client method
"""

include_field_elements = kwargs.pop("include_field_elements", False)
Expand Down Expand Up @@ -449,6 +463,7 @@ async def begin_recognize_content(
object to return a list[:class:`~azure.ai.formrecognizer.FormPage`].
:rtype: ~azure.core.polling.AsyncLROPoller[list[~azure.ai.formrecognizer.FormPage]]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *pages* and *language* keyword arguments

Expand Down Expand Up @@ -515,6 +530,7 @@ async def begin_recognize_content_from_url(self, form_url: str, **kwargs: Any) -
object to return a list[:class:`~azure.ai.formrecognizer.FormPage`].
:rtype: ~azure.core.polling.AsyncLROPoller[list[~azure.ai.formrecognizer.FormPage]]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *pages* and *language* keyword arguments
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ async def begin_training(
:raises ~azure.core.exceptions.HttpResponseError:
Note that if the training fails, the exception is raised, but a model with an
"invalid" status is still created. You can delete this model by calling :func:`~delete_model()`

.. versionadded:: v2.1-preview
The *model_name* keyword argument

Expand Down Expand Up @@ -414,6 +415,9 @@ async def begin_create_composed_model(
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.formrecognizer.CustomFormModel]
:raises ~azure.core.exceptions.HttpResponseError:

.. versionadded:: v2.1-preview
The *begin_create_composed_model* client method

.. admonition:: Example:

.. literalinclude:: ../samples/async_samples/sample_create_composed_model_async.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def callback(raw_response, _, headers):
read_results = raw_response.analyze_result.read_results
document_results = raw_response.analyze_result.document_results

self.assertBusinessCardTransformCorrect(business_card, actual, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual, read_results)

# check page range
self.assertEqual(business_card.page_range.first_page_number, document_results[0].page_range[0])
Expand Down Expand Up @@ -200,7 +200,7 @@ def callback(raw_response, _, headers):
document_results = raw_response.analyze_result.document_results
page_results = raw_response.analyze_result.page_results

self.assertBusinessCardTransformCorrect(business_card, actual, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual, read_results)

# check page range
self.assertEqual(business_card.page_range.first_page_number, document_results[0].page_range[0])
Expand Down Expand Up @@ -242,7 +242,7 @@ def callback(raw_response, _, headers):
for i in range(len(returned_model)):
business_card = returned_model[i]
actual = document_results[i]
self.assertBusinessCardTransformCorrect(business_card, actual.fields, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual.fields, read_results)
self.assertEqual(i + 1, business_card.page_range.first_page_number)
self.assertEqual(i + 1, business_card.page_range.last_page_number)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def callback(raw_response, _, headers):
read_results = raw_response.analyze_result.read_results
document_results = raw_response.analyze_result.document_results

self.assertBusinessCardTransformCorrect(business_card, actual, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual, read_results)

# check page range
self.assertEqual(business_card.page_range.first_page_number, document_results[0].page_range[0])
Expand Down Expand Up @@ -215,7 +215,7 @@ def callback(raw_response, _, headers):
document_results = raw_response.analyze_result.document_results
page_results = raw_response.analyze_result.page_results

self.assertBusinessCardTransformCorrect(business_card, actual, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual, read_results)

# check page range
self.assertEqual(business_card.page_range.first_page_number, document_results[0].page_range[0])
Expand Down Expand Up @@ -258,7 +258,7 @@ def callback(raw_response, _, headers):
for i in range(len(returned_model)):
business_card = returned_model[i]
actual = document_results[i]
self.assertBusinessCardTransformCorrect(business_card, actual.fields, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual.fields, read_results)
self.assertEqual(i + 1, business_card.page_range.first_page_number)
self.assertEqual(i + 1, business_card.page_range.last_page_number)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def callback(raw_response, _, headers):
read_results = raw_response.analyze_result.read_results
document_results = raw_response.analyze_result.document_results

self.assertBusinessCardTransformCorrect(business_card, actual, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual, read_results)

# check page range
self.assertEqual(business_card.page_range.first_page_number, document_results[0].page_range[0])
Expand Down Expand Up @@ -134,7 +134,7 @@ def callback(raw_response, _, headers):
document_results = raw_response.analyze_result.document_results
page_results = raw_response.analyze_result.page_results

self.assertBusinessCardTransformCorrect(business_card, actual, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual, read_results)

# check page range
self.assertEqual(business_card.page_range.first_page_number, document_results[0].page_range[0])
Expand Down Expand Up @@ -173,7 +173,7 @@ def callback(raw_response, _, headers):
for i in range(len(returned_model)):
business_card = returned_model[i]
actual = document_results[i]
self.assertBusinessCardTransformCorrect(business_card, actual.fields, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual.fields, read_results)
self.assertEqual(i + 1, business_card.page_range.first_page_number)
self.assertEqual(i + 1, business_card.page_range.last_page_number)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def callback(raw_response, _, headers):
read_results = raw_response.analyze_result.read_results
document_results = raw_response.analyze_result.document_results

self.assertBusinessCardTransformCorrect(business_card, actual, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual, read_results)

# check page range
self.assertEqual(business_card.page_range.first_page_number, document_results[0].page_range[0])
Expand Down Expand Up @@ -145,7 +145,7 @@ def callback(raw_response, _, headers):
document_results = raw_response.analyze_result.document_results
page_results = raw_response.analyze_result.page_results

self.assertBusinessCardTransformCorrect(business_card, actual, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual, read_results)

# check page range
self.assertEqual(business_card.page_range.first_page_number, document_results[0].page_range[0])
Expand Down Expand Up @@ -185,7 +185,7 @@ def callback(raw_response, _, headers):
for i in range(len(returned_model)):
business_card = returned_model[i]
actual = document_results[i]
self.assertBusinessCardTransformCorrect(business_card, actual.fields, read_results)
self.assertFormFieldsTransformCorrect(business_card, actual.fields, read_results)
self.assertEqual(i + 1, business_card.page_range.first_page_number)
self.assertEqual(i + 1, business_card.page_range.last_page_number)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def callback(raw_response, _, headers):
self.assertEqual(recognized_form[0].page_range.last_page_number, page_results[0].page)
self.assertEqual(recognized_form[0].form_type_confidence, 1.0)
self.assertIsNotNone(recognized_form[0].model_id)
self.assertLabeledFormFieldDictTransformCorrect(recognized_form[0].fields, actual_fields, read_results)
self.assertFormFieldsTransformCorrect(recognized_form[0].fields, actual_fields, read_results)

@GlobalFormRecognizerAccountPreparer()
@GlobalClientPreparer(training=True, multipage=True)
Expand Down Expand Up @@ -365,7 +365,7 @@ def callback(raw_response, _, headers):
self.assertEqual(form.form_type, "custom:"+model.model_id)
self.assertEqual(form.form_type_confidence, 1.0)
self.assertEqual(form.model_id, model.model_id)
self.assertLabeledFormFieldDictTransformCorrect(form.fields, actual.fields, read_results)
self.assertFormFieldsTransformCorrect(form.fields, actual.fields, read_results)

@GlobalFormRecognizerAccountPreparer()
@GlobalClientPreparer(training=True)
Expand Down Expand Up @@ -470,7 +470,7 @@ def callback(raw_response, _, headers):
self.assertEqual(form.form_type, "custom:"+model.model_id)
self.assertEqual(form.form_type_confidence, 1.0)
self.assertEqual(form.model_id, model.model_id)
self.assertLabeledFormFieldDictTransformCorrect(form.fields, actual.fields, read_results)
self.assertFormFieldsTransformCorrect(form.fields, actual.fields, read_results)

@GlobalFormRecognizerAccountPreparer()
@GlobalClientPreparer(training=True, selection_marks=True)
Expand Down
Loading