Skip to content

Commit

Permalink
[formrecognizer] Small sample fixes (Azure#20959)
Browse files Browse the repository at this point in the history
* misc sample fixes

* update docs

* rename and updates
  • Loading branch information
catalinaperalta authored Sep 30, 2021
1 parent 7217219 commit 78a4a8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
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

0 comments on commit 78a4a8a

Please sign in to comment.