Skip to content

Commit dc22490

Browse files
[formrecognizer] docs edits (Azure#21030)
* readme edits * fix some docstrings * fix asyncitempaged docstring type * samples edits * remove unimported helper method from migration guide * update link on build model
1 parent 9922c0b commit dc22490

File tree

11 files changed

+40
-36
lines changed

11 files changed

+40
-36
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,21 @@ for idx, content in enumerate(form_pages):
249249
))
250250
for table_idx, table in enumerate(content.tables):
251251
print("Table # {} has {} rows and {} columns".format(table_idx, table.row_count, table.column_count))
252-
print("Table # {} location on page: {}".format(table_idx, format_bounding_box(table.bounding_box)))
252+
print("Table # {} location on page: {}".format(table_idx, table.bounding_box))
253253
for cell in table.cells:
254254
print("...Cell[{}][{}] has text '{}' within bounding box '{}'".format(
255255
cell.row_index,
256256
cell.column_index,
257257
cell.text,
258-
format_bounding_box(cell.bounding_box)
258+
cell.bounding_box
259259
))
260260

261261
for line_idx, line in enumerate(content.lines):
262262
print("Line # {} has word count '{}' and text '{}' within bounding box '{}'".format(
263263
line_idx,
264264
len(line.words),
265265
line.text,
266-
format_bounding_box(line.bounding_box)
266+
line.bounding_box
267267
))
268268
if line.appearance:
269269
if line.appearance.style_name == "handwriting" and line.appearance.style_confidence > 0.8:
@@ -274,7 +274,7 @@ for idx, content in enumerate(form_pages):
274274
for selection_mark in content.selection_marks:
275275
print("Selection mark is '{}' within bounding box '{}' and has a confidence of {}".format(
276276
selection_mark.state,
277-
format_bounding_box(selection_mark.bounding_box),
277+
selection_mark.bounding_box,
278278
selection_mark.confidence
279279
))
280280
print("----------------------------------------")
@@ -309,7 +309,7 @@ for idx, page in enumerate(result.pages):
309309
"Line # {} has text content '{}' within bounding box '{}'".format(
310310
line_idx,
311311
line.content,
312-
format_bounding_box(line.bounding_box),
312+
line.bounding_box,
313313
)
314314
)
315315

@@ -324,7 +324,7 @@ for idx, page in enumerate(result.pages):
324324
print(
325325
"Selection mark is '{}' within bounding box '{}' and has a confidence of {}".format(
326326
selection_mark.state,
327-
format_bounding_box(selection_mark.bounding_box),
327+
selection_mark.bounding_box,
328328
selection_mark.confidence,
329329
)
330330
)
@@ -340,7 +340,7 @@ for table_idx, table in enumerate(result.tables):
340340
"Table # {} location on page: {} is {}".format(
341341
table_idx,
342342
region.page_number,
343-
format_bounding_box(region.bounding_box),
343+
region.bounding_box,
344344
)
345345
)
346346
for cell in table.cells:
@@ -355,7 +355,7 @@ for table_idx, table in enumerate(result.tables):
355355
print(
356356
"...content on page {} is within bounding box '{}'".format(
357357
region.page_number,
358-
format_bounding_box(region.bounding_box),
358+
region.bounding_box,
359359
)
360360
)
361361

@@ -393,7 +393,7 @@ for page in result.pages:
393393
"...Line # {} has text content '{}' within bounding box '{}'".format(
394394
line_idx,
395395
line.content,
396-
format_bounding_box(line.bounding_box),
396+
line.bounding_box,
397397
)
398398
)
399399

@@ -408,7 +408,7 @@ for page in result.pages:
408408
print(
409409
"...Selection mark is '{}' within bounding box '{}' and has a confidence of {}".format(
410410
selection_mark.state,
411-
format_bounding_box(selection_mark.bounding_box),
411+
selection_mark.bounding_box,
412412
selection_mark.confidence,
413413
)
414414
)
@@ -424,7 +424,7 @@ for table_idx, table in enumerate(result.tables):
424424
"Table # {} location on page: {} is {}".format(
425425
table_idx,
426426
region.page_number,
427-
format_bounding_box(region.bounding_box),
427+
region.bounding_box,
428428
)
429429
)
430430
for cell in table.cells:
@@ -439,15 +439,15 @@ for table_idx, table in enumerate(result.tables):
439439
print(
440440
"...content on page {} is within bounding box '{}'\n".format(
441441
region.page_number,
442-
format_bounding_box(region.bounding_box),
442+
region.bounding_box,
443443
)
444444
)
445445

446446
print("----Entities found in document----")
447447
for entity in result.entities:
448448
print("Entity of category '{}' with sub-category '{}'".format(entity.category, entity.sub_category))
449449
print("...has content '{}'".format(entity.content))
450-
print("...within '{}' bounding regions".format(format_bounding_region(entity.bounding_regions)))
450+
print("...within '{}' bounding regions".format(entity.bounding_regions))
451451
print("...with confidence {}\n".format(entity.confidence))
452452

453453
print("----Key-value pairs found in document----")
@@ -456,14 +456,14 @@ for kv_pair in result.key_value_pairs:
456456
print(
457457
"Key '{}' found within '{}' bounding regions".format(
458458
kv_pair.key.content,
459-
format_bounding_region(kv_pair.key.bounding_regions),
459+
kv_pair.key.bounding_regions,
460460
)
461461
)
462462
if kv_pair.value:
463463
print(
464464
"Value '{}' found within '{}' bounding regions\n".format(
465465
kv_pair.value.content,
466-
format_bounding_region(kv_pair.value.bounding_regions),
466+
kv_pair.value.bounding_regions,
467467
)
468468
)
469469
print("----------------------------------------")

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Sample code snippets are provided to illustrate using long-running operations [b
190190

191191
The following section provides several code snippets covering some of the most common Form Recognizer tasks, including:
192192

193-
* [Extract layout](#extract-layout "Extract Layout")
193+
* [Extract Layout](#extract-layout "Extract Layout")
194194
* [Using Prebuilt Models](#using-prebuilt-models "Using Prebuilt Models")
195195
* [Using Prebuilt Document](#using-prebuilt-document "Using Prebuilt Document")
196196
* [Build a Model](#build-a-model "Build a model")
@@ -276,7 +276,7 @@ for table_idx, table in enumerate(result.tables):
276276
### Using Prebuilt Models
277277
Extract fields from select document types such as receipts, invoices, business cards, and identity documents using prebuilt models provided by the Form Recognizer service.
278278

279-
For example, to analyze fields from a sales receipt, use the prebuilt receipt model provided by passing `model="prebuilt-receipt"` into the `begin_analyze_documents` method:
279+
For example, to analyze fields from a sales receipt, use the prebuilt receipt model provided by passing `model="prebuilt-receipt"` into the `begin_analyze_document` method:
280280

281281
```python
282282
from azure.ai.formrecognizer import DocumentAnalysisClient
@@ -314,7 +314,7 @@ You are not limited to receipts! There are a few prebuilt models to choose from,
314314

315315
### Using Prebuilt Document
316316
Analyze entities, key-value pairs, tables, styles, and selection marks from documents using the general prebuilt document model provided by the Form Recognizer service.
317-
Select the Prebuilt Document model by passing `model="prebuilt-document"` into the `begin_analyze_documents` method:
317+
Select the Prebuilt Document model by passing `model="prebuilt-document"` into the `begin_analyze_document` method:
318318

319319
```python
320320
from azure.ai.formrecognizer import DocumentAnalysisClient

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def begin_build_model(self, source, **kwargs):
9898
9999
:param str source: An Azure Storage blob container's SAS URI. A container URI (without SAS)
100100
can be used if the container is public. For more information on setting up a training data set, see:
101-
https://docs.microsoft.com/azure/cognitive-services/form-recognizer/build-training-data-set
101+
https://aka.ms/azsdk/formrecognizer/buildtrainingset
102102
:keyword str model_id: A unique ID for your model. If not specified, a model ID will be created for you.
103103
:keyword str description: An optional description to add to the model.
104104
:keyword str prefix: A case-sensitive prefix string to filter documents in the source path.

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ def from_dict(cls, data):
20662066

20672067

20682068
class BoundingRegion(object):
2069-
"""The bounding box corresponding to a page.
2069+
"""The bounding region corresponding to a page.
20702070
20712071
:ivar list[~azure.ai.formrecognizer.Point] bounding_box:
20722072
A list of 4 points representing the quadrilateral bounding box
@@ -2132,7 +2132,9 @@ class DocumentElement(object):
21322132
:vartype content: str
21332133
:ivar bounding_box: Bounding box of the word.
21342134
:vartype bounding_box: list[Point]
2135-
:ivar str kind:
2135+
:ivar str kind: The kind of document element. Possible kinds are "word" or "selectionMark" which
2136+
correspond to a :class:`~azure.ai.formrecognizer.DocumentWord` or
2137+
:class:`~azure.ai.formrecognizer.DocumentSelectionMark`, respectively.
21362138
"""
21372139

21382140
def __init__(self, **kwargs):
@@ -2857,7 +2859,7 @@ class DocumentSelectionMark(DocumentElement):
28572859
:vartype span: ~azure.ai.formrecognizer.DocumentSpan
28582860
:ivar confidence: Confidence of correctly extracting the selection mark.
28592861
:vartype confidence: float
2860-
:ivar str kind:
2862+
:ivar str kind: For DocumentSelectionMark, this is "selectionMark".
28612863
"""
28622864

28632865
def __init__(self, **kwargs):
@@ -3418,7 +3420,7 @@ class DocumentWord(DocumentElement):
34183420
:vartype span: ~azure.ai.formrecognizer.DocumentSpan
34193421
:ivar confidence: Confidence of correctly extracting the word.
34203422
:vartype confidence: float
3421-
:ivar str kind:
3423+
:ivar str kind: For DocumentWord, this is "word".
34223424
"""
34233425

34243426
def __init__(self, **kwargs):

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def parse_operation_id(location):
4747

4848

4949
class DocumentModelAdministrationLROPoller(LROPoller[PollingReturnType]):
50-
"""Custom poller for model build operations.
50+
"""Custom poller for model build operations. Call `result()` on the poller to return
51+
a :class:`~azure.ai.formrecognizer.DocumentModel`.
5152
5253
.. versionadded:: v2021-09-30-preview
5354
The *DocumentModelAdministrationLROPoller* poller object

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717

1818
class AsyncDocumentModelAdministrationLROPoller(AsyncLROPoller[PollingReturnType]):
19-
"""Custom poller for model build operations.
19+
"""Custom poller for model build operations. Call `result()` on the poller to return
20+
a :class:`~azure.ai.formrecognizer.DocumentModel`.
2021
2122
.. versionadded:: v2021-09-30-preview
2223
The *AsyncDocumentModelAdministrationLROPoller* poller object

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def begin_build_model(
106106
107107
:param str source: An Azure Storage blob container's SAS URI. A container URI (without SAS)
108108
can be used if the container is public. For more information on setting up a training data set, see:
109-
https://docs.microsoft.com/azure/cognitive-services/form-recognizer/build-training-data-set
109+
https://aka.ms/azsdk/formrecognizer/buildtrainingset
110110
:keyword str model_id: A unique ID for your model. If not specified, a model ID will be created for you.
111111
:keyword str description: An optional description to add to the model.
112112
:keyword str prefix: A case-sensitive prefix string to filter documents in the source path.
@@ -350,7 +350,7 @@ def list_models(self, **kwargs: Any) -> AsyncItemPaged[DocumentModelInfo]:
350350
description, and when it was created.
351351
352352
:return: Pageable of DocumentModelInfo.
353-
:rtype: ~azure.core.paging.async_paging.AsyncItemPaged[DocumentModelInfo]
353+
:rtype: ~azure.core.async_paging.AsyncItemPaged[DocumentModelInfo]
354354
:raises ~azure.core.exceptions.HttpResponseError:
355355
356356
.. admonition:: Example:
@@ -434,7 +434,7 @@ def list_operations(self, **kwargs: Any) -> AsyncItemPaged[ModelOperationInfo]:
434434
the document model can be accessed using the :func:`~get_model` or :func:`~list_models` APIs.
435435
436436
:return: A pageable of ModelOperationInfo.
437-
:rtype: ~azure.core.paging.async_paging.AsyncItemPaged[ModelOperationInfo]
437+
:rtype: ~azure.core.async_paging.AsyncItemPaged[ModelOperationInfo]
438438
:raises ~azure.core.exceptions.HttpResponseError:
439439
440440
.. admonition:: Example:

sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_analyze_layout_async.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
This sample demonstrates how to extract text, selection marks, and layout information from a document
1414
given through a file.
1515
16-
Note that selection marks returned from begin_analyze_document() do not return the text associated with
17-
the checkbox. For the API to return this information, build a custom model to analyze the checkbox and its text.
18-
See sample_build_model_async.py for more information.
16+
Note that selection marks returned from begin_analyze_document(model="prebuilt-layout") do not return the text
17+
associated with the checkbox. For the API to return this information, build a custom model to analyze the
18+
checkbox and its text. See sample_build_model.py for more information.
1919
2020
USAGE:
2121
python sample_analyze_layout_async.py

sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_build_model_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
documents found in https://aka.ms/azsdk/formrecognizer/sampletrainingfiles
1515
1616
More details on setting up a container and required file structure can be found here:
17-
https://docs.microsoft.com/azure/cognitive-services/form-recognizer/build-training-data-set
17+
https://aka.ms/azsdk/formrecognizer/buildtrainingset
1818
1919
USAGE:
2020
python sample_build_model_async.py

sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_analyze_layout.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
This sample demonstrates how to extract text, selection marks, and layout information from a document
1414
given through a file.
1515
16-
Note that selection marks returned from begin_analyze_document() do not return the text associated with
17-
the checkbox. For the API to return this information, build a custom model to analyze the checkbox and its text.
18-
See sample_build_model.py for more information.
16+
Note that selection marks returned from begin_analyze_document(model="prebuilt-layout") do not return the text
17+
associated with the checkbox. For the API to return this information, build a custom model to analyze the
18+
checkbox and its text. See sample_build_model.py for more information.
1919
2020
USAGE:
2121
python sample_analyze_layout.py

0 commit comments

Comments
 (0)