Skip to main content

OCR - AWS Textract

ACCESS THE CUSTOM STEP FOLDER

Description​

This custom step uses the AWS Textract service to perform different types of OCR on files that can be stored in S3 buckets or on the SAS Compute file system.

Features​

  • Text Extraction (Words / Lines / Paragraphs / Pages)
  • Form Extraction (Key-Value)
  • Supports: Local Files (SAS Viya) & Files in S3 Bucket

User Interface​

  • Options tab​

    Standalone modeFlow mode
  • AWS tab​

  • Advanced tab​

  • About tab​

Requirements​

Tested on SAS Viya version Stable 2022.09

Python Packages​

AWS Credentials​

To use this step an aws key & secret are required as credentials as well as an AWS region.

Supported File Types​

In the current implementation, AWS Textract doesn't support PDF files.

  • .jpg/.jpeg
  • .png

Usage​

📺 Tutorial (Click Thumbnail)​

YOUTUBE THUMBNAIL

Note: This step works well with the following custom step Create Listings of Directory - CLOD to create the input file-list based on a folder of documents.

Testdata​

Here is a list of test documents

Pro Tip: Take a photo with your smarphone, make a screenshot of a document or export a PowerPoint slide as .jpg/.png

Parameters​

Options​

X = Always Required | O = Required (for certain settings) | = No user input required

ParameterRequiredTypeDescription
Extraction TypeXOptionSpecifies the AWS Textract action that is called. For text: DetectDocumentText, for forms: AnalyzeDocument
Extraction LevelXOptionThe level of aggregation of the detected text. Possible values: Word, Line, Paragraph, Text
File LocationXOptionSpecifies whether the files are stored locally or in a S3 bucket
Input TypeXOptionSpecifies which documents should be processed. For local files (SAS Viya): Single file, list of files (table), For S3 Bucket: list of files (table), or a whole bucket
File PathOPathFile to be processed. Only when "SAS Viya" and "just one file" is selected
File ListOTableTable containing list of files. Only when a "list of files" is selected
Document Path ColumnOColumnColumn that contains the file paths. Only when "list of files" is selected
S3 Bucket NameOStringName of the S3 bucket containing the files. Only when "S3 Bucket" is selected
Output Status TableOptionWhether status tracking information about the processing should be in the output

AWS​

ParameterRequiredDescription
AWS Access KeyXAccess Key
AWS Secret KeyXSecret Key
AWS RegionXRegion of the AWS endpoint and S3 bucket (if "S3 Bucket" is selected)

Advanced​

ParameterRequiredDescription
Number of RetriesHow many retries attempts before a document is skipped
Seconds between retriesHow many seconds between retry attempts
Pragraph Detection ThresholdAWS Textract doesn't provide the OCR results on a paragraph level. Hence, paragraphs are detected after the fact by looking for text lines that are close / overlapping

Change Log​

  • Version 1.0 (08JAN2024)
    • Initial version