diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_receipts_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_receipts_async.py index d61aca783d02..5459f4b2623e 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_receipts_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_receipts_async.py @@ -61,21 +61,22 @@ async def recognize_receipts(self): transaction_date = receipt.fields.get("TransactionDate") if transaction_date: print("Transaction Date: {} has confidence: {}".format(transaction_date.value, transaction_date.confidence)) - print("Receipt items:") - for idx, item in enumerate(receipt.fields.get("Items").value): - print("...Item #{}".format(idx+1)) - item_name = item.value.get("Name") - if item_name: - print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence)) - item_quantity = item.value.get("Quantity") - if item_quantity: - print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence)) - item_price = item.value.get("Price") - if item_price: - print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence)) - item_total_price = item.value.get("TotalPrice") - if item_total_price: - print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence)) + if receipt.fields.get("Items"): + print("Receipt items:") + for idx, item in enumerate(receipt.fields.get("Items").value): + print("...Item #{}".format(idx+1)) + item_name = item.value.get("Name") + if item_name: + print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence)) + item_quantity = item.value.get("Quantity") + if item_quantity: + print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence)) + item_price = item.value.get("Price") + if item_price: + print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence)) + item_total_price = item.value.get("TotalPrice") + if item_total_price: + print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence)) subtotal = receipt.fields.get("Subtotal") if subtotal: print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence)) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_receipts_from_url_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_receipts_from_url_async.py index ed5cfaa10f9d..2787800b8d13 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_receipts_from_url_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_receipts_from_url_async.py @@ -57,21 +57,22 @@ async def recognize_receipts_from_url(self): transaction_date = receipt.fields.get("TransactionDate") if transaction_date: print("Transaction Date: {} has confidence: {}".format(transaction_date.value, transaction_date.confidence)) - print("Receipt items:") - for idx, item in enumerate(receipt.fields.get("Items").value): - print("...Item #{}".format(idx+1)) - item_name = item.value.get("Name") - if item_name: - print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence)) - item_quantity = item.value.get("Quantity") - if item_quantity: - print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence)) - item_price = item.value.get("Price") - if item_price: - print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence)) - item_total_price = item.value.get("TotalPrice") - if item_total_price: - print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence)) + if receipt.fields.get("Items"): + print("Receipt items:") + for idx, item in enumerate(receipt.fields.get("Items").value): + print("...Item #{}".format(idx+1)) + item_name = item.value.get("Name") + if item_name: + print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence)) + item_quantity = item.value.get("Quantity") + if item_quantity: + print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence)) + item_price = item.value.get("Price") + if item_price: + print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence)) + item_total_price = item.value.get("TotalPrice") + if item_total_price: + print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence)) subtotal = receipt.fields.get("Subtotal") if subtotal: print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence)) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_receipts.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_receipts.py index 7918e7b7fefe..af655366a66b 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_receipts.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_receipts.py @@ -58,21 +58,22 @@ def recognize_receipts(self): transaction_date = receipt.fields.get("TransactionDate") if transaction_date: print("Transaction Date: {} has confidence: {}".format(transaction_date.value, transaction_date.confidence)) - print("Receipt items:") - for idx, item in enumerate(receipt.fields.get("Items").value): - print("...Item #{}".format(idx+1)) - item_name = item.value.get("Name") - if item_name: - print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence)) - item_quantity = item.value.get("Quantity") - if item_quantity: - print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence)) - item_price = item.value.get("Price") - if item_price: - print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence)) - item_total_price = item.value.get("TotalPrice") - if item_total_price: - print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence)) + if receipt.fields.get("Items"): + print("Receipt items:") + for idx, item in enumerate(receipt.fields.get("Items").value): + print("...Item #{}".format(idx+1)) + item_name = item.value.get("Name") + if item_name: + print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence)) + item_quantity = item.value.get("Quantity") + if item_quantity: + print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence)) + item_price = item.value.get("Price") + if item_price: + print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence)) + item_total_price = item.value.get("TotalPrice") + if item_total_price: + print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence)) subtotal = receipt.fields.get("Subtotal") if subtotal: print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence)) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_receipts_from_url.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_receipts_from_url.py index a30efc8f33e3..8e76a65add67 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_receipts_from_url.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_receipts_from_url.py @@ -56,21 +56,22 @@ def recognize_receipts_from_url(self): transaction_date = receipt.fields.get("TransactionDate") if transaction_date: print("Transaction Date: {} has confidence: {}".format(transaction_date.value, transaction_date.confidence)) - print("Receipt items:") - for idx, item in enumerate(receipt.fields.get("Items").value): - print("...Item #{}".format(idx+1)) - item_name = item.value.get("Name") - if item_name: - print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence)) - item_quantity = item.value.get("Quantity") - if item_quantity: - print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence)) - item_price = item.value.get("Price") - if item_price: - print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence)) - item_total_price = item.value.get("TotalPrice") - if item_total_price: - print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence)) + if receipt.fields.get("Items"): + print("Receipt items:") + for idx, item in enumerate(receipt.fields.get("Items").value): + print("...Item #{}".format(idx+1)) + item_name = item.value.get("Name") + if item_name: + print("......Item Name: {} has confidence: {}".format(item_name.value, item_name.confidence)) + item_quantity = item.value.get("Quantity") + if item_quantity: + print("......Item Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence)) + item_price = item.value.get("Price") + if item_price: + print("......Individual Item Price: {} has confidence: {}".format(item_price.value, item_price.confidence)) + item_total_price = item.value.get("TotalPrice") + if item_total_price: + print("......Total Item Price: {} has confidence: {}".format(item_total_price.value, item_total_price.confidence)) subtotal = receipt.fields.get("Subtotal") if subtotal: print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))