Skip to content

Sample site for Document Intelligence code samples and associated media.

License

Notifications You must be signed in to change notification settings

Azure-Samples/document-intelligence-code-samples

 
 

Repository files navigation

Azure Document Intelligence code samples repo

Note: on July 2023, the Azure Cognitive Services Form Recognizer service was renamed to Azure AI Document Intelligence. Any mentions of Form Recognizer or Document Intelligence in documentation refer to the same Azure service.

Welcome! Azure AI Document Intelligence is a cloud service that uses machine learning to analyze text and structured data from your documents.

  • Code samples for each language's SDK are in the links below. The first step is to select to choose one (default Python).
Python .NET Java JavaScript
  • The contents of this floder default the version: v3.1 (2023-07-31-GA).
    You can select v4.0 (2024-02-29-preview) to view the latest version.

Table of Contents

Features

Azure AI Document Intelligence is a cloud-based Azure AI service that enables you to build intelligent document processing solutions. Massive amounts of data, spanning a wide variety of data types, are stored in forms and documents. Document Intelligence enables you to effectively manage the velocity at which data is collected and processed and is key to improved operations, informed data-driven decisions, and enlightened innovation.

Prerequisites

Setup

  1. Open a terminal window in your local environment and install the Azure AI Document Intelligence client library for Python with pip:
pip install azure-ai-formrecognizer==3.3.0
  1. Clone or download this sample repository
  2. Open the sample folder in Visual Studio Code or your IDE of choice.

Run the samples

  1. Open a terminal window and cd to the directory that the samples are saved in.
  2. Set the environment variables specified in the sample file you wish to run.
  3. Below are some sample code guidelines so that you can choose the sample according to your needs.
    Note: For more samples, see Azure SDK for Python and Async Samples.

Common samples

Select the link of the model name to reach the corresponding topic page for more details. Select v4.0 (2024-02-29-preview) to view the latest version.

Read model : Extract printed and handwritten text.

sample_analyze_read.py

Layout mode : Extract and anlayze text, tables, and document structure.

sample_analyze_layout.py

Prebuilt model : Add intelligent document processing to your apps and flows without having to train and build your own models.

sample_analyze_invoices.py - Analyze document text, selection marks, tables, and pre-trained fields and values pertaining to English invoices using a prebuilt model.
sample_analyze_identity_documents.py - Analyze document text and pre-trained fields and values pertaining to US driver licenses and international passports using a prebuilt model.
sample_analyze_receipts.py - Analyze document text and pre-trained fields and values pertaining to English sales receipts using a prebuilt model.
sample_analyze_tax_us_w2.py - Analyze document text and pre-trained fields and values pertaining to US tax W-2 forms using a prebuilt model.

Add-on capabilities : Extend the extracted results from documents with add-on capabilities.

sample_analyze_addon_barcodes.py - Extract barcode from a document using this add-on capability.
sample_analyze_addon_fonts.py - Extract font property from a document using this add-on capability.
sample_analyze_addon_formulas.py - Extract formula from a document using this add-on capability.
sample_analyze_addon_highres.py - Extract high resolution from a document using this add-on capability.
sample_analyze_addon_languages.py - Detact language from a document using this add-on capability.

Pre/post processing samples

There are usually some pre/post processing steps that are needed to get the best results from the Document Intelligence models. These steps are not part of the Document Intelligence service, but are common steps that are needed to get the best results. The following samples show how to do these steps.
Note:Applies to all versions.

sample_disambiguate_similar_characters.ipynb and sample_disambiguate_similar_characters.py
Sample postprocessing script to disambiguate similar characters based on business rules.

sample_identify_cross_page_tables.ipynb and sample_identify_cross_page_tables.py
Sample postprocessing script to identify cross-page tables based on business rules.

Next steps

Check out the API reference documentation to learn more about what you can do with the Azure Document Intelligence client library.

Current document analysis models

Document analysis models enable text extraction from forms and documents and return structured business-ready content ready for your organization's action, use, or development.

  • Layout — Extract text, tables, checkbox.
  • Read — Extract printed and handwritten text.

Current prebuilt models

Prebuilt models enable you to add intelligent document processing to your apps and flows without having to train and build your own models.

  • Invoice — Extract customer and vendor details.
  • Receipt — Extract sales transaction details.
  • Identity — Extract identification and verification details.
  • Health Insurance card — Extract health insurance and coverage details.
  • Contract — Extract agreement and party details.
  • US Tax W-2 — Extract taxable compensation details.
  • US Tax 1098 — Extract mortgage interest details.

Current add-on capabilities

✔️ ocr.highResolution ✔️ ocr.formula ✔️ ocr.font ✔️ ocr.barcode ✔️ languages

About

Sample site for Document Intelligence code samples and associated media.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published