Skip to content

Commit b33b8ec

Browse files
authored
Changes in docs [Form Recognizer] (#12216)
* initial commit * one more change * readme * Apply suggestions from code review * Update sdk/formrecognizer/azure-ai-formrecognizer/README.md * Update sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_training_client.py * Update sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_training_client.py * comments
1 parent 83ac5e9 commit b33b8ec

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

sdk/formrecognizer/azure-ai-formrecognizer/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ for recognized_form in result:
184184
))
185185
```
186186

187+
Alternatively, a form url can also be used to recognize custom forms using the `begin_recognize_custom_forms_from_url` method. The `_from_url` methods exist for
188+
all the recognize methods.
189+
190+
191+
```
192+
form_url_jpg = "<url_of_the_form>"
193+
poller = form_recognizer_client.begin_recognize_custom_forms_from_url(model_id=model_id, form_url=form_url)
194+
result = poller.result()
195+
```
196+
187197
### Recognize Content
188198
Recognize text and table structures, along with their bounding box coordinates, from documents.
189199

@@ -323,6 +333,14 @@ except ResourceNotFoundError:
323333
print("Successfully deleted model with id {}".format(custom_model.model_id))
324334
```
325335

336+
## Async APIs
337+
This library also includes a complete async API supported on Python 3.5+. To use it, you must
338+
first install an async transport, such as [aiohttp](https://pypi.org/project/aiohttp/).
339+
See
340+
[azure-core documentation](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md#transport)
341+
for more information.
342+
343+
326344
## Optional Configuration
327345

328346
Optional keyword arguments can be passed in at the client and per-operation level.
@@ -407,6 +425,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
407425
[python-fr-product-docs]: https://docs.microsoft.com/azure/cognitive-services/form-recognizer/overview
408426
[python-fr-ref-docs]: https://aka.ms/azsdk/python/formrecognizer/docs
409427
[python-fr-samples]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer/samples
428+
[train-a-model-using-labeled-data]: https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/python-labeled-data#train-a-model-using-labeled-data
410429

411430

412431
[quickstart_training]: https://docs.microsoft.com/azure/cognitive-services/form-recognizer/quickstarts/curl-train-extract#train-a-form-recognizer-model

sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_training_client.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ def __init__(self, endpoint, credential, **kwargs):
9393
def begin_training(self, training_files_url, use_training_labels, **kwargs):
9494
# type: (str, bool, Any) -> LROPoller[CustomFormModel]
9595
"""Create and train a custom model. The request must include a `training_files_url` parameter that is an
96-
externally accessible Azure storage blob container Uri (preferably a Shared Access Signature Uri).
96+
externally accessible Azure storage blob container Uri (preferably a Shared Access Signature Uri). Note that
97+
a container uri is accepted only when the container is public.
9798
Models are trained using documents that are of the following content type - 'application/pdf',
9899
'image/jpeg', 'image/png', 'image/tiff'. Other type of content in the container is ignored.
99100
100-
:param str training_files_url: An Azure Storage blob container's SAS URI.
101+
:param str training_files_url: An Azure Storage blob container's SAS URI. A container uri can be used if the
102+
container is public.
101103
:param bool use_training_labels: Whether to train with labels or not. Corresponding labeled files must
102104
exist in the blob container.
103105
:keyword str prefix: A case-sensitive prefix string to filter documents in the source path for
@@ -278,7 +280,9 @@ def get_copy_authorization(self, resource_id, resource_region, **kwargs):
278280
:param str resource_id: Azure Resource Id of the target Form Recognizer resource
279281
where the model will be copied to.
280282
:param str resource_region: Location of the target Form Recognizer resource. A valid Azure
281-
region name supported by Cognitive Services.
283+
region name supported by Cognitive Services. For example, 'westus', 'eastus' etc.
284+
See https://azure.microsoft.com/global-infrastructure/services/?products=cognitive-services
285+
for the regional availability of Cognitive Services
282286
:return: A dictionary with values for the copy authorization -
283287
"modelId", "accessToken", "resourceId", "resourceRegion", and "expirationDateTimeTicks".
284288
:rtype: Dict[str, Union[str, int]]

sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_models.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ class FieldText(FormContent):
250250
Units are in pixels for images and inches for PDF.
251251
:ivar text_content:
252252
When `include_text_content` is set to true, a list of text
253-
elements constituting this field or value is returned.
253+
elements constituting this field or value is returned. The list
254+
constitutes of text elements such as lines and words.
254255
:vartype text_content: list[~azure.ai.formrecognizer.FormWord, ~azure.ai.formrecognizer.FormLine]
255256
"""
256257

@@ -472,7 +473,8 @@ class FormTableCell(FormContent):
472473
The 1-based number of the page in which this content is present.
473474
:ivar text_content:
474475
When `include_text_content` is set to true, a list of text
475-
elements constituting this cell is returned.
476+
elements constituting this cell is returned. The list
477+
constitutes of text elements such as lines and words.
476478
For calls to recognize content, this list is always populated.
477479
:vartype text_content: list[~azure.ai.formrecognizer.FormWord, ~azure.ai.formrecognizer.FormLine]
478480
"""

sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_training_client_async.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ async def begin_training(
102102
**kwargs: Any
103103
) -> AsyncLROPoller[CustomFormModel]:
104104
"""Create and train a custom model. The request must include a `training_files_url` parameter that is an
105-
externally accessible Azure storage blob container Uri (preferably a Shared Access Signature Uri).
105+
externally accessible Azure storage blob container Uri (preferably a Shared Access Signature Uri). Note that
106+
a container uri is accepted only when the container is public.
106107
Models are trained using documents that are of the following content type - 'application/pdf',
107108
'image/jpeg', 'image/png', 'image/tiff'. Other type of content in the container is ignored.
108109
109-
:param str training_files_url: An Azure Storage blob container's SAS URI.
110+
:param str training_files_url: An Azure Storage blob container's SAS URI. A container uri can be used if the
111+
container is public.
110112
:param bool use_training_labels: Whether to train with labels or not. Corresponding labeled files must
111113
exist in the blob container.
112114
:keyword str prefix: A case-sensitive prefix string to filter documents in the source path for
@@ -300,7 +302,9 @@ async def get_copy_authorization(
300302
:param str resource_id: Azure Resource Id of the target Form Recognizer resource
301303
where the model will be copied to.
302304
:param str resource_region: Location of the target Form Recognizer resource. A valid Azure
303-
region name supported by Cognitive Services.
305+
region name supported by Cognitive Services. For example, 'westus', 'eastus' etc.
306+
See https://azure.microsoft.com/global-infrastructure/services/?products=cognitive-services
307+
for the regional availability of Cognitive Services
304308
:return: A dictionary with values for the copy authorization -
305309
"modelId", "accessToken", "resourceId", "resourceRegion", and "expirationDateTimeTicks".
306310
:rtype: Dict[str, Union[str, int]]

sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_copy_model_async.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
1212
DESCRIPTION:
1313
This sample demonstrates how to copy a custom model from a source Form Recognizer resource
14-
to a target Form Recognizer resource.
14+
to a target Form Recognizer resource. The resource id and the resource region can be found
15+
in the azure portal.
1516
1617
USAGE:
1718
python sample_copy_model_async.py

sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_copy_model.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
1212
DESCRIPTION:
1313
This sample demonstrates how to copy a custom model from a source Form Recognizer resource
14-
to a target Form Recognizer resource.
14+
to a target Form Recognizer resource. The resource id and the resource region can be found
15+
in the azure portal.
1516
1617
USAGE:
1718
python sample_copy_model.py

0 commit comments

Comments
 (0)