-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[form recognizer] Remove US receipt #11764
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
Changes from 9 commits
ecc13f3
7bb73e4
b3d68f6
8014fe3
704ee27
7e2a3f8
655efee
9267884
93fd081
e2eb829
eada107
985a894
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,21 +227,16 @@ with open("<path to your receipt>", "rb") as fd: | |
| poller = form_recognizer_client.begin_recognize_receipts(receipt) | ||
| result = poller.result() | ||
|
|
||
| r = result[0] | ||
| print("Receipt contained the following values with confidences: ") | ||
| print("Receipt Type: {} has confidence: {}".format(r.receipt_type.type, r.receipt_type.confidence)) | ||
| print("Merchant Name: {} has confidence: {}".format(r.merchant_name.value, r.merchant_name.confidence)) | ||
| print("Transaction Date: {} has confidence: {}".format(r.transaction_date.value, r.transaction_date.confidence)) | ||
| print("Receipt items:") | ||
| for item in r.receipt_items: | ||
| print("...Item Name: {} has confidence: {}".format(item.name.value, item.name.confidence)) | ||
| print("...Item Quantity: {} has confidence: {}".format(item.quantity.value, item.quantity.confidence)) | ||
| print("...Individual Item Price: {} has confidence: {}".format(item.price.value, item.price.confidence)) | ||
| print("...Total Item Price: {} has confidence: {}".format(item.total_price.value, item.total_price.confidence)) | ||
| print("Subtotal: {} has confidence: {}".format(r.subtotal.value, r.subtotal.confidence)) | ||
| print("Tax: {} has confidence: {}".format(r.tax.value, r.tax.confidence)) | ||
| print("Tip: {} has confidence: {}".format(r.tip.value, r.tip.confidence)) | ||
| print("Total: {} has confidence: {}".format(r.total.value, r.total.confidence)) | ||
| for receipt in result: | ||
| for name, field in receipt.fields.items(): | ||
| if name == "Items": | ||
| print("Receipt Items:") | ||
| for idx, items in enumerate(field.value): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's at all complicated to retrieve these values, it's probably worth illustrating for customers how to get them out of the receipt fields property.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are still accessing the field properties (including items) one by one in the samples. For the readme, based on @kristapratico , I wanted to show a simpler way of traversing everything |
||
| print("...Item #{}".format(idx)) | ||
| for item_name, item in items.value.items(): | ||
| print("......{}: {} has confidence {}".format(item_name, item.value, item.confidence)) | ||
| else: | ||
| print("{}: {} has confidence {}".format(name, field.value, field.confidence)) | ||
| ``` | ||
|
|
||
| ### Train a model | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,19 +45,42 @@ async def recognize_receipts(self): | |
|
|
||
| for idx, receipt in enumerate(receipts): | ||
| print("--------Recognizing receipt #{}--------".format(idx)) | ||
| print("Receipt Type: {} has confidence: {}".format(receipt.receipt_type.type, receipt.receipt_type.confidence)) | ||
| print("Merchant Name: {} has confidence: {}".format(receipt.merchant_name.value, receipt.merchant_name.confidence)) | ||
| print("Transaction Date: {} has confidence: {}".format(receipt.transaction_date.value, receipt.transaction_date.confidence)) | ||
| receipt_type = receipt.fields.get("ReceiptType") | ||
| if receipt_type: | ||
| print("Receipt Type: {} has confidence: {}".format(receipt_type.value, receipt_type.confidence)) | ||
| merchant_name = receipt.fields.get("MerchantName") | ||
| if merchant_name: | ||
| print("Merchant Name: {} has confidence: {}".format(merchant_name.value, merchant_name.confidence)) | ||
| 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 item in receipt.receipt_items: | ||
| print("...Item Name: {} has confidence: {}".format(item.name.value, item.name.confidence)) | ||
| print("...Item Quantity: {} has confidence: {}".format(item.quantity.value, item.quantity.confidence)) | ||
| print("...Individual Item Price: {} has confidence: {}".format(item.price.value, item.price.confidence)) | ||
| print("...Total Item Price: {} has confidence: {}".format(item.total_price.value, item.total_price.confidence)) | ||
| print("Subtotal: {} has confidence: {}".format(receipt.subtotal.value, receipt.subtotal.confidence)) | ||
| print("Tax: {} has confidence: {}".format(receipt.tax.value, receipt.tax.confidence)) | ||
| print("Tip: {} has confidence: {}".format(receipt.tip.value, receipt.tip.confidence)) | ||
| print("Total: {} has confidence: {}".format(receipt.total.value, receipt.total.confidence)) | ||
| for idx, item in enumerate(receipt.fields.get("Items").value): | ||
| print("...Item #{}".format(idx)) | ||
| 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)) | ||
| tax = receipt.fields.get("Tax") | ||
| if tax: | ||
| print("Tax: {} has confidence: {}".format(tax.value, tax.confidence)) | ||
| tip = receipt.fields.get("Tip") | ||
| if tip: | ||
| print("Tip: {} has confidence: {}".format(tip.value, tip.confidence)) | ||
| total = receipt.fields.get("Total") | ||
| if total: | ||
| print("Total: {} has confidence: {}".format(total.value, total.confidence)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand wanting to show the keys available, but wondering if we should do at least one sample or readme like this:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you mean. I think I will leave the samples like this, but update the readme sample to traverse the fields like this
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really like how the readme looks.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the .NET sample, we're only showing a subset of illustrative values from the receipt. Also, I'm not sure how it works in Python, but do you need to check the FieldValueType to cast these to the right time in order for a customer to use them in a scenario? |
||
| print("--------------------------------------") | ||
| # [END recognize_receipts_async] | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.