### Install Azure Document Intelligence Package Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/JavaScript(v4.0)/README.md Installs the Azure Document Intelligence REST client library for JavaScript using npm. This is the first step to start using the SDK. ```bash npm install @azure-rest/ai-document-intelligence ``` -------------------------------- ### Install Azure Document Intelligence Python SDK Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Layout_model/README.md Installs the Azure Document Intelligence client library for Python using pip. This is a prerequisite for running the provided Python code samples. ```bash pip install azure-ai-documentintelligence ``` -------------------------------- ### Install Azure Document Intelligence Library (Python) Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Read_model/README.md Installs the necessary Azure Document Intelligence client library for Python using pip. This is a prerequisite for running the provided samples. ```bash pip install azure-ai-documentintelligence ``` -------------------------------- ### Install Document Intelligence Python SDK Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/README.md Installs the Azure AI Document Intelligence client library for Python using pip. This command is essential for setting up the Python environment to run the provided samples. ```bash pip install azure-ai-documentintelligence ``` -------------------------------- ### Install Dependencies Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Retrieval_Augmented_Generation_(RAG)_samples/sample_figure_understanding.ipynb Installs necessary Python libraries including dotenv, openai, azure-ai-documentintelligence, azure-identity, pillow, and PyMuPDF for the demonstration. ```shell ! pip install python-dotenv openai azure-ai-documentintelligence azure-identity pillow PyMuPDF ``` -------------------------------- ### Install Azure Document Intelligence Python Library Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Custom_model/README.md Installs the latest version of the Azure Document Intelligence client library for Python using pip. This is a prerequisite for running the provided Python samples. ```bash pip install azure-ai-documentintelligence ``` -------------------------------- ### Install Azure AI Document Intelligence SDK for Python Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/README.md Installs the Azure AI Document Intelligence client library for Python using pip. This command is essential for setting up your development environment to use the SDK. ```bash pip install azure-ai-documentintelligence ``` -------------------------------- ### Install Azure Document Intelligence Python Library Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Add-on_capabilities/README.md Installs the Azure Document Intelligence client library for Python using pip. This command ensures you have the necessary package to interact with the Document Intelligence service. ```bash pip install azure-ai-documentintelligence --pre ``` -------------------------------- ### Install Azure Document Intelligence Libraries Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Pre_or_post_processing_samples/sample_identify_cross_page_tables.ipynb Installs necessary Python packages for interacting with Azure Document Intelligence, including the SDK, dotenv for environment variables, and azure-identity for authentication. This command is typically run in a notebook or terminal environment. ```Python ! pip install azure-ai-documentintelligence python-dotenv azure-identity ``` -------------------------------- ### Install Azure Document Intelligence Client Library for Python Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Prebuilt_model/README.md Installs the latest version of the Azure Document Intelligence client library for Python using pip. This package is required to interact with the Document Intelligence service from your Python applications. ```Bash pip install azure-ai-documentintelligence ``` -------------------------------- ### Install Azure Document Intelligence Libraries Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Retrieval_Augmented_Generation_(RAG)_samples/sample_identify_and_merge_cross_page_tables.ipynb Installs necessary Python packages for Azure Document Intelligence, including the SDK, dotenv for environment variable management, and azure-identity for authentication. This command is typically run in a notebook or terminal environment. ```python ! pip install azure-ai-documentintelligence python-dotenv azure-identity ``` -------------------------------- ### Install Required Python Packages Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Retrieval_Augmented_Generation_(RAG)_samples/sample_rag_langchain.ipynb Installs essential Python libraries for LangChain, Azure AI Document Intelligence, Azure AI Search, and Azure OpenAI integration. Ensures all dependencies are met for the RAG pipeline. ```python ! pip install python-dotenv langchain langchain-community langchain-openai langchainhub openai tiktoken azure-ai-documentintelligence azure-identity azure-search-documents==11.6.0b3 ``` -------------------------------- ### Manage Models Sample Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/README.md Manage custom models on your account, including listing, getting, deleting -------------------------------- ### Manage Classifiers Sample Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/README.md Manage classifiers on your account, including creating, listing, getting, and deleting document classifiers. This sample demonstrates basic classifier lifecycle operations. ```python from azure.ai.formrecognizer import DocumentModelAdministrationClient from azure.core.credentials import AzureKeyCredential # Replace with your endpoint and key endpoint = "YOUR_ENDPOINT" key = "YOUR_KEY" # Authenticate the client document_model_admin_client = DocumentModelAdministrationClient(endpoint=endpoint, credential=AzureKeyCredential(key)) # --- Example Operations --- # 1. List all classifiers print("Listing all classifiers:") classifiers = list(document_model_admin_client.list_classifiers()) for classifier in classifiers: print(f"- ID: {classifier.classifier_id}, Description: {classifier.description}") # 2. Get a specific classifier (replace with an existing classifier ID) # try: # specific_classifier_id = "YOUR_EXISTING_CLASSIFIER_ID" # classifier_info = document_model_admin_client.get_classifier(specific_classifier_id) # print(f"\nDetails for classifier '{specific_classifier_id}': {classifier_info}") # except Exception as e: # print(f"\nCould not get classifier '{specific_classifier_id}': {e}") # 3. Create a new classifier (requires training data setup) # print("\nCreating a new classifier (requires training data setup)...") # try: # new_classifier = document_model_admin_client.begin_create_classifier( # classifier_id="my_new_classifier", # doc_types={ # "invoice": { # "source": "YOUR_TRAINING_DATA_BLOB_URL_FOR_INVOICES", # "build_mode": "template" # }, # "receipt": { # "source": "YOUR_TRAINING_DATA_BLOB_URL_FOR_RECEIPTS", # "build_mode": "template" # } # } # ).result() # print(f"Classifier created: {new_classifier.classifier_id}") # except Exception as e: # print(f"Error creating classifier: {e}") # 4. Delete a classifier (replace with an existing classifier ID) # try: # classifier_id_to_delete = "YOUR_CLASSIFIER_ID_TO_DELETE" # document_model_admin_client.delete_classifier(classifier_id_to_delete) # print(f"\nClassifier '{classifier_id_to_delete}' deleted successfully.") # except Exception as e: # print(f"\nCould not delete classifier '{classifier_id_to_delete}': {e}") ``` -------------------------------- ### Manage Custom Models (Sync) Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Java(v4.0)/README.md Provides Java code for managing custom models synchronously, including operations like training, listing, and getting custom models. Requires Azure Document Intelligence SDK. ```Java /** * Manage Custom Models Sample (Synchronous) * This sample demonstrates synchronous operations for managing custom models in Azure AI Document Intelligence. * For more information, see: * https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageCustomModels.java */ // Placeholder for actual code content. // The actual code would involve using DocumentModelAdministrationClient to perform CRUD operations on custom models. ``` -------------------------------- ### Enable Azure SDK Logging Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/JavaScript(v4.0)/README.md This example explains how to enable detailed logging for Azure SDKs to help diagnose issues. Logging can be activated by setting the `AZURE_LOG_LEVEL` environment variable or by calling `setLogLevel` from the `@azure/logger` package. ```javascript const { setLogLevel } = require("@azure/logger"); setLogLevel("info"); ``` -------------------------------- ### Run Python Sample Application Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Prebuilt_model/README.md Executes a Python sample script named 'sample_analyze_receipts.py' from the command line. This command assumes the script has been created and saved in the current directory. ```Bash python sample_analyze_receipts.py ``` -------------------------------- ### Setup Azure Document Intelligence Client Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Retrieval_Augmented_Generation_(RAG)_samples/sample_identify_and_merge_cross_page_tables.ipynb Loads environment variables from a .env file using dotenv and initializes the Azure Document Intelligence client with endpoint and key credentials. It imports necessary libraries for Azure services and defines constants for document processing. ```python """ This code loads environment variables using the `dotenv` library and sets the necessary environment variables for Azure services. The environment variables are loaded from the `.env` file in the same directory as this notebook. """ import os, sys from dotenv import load_dotenv from azure.core.credentials import AzureKeyCredential from azure.ai.documentintelligence import DocumentIntelligenceClient from azure.ai.documentintelligence.models import ContentFormat load_dotenv() BORDER_SYMBOL = "|" endpoint = os.getenv("AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT") key = os.getenv("AZURE_DOCUMENT_INTELLIGENCE_KEY") ``` -------------------------------- ### Initialize Azure and OpenAI Clients Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Retrieval_Augmented_Generation_(RAG)_samples/sample_figure_understanding.ipynb Loads environment variables for Azure Document Intelligence and Azure OpenAI endpoints and keys using dotenv. It then initializes the DocumentIntelligenceClient and sets up variables for Azure OpenAI, including the deployment name and API version for the GPT-4V model. ```python """ This code loads environment variables using the `dotenv` library and sets the necessary environment variables for Azure services. The environment variables are loaded from the `.env` file in the same directory as this notebook. """ import os from dotenv import load_dotenv from azure.core.credentials import AzureKeyCredential from azure.ai.documentintelligence import DocumentIntelligenceClient from azure.ai.documentintelligence.models import ContentFormat from openai import AzureOpenAI load_dotenv() doc_intelligence_endpoint = os.getenv("AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT") doc_intelligence_key = os.getenv("AZURE_DOCUMENT_INTELLIGENCE_KEY") aoai_api_base = os.getenv("AZURE_OPENAI_ENDPOINT") aoai_api_key= os.getenv("AZURE_OPENAI_API_KEY") aoai_deployment_name = 'gpt-4v' # your model deployment name for GPT-4V aoai_api_version = '2024-02-15-preview' # this might change in the future ``` -------------------------------- ### Run Document Intelligence Python Sample Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Read_model/README.md Executes a Python sample script for Azure Document Intelligence. Ensure environment variables are set and the script is in the current directory. ```bash python sample_analyze_read.py ``` -------------------------------- ### Document Intelligence 1099-A Model Schema Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/schema/2024-11-30-ga/us-tax/1099/1099-a.md Details the fields extracted by the prebuilt-tax.us.1099A Document Intelligence model, including their types, descriptions, and examples. ```APIDOC APIDOC: prebuilt-tax.us.1099A Model Schema Model: prebuilt-tax.us.1099A Description: Extracts information from US tax form 1099-A. Fields: TaxYear (string): Tax Year extracted from Form 1099-A. Example: 2022 Lender (object): TIN (string): Lender tax identification number. Example: 123-45-6789 Name (string): Lender full name as written on the form. Example: John Smith Address (address): Lender address. Example: 123 Microsoft Way, Redmond WA 98052 PhoneNumber (phoneNumber): Lender Phone Number. Example: +19876543210 Borrower (object): TIN (string): Borrower tax identification number. Example: 123-45-6789 Name (string): Borrower full name as written on the form. Example: John Smith Address (address): Borrower address. Example: 123 Microsoft Way, Redmond WA 98052 AccountNumber (string): Borrower account number. Example: 55123456789 Box1 (date): Box 1 extracted from Form 1099-A. Example: 2022-12-31 Box2 (number): Box 2 extracted from Form 1099-A. Example: 123456 Box4 (number): Box 4 extracted from Form 1099-A. Example: 123456 Box5 (boolean): Box 5 extracted from Form 1099-A. Example: :selected: Box6 (string): Box 6 extracted from Form 1099-A. Example: 1 Private Drive, Redmond WA 98052 IsCorrected (boolean): Indicates whether form is a corrective filing. Example: :selected: TaxState (string): Taxable State extracted from Form 1099-A. Example: CA ``` -------------------------------- ### Get Document Intelligence Service Info Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/JavaScript(v4.0)/README.md This code sample demonstrates how to retrieve general information about the Document Intelligence service, such as the limit for custom document models. ```ts const response = await client.path("/info").get(); if (isUnexpected(response)) { throw response.body.error; } console.log(response.body.customDocumentModels.limit); ``` -------------------------------- ### Create Document Intelligence Client (Java) Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Java(v4.0)/README.md Demonstrates how to create an instance of the DocumentIntelligenceClient using an Azure Key Credential. This client is used to interact with the Azure Document Intelligence service. ```Java DocumentIntelligenceClient documentIntelligenceClient = new DocumentIntelligenceClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("{endpoint}") .buildClient(); ``` -------------------------------- ### US Tax 1095-A Document Fields Schema Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/schema/2024-11-30-ga/us-tax/1095/1095-a.md Defines the schema for data extracted by the prebuilt-tax.us.1095A model. It lists all supported fields, their data types, descriptions, and provides examples where applicable. ```APIDOC Model ID: prebuilt-tax.us.1095A Document Fields: - TaxYear (string): Tax Year extracted from Form 1095-A. Example: 2024 - IsVoid (boolean): Indicates if the form is void. - IsCorrected (boolean): Indicates if the form is corrected. - MarketplaceIdentifier (string): Marketplace identifier number extracted from Form 1095-A. Example: 123456789 - MarketplaceAssignedPolicyNumber (string): Marketplace assigned policy number extracted from Form 1095-A. Example: ABC123456789 - PolicyIssuerName (string): The issuer's name for the health insurance policy. Example: Health Insurance Co. - PolicyStartDate (date): Policy start date extracted from Form 1095-A. Example: 2024-01-01 - PolicyTerminationDate (date): Policy termination date extracted from Form 1095-A. Example: 2024-12-31 - Recipient (object): - Name (string): Recipient's full name as written on the form. Example: Jane Doe - SSN (string): Recipient's Social Security Number. Example: 123-45-6789 - DateOfBirth (date): Recipient's date of birth. Example: 1970-01-01 - Address (address): Recipient's address as written on the form. Example: 123 Microsoft Way, Redmond WA 98052 - Spouse (object): - Name (string): Spouse's full name as written on the form. Example: John Doe - SSN (string): Spouse's Social Security Number. Example: 987-65-4321 - DateOfBirth (date): Spouse's date of birth. Example: 1975-02-01 - CoveredIndividuals (array): - * (object): - Name (string): Full name of the covered individual as written on the form. Example: John Doe Jr. - SSN (string): Social Security Number of the covered individual. Example: 567-89-0123 - DateOfBirth (date): Date of birth of the covered individual. Example: 2005-03-15 - CoverageStartDate (date): Coverage start date of the covered individual. Example: 2023-01-01 - CoverageTerminationDate (date): Coverage termination date of the covered individual. Example: 2023-12-31 - Coverages (array): - * (object): - Month (string): Month for which the coverage details apply. Example: January - MonthlyEnrollmentPremiums (number): Monthly enrollment premiums amount for the month. Example: 500.00 - MonthlySecondLowestCostSilverPlanPremium (number): Monthly Second Lowest Cost Silver Plan (SLCSP) premium. Example: 450.00 - MonthlyAdvancePaymentOfPremiumTaxCredit (number): Advance payment of premium tax credit amount for the month. Example: 200.00 ``` -------------------------------- ### Line Item Schema Fields Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/schema/2024-11-30-ga/invoice.md Defines the structure and types for line item data extracted by Document Intelligence. Includes fields like unit and unit price, along with their descriptions and example values. ```APIDOC LineItem: Fields: - name: Items.*.Unit type: string description: The unit of the line item, e.g, kg, lb etc. example: "hours" - name: Items.*.UnitPrice type: currency description: The net or gross price (depending on the gross invoice setting of the invoice) of one unit of this item example: "$30.00" ``` -------------------------------- ### Create Document Intelligence Administration Client (Java) Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Java(v4.0)/README.md Shows how to instantiate a DocumentIntelligenceAdministrationClient, which is used for managing models and custom document models within the Azure Document Intelligence service. ```Java DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("{endpoint}") .buildClient(); ``` -------------------------------- ### Create DocumentIntelligenceClient with API Key Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/JavaScript(v4.0)/README.md Shows how to instantiate the DocumentIntelligenceClient using an API key. This authentication method requires setting the DOCUMENT_INTELLIGENCE_ENDPOINT and DOCUMENT_INTELLIGENCE_API_KEY environment variables. ```typescript import DocumentIntelligence from "@azure-rest/ai-document-intelligence"; const client = DocumentIntelligence(process.env["DOCUMENT_INTELLIGENCE_ENDPOINT"], { key: process.env["DOCUMENT_INTELLIGENCE_API_KEY"], }); ``` -------------------------------- ### Line Item Schema Fields Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/schema/2024-07-31-preview/invoice.md Defines the structure and types for line item data extracted by Document Intelligence. Includes fields like unit and unit price, along with their descriptions and example values. ```APIDOC LineItem: Fields: - name: Items.*.Unit type: string description: The unit of the line item, e.g, kg, lb etc. example: "hours" - name: Items.*.UnitPrice type: currency description: The net or gross price (depending on the gross invoice setting of the invoice) of one unit of this item example: "$30.00" ``` -------------------------------- ### Analyze Document Layout from URL Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/JavaScript(v4.0)/README.md Analyzes a document using the prebuilt-layout model by providing a URL to the document. This sample shows how to make the POST request and specify query parameters like locale. ```typescript const initialResponse = await client .path("/documentModels/{modelId}:analyze", "prebuilt-layout") .post({ contentType: "application/json", body: { urlSource: "https://raw.githubusercontent.com/Azure/azure-sdk-for-js/6704eff082aaaf2d97c1371a28461f512f8d748a/sdk/formrecognizer/ai-form-recognizer/assets/forms/Invoice_1.pdf", }, queryParameters: { locale: "en-IN" }, }); ``` -------------------------------- ### Azure Document Intelligence Document Schemas Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/schema/2024-11-30-ga/id-document.md Defines the structure and fields for various identity documents recognized by Azure Document Intelligence. Each schema specifies the data fields, their types, and example values for extracted information. ```APIDOC idDocument.residencePermit: Fields: CountryRegion: { type: countryRegion, description: Country or region code, example: USA } DocumentNumber: { type: string, description: Residence permit number, example: WDLABCD456DG } FirstName: { type: string, description: Given name and middle initial if applicable, example: LIAM R. } LastName: { type: string, description: Surname, example: TALBOT } DateOfBirth: { type: date, description: Date of birth, example: 01/06/1958 } DateOfExpiration: { type: date, description: Date of expiration, example: 08/12/2020 } DateOfIssue: { type: date, description: Date of issue, example: 08/12/2012 } Sex: { type: string, description: Sex, example: M } PersonalNumber: { type: string, description: Personal Id. No., example: A234567893 } PlaceOfBirth: { type: string, description: Place of birth, example: Germany } Category: { type: string, description: Permit category, example: DV2 } Address: { type: string, description: Address, example: 123 STREET ADDRESS YOUR CITY WA 99999-1234 } ``` ```APIDOC idDocument.usSocialSecurityCard: Fields: DocumentNumber: { type: string, description: Social security card number, example: WDLABCD456DG } FirstName: { type: string, description: Given name and middle initial if applicable, example: LIAM R. } LastName: { type: string, description: Surname, example: TALBOT } DateOfIssue: { type: date, description: Date of issue, example: 08/12/2012 } ``` ```APIDOC idDocument: Fields: Address: { type: address, description: Address, example: 123 STREET ADDRESS YOUR CITY WA 99999-1234 } DocumentNumber: { type: string, description: Identity document number, example: WDLABCD456DG } FirstName: { type: string, description: Given name and middle initial if applicable, example: LIAM R. } LastName: { type: string, description: Surname, example: TALBOT } DateOfBirth: { type: date, description: Date of birth, example: 01/06/1958 } DateOfExpiration: { type: date, description: Date of expiration, example: 08/12/2020 } ``` -------------------------------- ### Document Intelligence Health Insurance Card Schema Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/schema/2024-07-31-preview/health-insurance-card.md Defines the structure and fields recognized by the prebuilt health insurance card model. It includes details on data types, descriptions, and examples for each extracted field. ```APIDOC Model ID: prebuilt-healthInsuranceCard.us Supported Languages: English (en-US) Document Fields: - Insurer (string): Health insurance provider name. Example: PREMERA BLUE CROSS - Member (object): - Name (string): Member name. Example: ANGEL BROWN - BirthDate (date): Member date of birth. Example: 01/06/1958 - Employer (string): Member name employer. Example: Microsoft - Gender (string): Member gender. Example: M - IdNumberSuffix (string): Identification Number Suffix as it appears on some health insurance cards. Example: 01 - Dependents (array): Array holding list of dependents, ordered where possible by membership suffix value. - Dependents.* (object): - Name (string): Dependent name. Example: 01 - IdNumber (object): - Prefix (string): Identification Number Prefix as it appears on some health insurance cards. Example: ABC - Number (string): Identification Number. Example: 123456789 - GroupNumber (string): Insurance Group Number. Example: 1000000 - PrescriptionInfo (object): - Issuer (string): ANSI issuer identification number (IIN). Example: (80840) 300-11908-77 - RxBIN (string): Prescription issued BIN number. Example: 987654 - RxPCN (string): Prescription processor control number. Example: 63200305 - RxGrp (string): Prescription group number. Example: BCAAXYZ - RxId (string): Prescription identification number. If not present, will default to membership id number. Example: P97020065 - RxPlan (string): Prescription Plan number. Example: A1 - Pbm (string): Pharmacy Benefit Manager for the plan. Example: CVS CAREMARK - EffectiveDate (date): Date from which the plan is effective. Example: 08/12/2012 - Copays (array): Array holding list of CoPay Benefits. - Copays.* (object): - Benefit (string): Co-Pay Benefit name. Example: Deductible - Amount (currency): Co-Pay required amount. Example: $1,500 - Payer (object): - Id (string): Payer Id Number. Example: 89063 - Address (address): Payer address. Example: 123 Service St, Redmond WA, 98052 - PhoneNumber (phoneNumber): Payer phone number. Example: +1 (987) 213-5674 - Plan (object): - Number (string): Plan number. Example: 456 - Name (string): Plan name - If see Medicaid -> then medicaid. Example: HEALTH SAVINGS PLAN - Type (string): Plan type. Example: PPO - MedicareMedicaidInfo (object): - Id (string): Medicare or Medicaid number. Example: 1AB2-CD3-EF45 - PartAEffectiveDate (date): Effective date of Medicare Part A. Example: 01-01-2023 - PartBEffectiveDate (date): Effective date of Medicare Part B. Example: 01-01-2023 ``` -------------------------------- ### Document Intelligence Client Builder Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Java(v4.0)/README.md Demonstrates how to build a Document Intelligence client using the DocumentIntelligenceClientBuilder. This is a foundational step for interacting with the Document Intelligence service. ```Java /** * Document Intelligence Client Builder Sample * This sample shows how to build a Document Intelligence client using the DocumentIntelligenceClientBuilder. * For more information, see: * https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentIntelligenceClientBuilder.java */ // Placeholder for actual code content as it cannot be fetched. // The actual code would involve instantiating DocumentIntelligenceClientBuilder and configuring it with endpoint and credentials. ``` -------------------------------- ### Load Environment Variables and Initialize Document Intelligence Client Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Pre_or_post_processing_samples/sample_identify_cross_page_tables.ipynb Loads Azure service credentials and endpoint from a `.env` file using the `dotenv` library and initializes the `DocumentIntelligenceClient`. This client is essential for making API calls to Azure Document Intelligence. It requires `AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT` and `AZURE_DOCUMENT_INTELLIGENCE_KEY` environment variables to be set. ```Python """ This code loads environment variables using the `dotenv` library and sets the necessary environment variables for Azure services. The environment variables are loaded from the `.env` file in the same directory as this notebook. """ import os from dotenv import load_dotenv from azure.core.credentials import AzureKeyCredential from azure.ai.documentintelligence import DocumentIntelligenceClient load_dotenv() endpoint = os.getenv("AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT") key = os.getenv("AZURE_DOCUMENT_INTELLIGENCE_KEY") ``` -------------------------------- ### Get Table Span Offsets Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Retrieval_Augmented_Generation_(RAG)_samples/sample_identify_and_merge_cross_page_tables.ipynb Calculates the minimum and maximum character offsets of a table's spans within the document content. It returns (-1, -1) if the table has no associated spans. ```python def get_table_span_offsets(table): """ Calculates the minimum and maximum offsets of a table's spans. Args: table (Table): The table object containing spans. Returns: tuple: A tuple containing the minimum and maximum offsets of the table's spans. If the tuple is (-1, -1), it means the table's spans is empty. """ if table.spans: min_offset = table.spans[0].offset max_offset = table.spans[0].offset + table.spans[0].length for span in table.spans: if span.offset < min_offset: min_offset = span.offset if span.offset + span.length > max_offset: max_offset = span.offset + span.length return min_offset, max_offset else: return -1, -1 ``` -------------------------------- ### Seller Object Schema Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/schema/2024-11-30-ga/us-mortgage/1008.md Defines the structure and properties of a Seller object. This schema includes fields for the seller's name, address, unique identifiers, and contact details, along with their respective data types and example values. ```APIDOC Seller: __type__: object __description__: Represents a seller entity. Properties: - Name: string Description: Seller name. Example: Renner, Hamill and Harber - Address: object Description: Seller address. Example: 9180 Landen Curve Apt. 137\nGulfport, MO 39503, United States Properties: - Street: string Description: Street address. - City: string Description: City. - State: string Description: State or province. - PostalCode: string Description: Postal or ZIP code. - Country: string Description: Country. - Number: string Description: Seller number, a unique identifier. Example: 1487FHIUJH579836827 - LoanNumber: string Description: Seller loan number. Example: 84521F5135432x468rd15375fs - ContactName: string Description: Contact person's name for the seller. Example: Franciso Connelly - ContactPhoneNumber: string Description: Contact person's phone number. Example: 407-930-3985 - InvestorLoanNumber: string Description: Investor loan number associated with the seller. Example: 987654 ``` -------------------------------- ### Run Document Intelligence Sample (Copy Model) Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Custom_model/README.md Executes a Python script to copy a custom model from a source Azure Document Intelligence resource to a target resource. This facilitates model migration or backup. ```bash python sample_copy_model_to.py ``` -------------------------------- ### Get Table Page Numbers Source: https://github.com/azure-samples/document-intelligence-code-samples/blob/main/Python(v4.0)/Retrieval_Augmented_Generation_(RAG)_samples/sample_identify_and_merge_cross_page_tables.ipynb Extracts and returns a list of page numbers where a given table object appears in the document. This is useful for understanding the spatial distribution of tables across document pages. ```python def get_table_page_numbers(table): """ Returns a list of page numbers where the table appears. Args: table: The table object. Returns: A list of page numbers where the table appears. """ return [region.page_number for region in table.bounding_regions] ```