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] Adding line items to invoice samples #17682

Merged
merged 1 commit into from
Mar 31, 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 @@ -97,6 +97,33 @@ async def recognize_invoice(self):
shipping_address_recipient = invoice.fields.get("ShippingAddressRecipient")
if shipping_address_recipient:
print("Shipping Address Recipient: {} has confidence: {}".format(shipping_address_recipient.value, shipping_address_recipient.confidence))
print("Invoice items:")
for idx, item in enumerate(invoice.fields.get("Items").value):
print("...Item #{}".format(idx+1))
item_description = item.value.get("Description")
if item_description:
print("......Description: {} has confidence: {}".format(item_description.value, item_description.confidence))
item_quantity = item.value.get("Quantity")
if item_quantity:
print("......Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence))
unit = item.value.get("Unit")
if unit:
print("......Unit: {} has confidence: {}".format(unit.value, unit.confidence))
unit_price = item.value.get("UnitPrice")
if unit_price:
print("......Unit Price: {} has confidence: {}".format(unit_price.value, unit_price.confidence))
product_code = item.value.get("ProductCode")
if product_code:
print("......Product Code: {} has confidence: {}".format(product_code.value, product_code.confidence))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that some of these arent actually printed with this sample because the sample doesnt include all fo this information.

item_date = item.value.get("Date")
if item_date:
print("......Date: {} has confidence: {}".format(item_date.value, item_date.confidence))
tax = item.value.get("Tax")
if tax:
print("......Tax: {} has confidence: {}".format(tax.value, tax.confidence))
amount = item.value.get("Amount")
if amount:
print("......Amount: {} has confidence: {}".format(amount.value, amount.confidence))
subtotal = invoice.fields.get("SubTotal")
if subtotal:
print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,33 @@ def recognize_invoice(self):
shipping_address_recipient = invoice.fields.get("ShippingAddressRecipient")
if shipping_address_recipient:
print("Shipping Address Recipient: {} has confidence: {}".format(shipping_address_recipient.value, shipping_address_recipient.confidence))
print("Invoice items:")
for idx, item in enumerate(invoice.fields.get("Items").value):
print("...Item #{}".format(idx+1))
item_description = item.value.get("Description")
if item_description:
print("......Description: {} has confidence: {}".format(item_description.value, item_description.confidence))
item_quantity = item.value.get("Quantity")
if item_quantity:
print("......Quantity: {} has confidence: {}".format(item_quantity.value, item_quantity.confidence))
unit = item.value.get("Unit")
if unit:
print("......Unit: {} has confidence: {}".format(unit.value, unit.confidence))
unit_price = item.value.get("UnitPrice")
if unit_price:
print("......Unit Price: {} has confidence: {}".format(unit_price.value, unit_price.confidence))
product_code = item.value.get("ProductCode")
if product_code:
print("......Product Code: {} has confidence: {}".format(product_code.value, product_code.confidence))
item_date = item.value.get("Date")
if item_date:
print("......Date: {} has confidence: {}".format(item_date.value, item_date.confidence))
tax = item.value.get("Tax")
if tax:
print("......Tax: {} has confidence: {}".format(tax.value, tax.confidence))
amount = item.value.get("Amount")
if amount:
print("......Amount: {} has confidence: {}".format(amount.value, amount.confidence))
subtotal = invoice.fields.get("SubTotal")
if subtotal:
print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))
Expand Down