pyonb: an open-source API and optical character recognition SDK for automated document-to-text conversion of clinical records
Abstract
Optical character recognition (OCR) software is becoming increasingly prevalent with the expanding computational power and advancements in natural language processing, which enables reuse of previously untapped data due to the lack of tools for converting images into computer-readable text. Broadly, OCR is the analysis, recognition and extraction of text from documents. There are numerous open-source OCR software toolkits (Tesseract, Docling, olmOCR, PaddleOCR, Marker, Sparrow, MinerU, etc.) providing automatic conversion of images or filetypes such as PDF and DOCX into structured outputs.Data storage is significantly heterogenous across and within UK hospitals. Medical data is often stored within data warehouses containing hundreds of millions of documents. This volume of data combined with the difficulty of information extraction from scanned documents represents a significant data processing challenge. From a research and innovation perspective, automatic text extraction of hospital documents enables innumerable possibilities such as improving diagnostics, clinical workflows and administrative processes. For example, AI methods can be applied to decades of untapped historical records to create prognostic models that cannot be developed in any other way. Here, we present pyonb (https://github.com/SAFEHR-data/pyonb), an open-source Python SDK for automated document-to-text conversion, designed for clinical processing (although it is content-agnostic so useable for any text extraction task). pyonb bundles multiple open-source OCR tools (including Marker, Sparrow, PaddleOCR, and more) with a central forwarding API for requesting which OCR tool to execute. pyonb is designed as a suite of containerised services which can be deployed on a server to retrieve documents from a data warehouse for automated OCR and text extraction.In this work we describe:the user requirements which motivated our design decisionsthe software architecturehow developers can deploy the software and extend it to integrate their preferred OCR toolthe performance and processing speeds of a subset of OCR toolsAcknowledgements This study was funded by the National Institute for Health and Care Research (NIHR, award code NIHR302495) and University College London Hospitals Biomedical Research Centre. The views expressed are those of the author(s) and not necessarily those of the NIHR or the Department of Health and Social Care.