Skip to content

Commit

Permalink
some small docs fixes/improvements (#18894)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapratico authored May 25, 2021
1 parent f9aa2ea commit deb5edc
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 41 deletions.
4 changes: 2 additions & 2 deletions sdk/formrecognizer/azure-ai-formrecognizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit deb5edc

Please sign in to comment.