Skip to main content

Convert AWS Textract JSON to PRImA PAGE XML

Project description

textract2page

Convert AWS Textract JSON to PRImA PAGE XML

Introduction

This software converts OCR results from Amazon AWS Textract Response files to PAGE XML files.

Installation

In a Python virtualenv:

pip install textract2page

Usage

The package contains a file-based conversion function provided as CLI and Python API. The function takes the Textract JSON file and the original image file which was used as input for the OCR. (That is necessary because Textract stores coordinates in float ratios, whereas PAGE uses int in pixel indices.)

Python API

To convert a Textract file example.json for an image file example.jpg to a PAGE example.xml:

from textract2page import convert_file

convert_file("example.json", "example.jpg", "example.xml")

CLI

Analogously, on the command line interface:

textract2page example.json example.jpg > example.xml
textract2page -O example.xml example.json example.jpg

You can get a list of options with --help or -h

Testing

Requires installation and a local copy of the repository.

To run regression tests with pytest, do

make deps-test
make test-api

To run regression test via command line, do

# optionally:
sudo apt-get install xmlstarlet
make test-cli

(If xmlstarlet is available, then the CLI test will also validate the result tree. Otherwise, this just checks the command completes without error.)

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textract2page-0.1.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

textract2page-0.1-py3-none-any.whl (9.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page