Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 3.8 KB

README.md

File metadata and controls

54 lines (37 loc) · 3.8 KB

Automated Document Processing extraction sample application

This sample application demonstrates the API calls needed to use IBM Automated Document Processing to extract document information. The sample application does the following:

  • Authenticates the user to the Document Processing Engine (DPE).
  • Retrieves the list of document classes in the DPE.
  • Displays the properties associated with each document class.
  • Allows the user to select a document class and upload a file to the DPE.
  • Polls the DPE every five seconds to get the extraction status of an uploaded document.
  • Shows status information as the document undergoes extraction.
  • Displays the document JSON of an extracted document when processing is complete.

Installation

A prerequisite to install the sample application is having node and npm on your system. You can download and install them from here: https://nodejs.org/en/download/

To install the sample application, do the following:

  • Clone this repository or copy the code to your local machine.
  • Open a command window, change to the directory where you added the sample code, and run npm install.

Configuration

Configuration of the sample application is done using settings in the .env file found at the root level. The initial settings in the file are only examples -- you must modify this file with your settings to run the application. The application can be run against DPE servers with and without authentication configured.

The settings in the .env file are:

  • DPE_SERVICE_URL: The URL of the DPE server.
  • DPE_PROJECT_ID: The GUID ID of the project you want to run against in the DPE.
  • AUTHENTICATION_ENABLED: Valid values are 0 and 1. Set to 1 to trigger logic to authenticated the user to the DPE server. Set to 0 when running against an unsecured DPE server when authentication is not required.
  • DPE_IAM_SERVICE_URL: Requrired when AUTHENTICATION_ENABLED is set to 1. The URL of the IAM service associated with the DPE server.
  • DPE_ZEN_SERVICE_URL: Requrired when AUTHENTICATION_ENABLED is set to 1. The URL of the ZEN service associated with the DBP server.
  • NODE_TLS_REJECT_UNAUTHORIZED: Valid values are 0 or 1. 0 means to ignore self-signed certificate errors encountered when making calls to the various API endpoints. This setting should only be used when running in a development environment.

Architecture

The application consists of two files: -- App.js: Written in React, this file contains all code shown in the UI. It makes API calls to the DPE server using a proxy in the setupProxy.js file. -- setupProxy.js: Contains all code that runs on the server including a proxy to forward all requests with prefix "/api/" to the DPE server. It also handles requests for authentication and retrieving the settings in the .env file.

Running the application

Enter npm start into your command window. A new browser tab should open with the running application.

If authentication is configured, the logon window is displayed and you are prompted to enter a user name and passwored. Once authenticated, the dropdown list of document classes is populated in the application. You may display the properties of a document class by selecting one from the dropdown, then clicking the Document Class Properties button.

To upload a file for extraction, do the following:

  • Select an appropriate document class from the dropdown.
  • Click on the file upload control to the right of the Document Class Properties button and select a file. Optionally, you may drag and drop a file onto the control.
  • Click the Upload button.

The file is uploaded and extraction status is displayed in the lower part of the application window.

When extraction is complete, the document JSON is displayed.

To upload another document, click the file upload control and select a new document and repeat the steps listed above.