Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[formrecognizer] Small sample fixes #20959

Merged
merged 3 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
# --------------------------------------------------------------------------

"""
FILE: sample_analyze_document_async.py
FILE: sample_analyze_prebuilt_document_async.py

DESCRIPTION:
This sample demonstrates how to extract general document information from a document
given through a file.

Note that selection marks returned from begin_analyze_document() do not return the text associated with
the checkbox. For the API to return this information, build a custom model to analyze the checkbox and its text.
See sample_build_model_async.py for more information.

USAGE:
python sample_analyze_document_async.py
python sample_analyze_prebuilt_document_async.py

Set the environment variables with your own values before running the sample:
1) AZURE_FORM_RECOGNIZER_ENDPOINT - the endpoint to your Cognitive Services resource.
Expand Down Expand Up @@ -131,7 +127,7 @@ async def analyze_document():
)
for region in cell.bounding_regions:
print(
"...content on page {} is within bounding box '{}'".format(
"...content on page {} is within bounding box '{}'\n".format(
region.page_number,
format_bounding_box(region.bounding_box),
)
Expand All @@ -142,7 +138,7 @@ async def analyze_document():
print("Entity of category '{}' with sub-category '{}'".format(entity.category, entity.sub_category))
print("...has content '{}'".format(entity.content))
print("...within '{}' bounding regions".format(format_bounding_region(entity.bounding_regions)))
print("...with confidence {}".format(entity.confidence))
print("...with confidence {}\n".format(entity.confidence))

print("----Key-value pairs found in document----")
for idx, kv_pair in enumerate(result.key_value_pairs):
Expand All @@ -155,7 +151,7 @@ async def analyze_document():
)
if kv_pair.value:
print(
"Value '{}' found within '{}' bounding regions".format(
"Value '{}' found within '{}' bounding regions\n".format(
kv_pair.value.content,
format_bounding_region(kv_pair.value.bounding_regions),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
# --------------------------------------------------------------------------

"""
FILE: sample_analyze_document.py
FILE: sample_analyze_prebuilt_document.py

DESCRIPTION:
This sample demonstrates how to extract general document information from a document
given through a file.

Note that selection marks returned from begin_analyze_document() do not return the text associated with
the checkbox. For the API to return this information, build a custom model to analyze the checkbox and its text.
See sample_build_model.py for more information.

USAGE:
python sample_analyze_document.py
python sample_analyze_prebuilt_document.py

Set the environment variables with your own values before running the sample:
1) AZURE_FORM_RECOGNIZER_ENDPOINT - the endpoint to your Cognitive Services resource.
Expand Down Expand Up @@ -127,7 +123,7 @@ def analyze_document():
)
for region in cell.bounding_regions:
print(
"...content on page {} is within bounding box '{}'".format(
"...content on page {} is within bounding box '{}'\n".format(
region.page_number,
format_bounding_box(region.bounding_box),
)
Expand All @@ -138,7 +134,7 @@ def analyze_document():
print("Entity of category '{}' with sub-category '{}'".format(entity.category, entity.sub_category))
print("...has content '{}'".format(entity.content))
print("...within '{}' bounding regions".format(format_bounding_region(entity.bounding_regions)))
print("...with confidence {}".format(entity.confidence))
print("...with confidence {}\n".format(entity.confidence))

print("----Key-value pairs found in document----")
for kv_pair in result.key_value_pairs:
Expand All @@ -151,7 +147,7 @@ def analyze_document():
)
if kv_pair.value:
print(
"Value '{}' found within '{}' bounding regions".format(
"Value '{}' found within '{}' bounding regions\n".format(
kv_pair.value.content,
format_bounding_region(kv_pair.value.bounding_regions),
)
Expand Down