From deb5edc3d2abb7513aa9d50209e7a5a0ef252821 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Tue, 25 May 2021 08:34:02 -0700 Subject: [PATCH] some small docs fixes/improvements (#18894) --- .../azure-ai-formrecognizer/README.md | 4 +- .../formrecognizer/_form_recognizer_client.py | 7 ++- .../formrecognizer/_form_training_client.py | 2 +- .../azure/ai/formrecognizer/_models.py | 4 +- .../aio/_form_recognizer_client_async.py | 7 ++- .../aio/_form_training_client_async.py | 2 +- .../sample_create_composed_model_async.py | 57 ++++++++++--------- ...mple_recognize_identity_documents_async.py | 4 +- 8 files changed, 46 insertions(+), 41 deletions(-) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/README.md b/sdk/formrecognizer/azure-ai-formrecognizer/README.md index 8c51ce8a1255..deec1922ebb6 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/README.md +++ b/sdk/formrecognizer/azure-ai-formrecognizer/README.md @@ -34,7 +34,7 @@ This table shows the relationship between SDK versions and supported API version |SDK version|Supported API version of service |-|- |3.1.0 - Latest GA release| 2.0, 2.1 (default) - +|3.0.0| 2.0 #### Create a Form Recognizer resource Form Recognizer supports both [multi-service and single-service access][multi_and_single_service]. @@ -147,7 +147,7 @@ Sample code snippets are provided to illustrate using a FormRecognizerClient [he `FormTrainingClient` provides operations for: - Training custom models without labels to recognize all fields and values found in your custom forms. A `CustomFormModel` is returned indicating the form types the model will recognize, and the fields it will extract for each form type. See the [service documentation][fr-train-without-labels] for a more detailed explanation. -- Training custom models with labels to recognize specific fields, selection marks, and values you specify by labeling your custom forms. A `CustomFormModel` is returned indicating the fields the model will extract, as well as the estimated accuracy for each field. See the [service documentation][fr-train-with-labels] for a more detailed explanation. +- Training custom models with labels to recognize specific fields, selection marks, tables, and values you specify by labeling your custom forms. A `CustomFormModel` is returned indicating the fields the model will extract, as well as the estimated accuracy for each field. See the [service documentation][fr-train-with-labels] for a more detailed explanation. - Managing models created in your account. - Copying a custom model from one Form Recognizer resource to another. - Creating a composed model from a collection of existing trained models with labels. 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 62cd844fb13b..bd1863ffa544 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 @@ -27,9 +27,10 @@ class FormRecognizerClient(FormRecognizerClientBase): """FormRecognizerClient extracts information from forms and images into structured data. - It is the interface to use for analyzing receipts, business cards, invoices, recognizing - content/layout from forms, and analyzing custom forms from trained models. It provides - different methods based on inputs from a URL and inputs from a stream. + It is the interface to use for analyzing with prebuilt models (receipts, business cards, + invoices, identity documents), recognizing content/layout from forms, and analyzing + custom forms from trained models. It provides different methods based on inputs from a + URL and inputs from a stream. :param str endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_training_client.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_training_client.py index 03b0f0278027..795c49902c69 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_training_client.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_training_client.py @@ -438,7 +438,7 @@ def begin_create_composed_model(self, model_ids, **kwargs): A composed model allows multiple models to be called with a single model ID. When a document is submitted to be analyzed with a composed model ID, a classification step is first performed to - route it to the correct custom model + route it to the correct custom model. :param list[str] model_ids: List of model IDs to use in the composed model. :keyword str model_name: An optional, user-defined name to associate with your model. 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 a4fbef503f0c..93b2d752cfda 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_models.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_models.py @@ -627,7 +627,9 @@ class FormPage(object): returned is 300 per page. The lines are sorted top to bottom, left to right, although in certain cases proximity is treated with higher priority. As the sorting order depends on the detected text, it may change across images and OCR version updates. Thus, business - logic should be built upon the actual line location instead of order. + logic should be built upon the actual line location instead of order. The reading order + of lines can be specified by the `reading_order` keyword argument (Note: `reading_order` + only supported in `begin_recognize_content` and `begin_recognize_content_from_url`). :ivar selection_marks: List of selection marks extracted from the page. :vartype selection_marks: list[~azure.ai.formrecognizer.FormSelectionMark] 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 81b0c324733c..0ed8f663b5fe 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 @@ -24,9 +24,10 @@ class FormRecognizerClient(FormRecognizerClientBaseAsync): """FormRecognizerClient extracts information from forms and images into structured data. - It is the interface to use for analyzing receipts, business cards, invoices, recognizing - content/layout from forms, and analyzing custom forms from trained models. It provides - different methods based on inputs from a URL and inputs from a stream. + It is the interface to use for analyzing with prebuilt models (receipts, business cards, + invoices, identity documents), recognizing content/layout from forms, and analyzing + custom forms from trained models. It provides different methods based on inputs from a + URL and inputs from a stream. :param str endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_training_client_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_training_client_async.py index dad7a1e993aa..e6eda6b81e38 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_training_client_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_training_client_async.py @@ -426,7 +426,7 @@ async def begin_create_composed_model( A composed model allows multiple models to be called with a single model ID. When a document is submitted to be analyzed with a composed model ID, a classification step is first performed to - route it to the correct custom model + route it to the correct custom model. :param list[str] model_ids: List of model IDs to use in the composed model. :keyword str model_name: An optional, user-defined name to associate with your model. diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_create_composed_model_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_create_composed_model_async.py index cdc0698f4f1c..2254773d8394 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_create_composed_model_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_create_composed_model_async.py @@ -54,34 +54,35 @@ async def create_composed_model_async(self): po_cleaning_supplies = os.environ['PURCHASE_ORDER_OFFICE_CLEANING_SUPPLIES_SAS_URL'] form_training_client = FormTrainingClient(endpoint=endpoint, credential=AzureKeyCredential(key)) - supplies_poller = await form_training_client.begin_training( - po_supplies, use_training_labels=True, model_name="Purchase order - Office supplies" - ) - equipment_poller = await form_training_client.begin_training( - po_equipment, use_training_labels=True, model_name="Purchase order - Office Equipment" - ) - furniture_poller = await form_training_client.begin_training( - po_furniture, use_training_labels=True, model_name="Purchase order - Furniture" - ) - cleaning_supplies_poller = await form_training_client.begin_training( - po_cleaning_supplies, use_training_labels=True, model_name="Purchase order - Cleaning Supplies" - ) - supplies_model = await supplies_poller.result() - equipment_model = await equipment_poller.result() - furniture_model = await furniture_poller.result() - cleaning_supplies_model = await cleaning_supplies_poller.result() - - models_trained_with_labels = [ - supplies_model.model_id, - equipment_model.model_id, - furniture_model.model_id, - cleaning_supplies_model.model_id - ] - - poller = await form_training_client.begin_create_composed_model( - models_trained_with_labels, model_name="Office Supplies Composed Model" - ) - model = await poller.result() + async with form_training_client: + supplies_poller = await form_training_client.begin_training( + po_supplies, use_training_labels=True, model_name="Purchase order - Office supplies" + ) + equipment_poller = await form_training_client.begin_training( + po_equipment, use_training_labels=True, model_name="Purchase order - Office Equipment" + ) + furniture_poller = await form_training_client.begin_training( + po_furniture, use_training_labels=True, model_name="Purchase order - Furniture" + ) + cleaning_supplies_poller = await form_training_client.begin_training( + po_cleaning_supplies, use_training_labels=True, model_name="Purchase order - Cleaning Supplies" + ) + supplies_model = await supplies_poller.result() + equipment_model = await equipment_poller.result() + furniture_model = await furniture_poller.result() + cleaning_supplies_model = await cleaning_supplies_poller.result() + + models_trained_with_labels = [ + supplies_model.model_id, + equipment_model.model_id, + furniture_model.model_id, + cleaning_supplies_model.model_id + ] + + poller = await form_training_client.begin_create_composed_model( + models_trained_with_labels, model_name="Office Supplies Composed Model" + ) + model = await poller.result() print("Office Supplies Composed Model Info:") print("Model ID: {}".format(model.model_id)) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_identity_documents_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_identity_documents_async.py index 9bbab8201d0c..ed0c61f6fb1b 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_identity_documents_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_identity_documents_async.py @@ -33,7 +33,7 @@ async def recognize_identity_documents(self): path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "./../sample_forms/id_documents/license.jpg")) - # [START recognize_identity_documents] + # [START recognize_identity_documents_async] from azure.core.credentials import AzureKeyCredential from azure.ai.formrecognizer.aio import FormRecognizerClient @@ -78,7 +78,7 @@ async def recognize_identity_documents(self): region = id_document.fields.get("Region") if region: print("Region: {} has confidence: {}".format(region.value, region.confidence)) - # [END recognize_identity_documents] + # [END recognize_identity_documents_async] async def main(): sample = RecognizeIdDocumentsSampleAsync()