Extract Receipts in English
Extracts information from sales receipts using its prebuilt receipt model. It combines the powerful Optical Character Recognition (OCR) capabilities with receipt understanding deep learning models to extract key information from receipts in English. The Receipt API extracts key information from sales receipts in English, such as merchant name, transaction date, transaction total, line items, and more.
For this extraction we use Microsoft Azure Form Recognizer api.
To be able to use this activity, we need an Api Key and an Endpoint URl.
You can use the existing keys from a Microsoft Azure Form Recognizer resource(if any available), or you can create a new one. To create a new resource, once you have the azure subscription, create a Form Recognizer resource in the Azure portal to get your key and endpoint. After it deploys, click Go to resource. You will need the key and endpoint from the resource you create to connect your workflow to the Form Recognizer API.
You can use the free pricing tier (F0) to try the service, and upgrade later to a paid tier for production.
Below is a screenshot of Form Recognizer resource. Just copy one of the keys to Api Key and the EndPoint to Endpoint URl.
#
Designer Properties- Api Key The Microsoft Azure api key for Form recognizer. Please check above how to get this key.
- Endpoint Url The Microsoft Azure Endpoint for Form recognizer. Please check above how to get this key.
- File Path The path to the file for which we want to extract the tables, words or lines.
- All String Fields All string fields extracted from the document for each receipt form. Represents a dictionary of fields grouped by field name(Dictionary(string, string)). If there are 2 fields with the same name, the last one will be used. Most of the time, we have only one receipt in a document, and we can use this property to access its fields as string. For all the possible keys please check https://docs.microsoft.com/en-us/azure/cognitive-services/form-recognizer/concept-receipts#fields-extracted.
- All Receipt Fields All fields extracted from document for each receipt. Represents a dictionary of fields grouped by field name(Dictionary(string, Field)). If there are 2 fields with the same name, the last one will be used.
Most of the time, we have only one receipt in a document, and we can use this property to access its fields as Field. For all the possible keys please check https://docs.microsoft.com/en-us/azure/cognitive-services/form-recognizer/concept-receipts#fields-extracted.
- Output Tables Extracted tables by page number represented as a Dictionary(int, List(DataTable)), where the key is the page number while the value is a list of tables for that page.
- Merged Tables All the extracted data tables merged under one table and represented as a DataTable. This is useful when having only one table.
#
Properties#
Azure Properties- See Designer Properties above.
- Minimum Confidence Minimum confidence when accepting the parsed input content. By default, it is 0.5, but it can have any values between 0 and 1.
#
General PropertiesSee General Properties.
#
MiscSee Misc.
#
Out ErrorSee Out Error.
#
Result- All String Fields See Designer Properties above.
- All Receipt Fields See Designer Properties above.
- Document Lines Extracted lines by page and line number represented as a Dictionary(int, Dictionary(int, string)), where the key is the page number while the value is a dictionary from line number to corresponding string on that line.
- Receipt Fields by Receipt The extracted fields for each receipt in the file represented as a List(Dictionary(string, Field)) where each item in the list represents the data for a receipt and each receipt has a dictionary of predefined keys to the corresponding extracted values. For more details about Field type please check above Field Class. For all the possible keys please check https://docs.microsoft.com/en-us/azure/cognitive-services/form-recognizer/concept-receipts#example-output.
- Merged Tables See Designer Properties above.
- Output Tables See Designer Properties above.
- Output Words Extracted words by page and line number represented as a Dictionary(int, Dictionary(int, List(string))), where the key is the page number while the value is a dictionary from line number to the list of words on that line.
- String Fields by receipt The extracted fields for each receipt in the file represented as a List(Dictionary(string, string)) where each item in the list represents the data for a receipt and each receipt has dictionary of predefined keys to the corresponding extracted values. For all the possible keys please check https://docs.microsoft.com/en-us/azure/cognitive-services/form-recognizer/concept-receipts#example-output.
#
ExampleIn this example, we extract all the available receipts fields from SampleReceipt and display them in a MessageBox separated by new line.
Please set the Api Key, Endpoint URl and file path using the above SampleReceipt.jpg file or any other file.