Skip to main content
Document AI is a document understanding platform from Google Cloud to transform unstructured data from documents into structured data, making it easier to understand, analyze, and consume. Learn more: The module contains a PDF parser based on DocAI from Google Cloud. You need to install two libraries to use this parser:
First, you need to set up a Google Cloud Storage (GCS) bucket and create your own Optical Character Recognition (OCR) processor as described here: cloud.google.com/document-ai/docs/create-processor The GCS_OUTPUT_PATH should be a path to a folder on GCS (starting with gs://) and a PROCESSOR_NAME should look like projects/PROJECT_NUMBER/locations/LOCATION/processors/PROCESSOR_ID or projects/PROJECT_NUMBER/locations/LOCATION/processors/PROCESSOR_ID/processorVersions/PROCESSOR_VERSION_ID. You can get it either programmatically or copy from the Prediction endpoint section of the Processor details tab in the Google Cloud Console.
Now, create a DocAIParser.
For this example, you can use an Alphabet earnings report that’s uploaded to a public GCS bucket. 2022Q1_alphabet_earnings_release.pdf Pass the document to the lazy_parse() method to
We’ll get one document per page, 11 in total:
You can run end-to-end parsing of a blob one-by-one. If you have many documents, it might be a better approach to batch them together and maybe even detach parsing from handling the results of parsing.
You can check whether operations are finished:
And when they’re finished, you can parse the results:
And now we can finally generate Documents from parsed results: