Skip to content

Commit c7ff91d

Browse files
[formrecognizer] Update doc strings for v3 (Azure#20920)
* update docs based on Paul's feedback * improve bounding region docs * sample fixes * review feedback * spelling
1 parent ac10472 commit c7ff91d

File tree

6 files changed

+34
-35
lines changed

6 files changed

+34
-35
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def begin_analyze_document(self, model, document, **kwargs):
8686
:keyword str pages: Custom page numbers for multi-page documents(PDF/TIFF). Input the page numbers
8787
and/or ranges of pages you want to get in the result. For a range of pages, use a hyphen, like
8888
`pages="1-3, 5-6"`. Separate each page number or range with a comma.
89-
:keyword str locale: Locale of the document. Supported locales include: en-US, en-AU, en-CA, en-GB,
90-
and en-IN.
89+
:keyword str locale: Locale hint of the input document.
90+
See supported locales here: https://aka.ms/azsdk/formrecognizer/supportedlocales.
9191
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
9292
:return: An instance of an LROPoller. Call `result()` on the poller
9393
object to return a :class:`~azure.ai.formrecognizer.AnalyzeResult`.
@@ -137,13 +137,13 @@ def begin_analyze_document_from_url(self, model, document_url, **kwargs):
137137
Use this to specify the custom model ID or prebuilt model ID. Prebuilt model IDs to use are:
138138
"prebuilt-receipt", "prebuilt-invoice", "prebuilt-idDocument", "prebuilt-businessCard",
139139
"prebuilt-document", "prebuilt-layout".
140-
:param str document_url: The URL of the document to analyze. The input must be a valid, encoded URL
141-
of one of the supported formats: JPEG, PNG, PDF, TIFF, or BMP.
140+
:param str document_url: The URL of the document to analyze. The input must be a valid, encoded, and
141+
publicly accessible URL of one of the supported formats: JPEG, PNG, PDF, TIFF, or BMP.
142142
:keyword str pages: Custom page numbers for multi-page documents(PDF/TIFF). Input the page numbers
143143
and/or ranges of pages you want to get in the result. For a range of pages, use a hyphen, like
144144
`pages="1-3, 5-6"`. Separate each page number or range with a comma.
145-
:keyword str locale: Locale of the document. Supported locales include: en-US, en-AU, en-CA, en-GB,
146-
and en-IN.
145+
:keyword str locale: Locale hint of the input document.
146+
See supported locales here: https://aka.ms/azsdk/formrecognizer/supportedlocales.
147147
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
148148
:return: An instance of an LROPoller. Call `result()` on the poller
149149
object to return a :class:`~azure.ai.formrecognizer.AnalyzeResult`.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,8 @@ class BoundingRegion(object):
20712071
:ivar list[~azure.ai.formrecognizer.Point] bounding_box:
20722072
A list of 4 points representing the quadrilateral bounding box
20732073
that outlines the text. The points are listed in clockwise
2074-
order: top-left, top-right, bottom-right, bottom-left.
2074+
order relative to the text orientation: top-left, top-right,
2075+
bottom-right, bottom-left.
20752076
Units are in pixels for images and inches for PDF.
20762077
:ivar int page_number:
20772078
The 1-based number of the page in which this content is present.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ async def begin_analyze_document(
9292
:keyword str pages: Custom page numbers for multi-page documents(PDF/TIFF). Input the page numbers
9393
and/or ranges of pages you want to get in the result. For a range of pages, use a hyphen, like
9494
`pages="1-3, 5-6"`. Separate each page number or range with a comma.
95-
:keyword str locale: Locale of the document. Supported locales include: en-US, en-AU, en-CA, en-GB,
96-
and en-IN.
95+
:keyword str locale: Locale hint of the input document.
96+
See supported locales here: https://aka.ms/azsdk/formrecognizer/supportedlocales.
9797
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
9898
:return: An instance of an AsyncLROPoller. Call `result()` on the poller
9999
object to return a :class:`~azure.ai.formrecognizer.AnalyzeResult`.
@@ -144,13 +144,13 @@ async def begin_analyze_document_from_url(
144144
Use this to specify the custom model ID or prebuilt model ID. Prebuilt model IDs to use are:
145145
"prebuilt-receipt", "prebuilt-invoice", "prebuilt-idDocument", "prebuilt-businessCard",
146146
"prebuilt-document", "prebuilt-layout".
147-
:param str document_url: The URL of the document to analyze. The input must be a valid, encoded URL
148-
of one of the supported formats: JPEG, PNG, PDF, TIFF, or BMP.
147+
:param str document_url: The URL of the document to analyze. The input must be a valid, encoded, and
148+
publicly accessible URL of one of the supported formats: JPEG, PNG, PDF, TIFF, or BMP.
149149
:keyword str pages: Custom page numbers for multi-page documents(PDF/TIFF). Input the page numbers
150150
and/or ranges of pages you want to get in the result. For a range of pages, use a hyphen, like
151151
`pages="1-3, 5-6"`. Separate each page number or range with a comma.
152-
:keyword str locale: Locale of the document. Supported locales include: en-US, en-AU, en-CA, en-GB,
153-
and en-IN.
152+
:keyword str locale: Locale hint of the input document.
153+
See supported locales here: https://aka.ms/azsdk/formrecognizer/supportedlocales.
154154
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
155155
:return: An instance of an AsyncLROPoller. Call `result()` on the poller
156156
object to return a :class:`~azure.ai.formrecognizer.AnalyzeResult`.

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def analyze_custom_documents(custom_model_id):
6161
for idx, document in enumerate(result.documents):
6262
print("--------Analyzing document #{}--------".format(idx + 1))
6363
print("Document has type {}".format(document.doc_type))
64-
print("Document has document type confidence {}".format(document.confidence))
65-
print("Document was analyzed with model with ID {}".format(result.model_id))
64+
print("Document has confidence {}".format(document.confidence))
65+
print("Document was analyzed by model with ID {}".format(result.model_id))
6666
for name, field in document.fields.items():
6767
field_value = field.value if field.value else field.content
6868
print("......found field of type '{}' with value '{}' and with confidence {}".format(field.value_type, field_value, field.confidence))
@@ -79,22 +79,20 @@ def analyze_custom_documents(custom_model_id):
7979
word.content, word.confidence
8080
)
8181
)
82-
if page.selection_marks:
83-
print("\nSelection marks found on page {}".format(page.page_number))
84-
for selection_mark in page.selection_marks:
85-
print(
86-
"...Selection mark is '{}' and has a confidence of {}".format(
87-
selection_mark.state, selection_mark.confidence
88-
)
82+
for selection_mark in page.selection_marks:
83+
print(
84+
"...Selection mark is '{}' and has a confidence of {}".format(
85+
selection_mark.state, selection_mark.confidence
8986
)
87+
)
9088

9189
for i, table in enumerate(result.tables):
9290
print("\nTable {} can be found on page:".format(i + 1))
9391
for region in table.bounding_regions:
9492
print("...{}".format(i + 1, region.page_number))
9593
for cell in table.cells:
9694
print(
97-
"...Cell[{}][{}] has text '{}'".format(
95+
"...Cell[{}][{}] has content '{}'".format(
9896
cell.row_index, cell.column_index, cell.content
9997
)
10098
)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def analyze_document():
7070
)
7171
)
7272

73-
for idx, page in enumerate(result.pages):
74-
print("----Analyzing document from page #{}----".format(idx + 1))
73+
for page in result.pages:
74+
print("----Analyzing document from page #{}----".format(page.page_number))
7575
print(
7676
"Page has width: {} and height: {}, measured with unit: {}".format(
7777
page.width, page.height, page.unit
@@ -80,7 +80,7 @@ def analyze_document():
8080

8181
for line_idx, line in enumerate(page.lines):
8282
print(
83-
"Line # {} has text content '{}' within bounding box '{}'".format(
83+
"...Line # {} has text content '{}' within bounding box '{}'".format(
8484
line_idx,
8585
line.content,
8686
format_bounding_box(line.bounding_box),
@@ -96,7 +96,7 @@ def analyze_document():
9696

9797
for selection_mark in page.selection_marks:
9898
print(
99-
"Selection mark is '{}' within bounding box '{}' and has a confidence of {}".format(
99+
"...Selection mark is '{}' within bounding box '{}' and has a confidence of {}".format(
100100
selection_mark.state,
101101
format_bounding_box(selection_mark.bounding_box),
102102
selection_mark.confidence,
@@ -119,7 +119,7 @@ def analyze_document():
119119
)
120120
for cell in table.cells:
121121
print(
122-
"...Cell[{}][{}] has text '{}'".format(
122+
"...Cell[{}][{}] has content '{}'".format(
123123
cell.row_index,
124124
cell.column_index,
125125
cell.content,
@@ -134,14 +134,14 @@ def analyze_document():
134134
)
135135

136136
print("----Entities found in document----")
137-
for idx, entity in enumerate(result.entities):
137+
for entity in result.entities:
138138
print("Entity of category '{}' with sub-category '{}'".format(entity.category, entity.sub_category))
139139
print("...has content '{}'".format(entity.content))
140140
print("...within '{}' bounding regions".format(format_bounding_region(entity.bounding_regions)))
141141
print("...with confidence {}".format(entity.confidence))
142142

143143
print("----Key-value pairs found in document----")
144-
for idx, kv_pair in enumerate(result.key_value_pairs):
144+
for kv_pair in result.key_value_pairs:
145145
if kv_pair.key:
146146
print(
147147
"Key '{}' found within '{}' bounding regions".format(

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def analyze_layout():
6666
)
6767
)
6868

69-
for idx, page in enumerate(result.pages):
70-
print("----Analyzing layout from page #{}----".format(idx + 1))
69+
for page in result.pages:
70+
print("----Analyzing layout from page #{}----".format(page.page_number))
7171
print(
7272
"Page has width: {} and height: {}, measured with unit: {}".format(
7373
page.width, page.height, page.unit
@@ -76,7 +76,7 @@ def analyze_layout():
7676

7777
for line_idx, line in enumerate(page.lines):
7878
print(
79-
"Line # {} has text content '{}' within bounding box '{}'".format(
79+
"...Line # {} has text content '{}' within bounding box '{}'".format(
8080
line_idx,
8181
line.content,
8282
format_bounding_box(line.bounding_box),
@@ -92,7 +92,7 @@ def analyze_layout():
9292

9393
for selection_mark in page.selection_marks:
9494
print(
95-
"Selection mark is '{}' within bounding box '{}' and has a confidence of {}".format(
95+
"...Selection mark is '{}' within bounding box '{}' and has a confidence of {}".format(
9696
selection_mark.state,
9797
format_bounding_box(selection_mark.bounding_box),
9898
selection_mark.confidence,
@@ -115,7 +115,7 @@ def analyze_layout():
115115
)
116116
for cell in table.cells:
117117
print(
118-
"...Cell[{}][{}] has text '{}'".format(
118+
"...Cell[{}][{}] has content '{}'".format(
119119
cell.row_index,
120120
cell.column_index,
121121
cell.content,

0 commit comments

Comments
 (0)