From ffeb36628a82b76d2671442ce3280a45769b7bbf Mon Sep 17 00:00:00 2001 From: catalinaperalta Date: Wed, 29 Sep 2021 19:53:51 -0400 Subject: [PATCH] [formrecognizer] Print fields in custom documents samples (#20904) * print fields in samples * review feedback --- .../async_samples/sample_analyze_custom_documents_async.py | 3 +++ .../samples/v3.2-beta/sample_analyze_custom_documents.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_analyze_custom_documents_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_analyze_custom_documents_async.py index ebebd0aceec4..5a21313ff053 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_analyze_custom_documents_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/async_samples/sample_analyze_custom_documents_async.py @@ -69,6 +69,9 @@ async def analyze_custom_documents_async(custom_model_id): print("Document has type {}".format(document.doc_type)) print("Document has document type confidence {}".format(document.confidence)) print("Document was analyzed with model with ID {}".format(result.model_id)) + for name, field in document.fields.items(): + field_value = field.value if field.value else field.content + print("......found field of type '{}' with value '{}' and with confidence {}".format(field.value_type, field_value, field.confidence)) # iterate over tables, lines, and selection marks on each page for page in result.pages: diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_analyze_custom_documents.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_analyze_custom_documents.py index 6ee58663c097..3a6dd7c403ca 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_analyze_custom_documents.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2-beta/sample_analyze_custom_documents.py @@ -63,6 +63,10 @@ def analyze_custom_documents(custom_model_id): print("Document has type {}".format(document.doc_type)) print("Document has document type confidence {}".format(document.confidence)) print("Document was analyzed with model with ID {}".format(result.model_id)) + for name, field in document.fields.items(): + field_value = field.value if field.value else field.content + print("......found field of type '{}' with value '{}' and with confidence {}".format(field.value_type, field_value, field.confidence)) + # iterate over tables, lines, and selection marks on each page for page in result.pages: