Skip to main content

pagexml-tools

GitHub Actions Project Status: Active – The project has reached a stable, usable state and is being actively developed. Documentation Status PyPI PyPI - Python Version

Utility functions for reading PageXML files

installing

using poetry

poetry add pagexml-tools

using pip

pip install pagexml-tools

Using

PageXML-tools contains functions for parsing and for a range of analysis tasks.

Parsing PageXML files and the Physical Document model

There is a tutorial that demonstrates the physical document model API

PageXML-tools contains basic functionality for parsing a PageXML file that returns a document model representing the content of the file. The HTR/OCR process that generates PageXML, recognises text in an image of a physical document.

from pagexml.parser import parse_pagexml_file

pagexml_file = "path/to/pagexml_file.xml"

page_doc = parse_pagexml_file(pagexml_file)

# a page document has an ID
print(page_doc.id)

# print descriptive statistics
print(page_doc.stats)

# iterative over text regions and lines
for tr in page_doc.text_regions:
    # a text_region has an ID and a bounding box derived from its coordinates
    print(tr.id, tr.coords.box)
    # a text_region can have sub-text_regions and lines
    for line in tr.lines:
        # a line has an ID, coordinates and text
        print(line.id, line.coords.box, line.text)

In addition to the basic parsing and handling of PageXML output, there is functionality to support a range of tasks:

  • reading sets of PageXML files from a archive (tar, zip) file (tutorial),
  • searching in text (keyword in context, keywords or fuzzy search)
  • reading and working with tables (table processing)
  • classifying physical document types in a large set of PageXML documents (tutorial),
  • checking the quality of the HTR/OCR process (tutorial),
  • comparing subsets (tutorial),
  • identifying document sections in sequences of PageXML documents (tutorial),
  • turning text lines into running text (tutorial),
  • supporting different reading orders (tutorial),
  • reinterpreting and restructuring text regions and lines (tutorial),
  • turning physical structure into logical structure,

Using PageXML-tools in R:

#Python
# run in CMD (Command) first (first time only): 
py -m pip install pagexml-tools
# Install and start Python 3.11 in background 
# R
# run in different window in R first time only! 
install.packages("reticulate")
# run in different window in R first: 
library(reticulate)
# run in different window in R next: 
py_require(c("pagexml-tools")) 

# Import PageXML file parser:

from pagexml.parser import parse_pagexml_file

Thanks to Milan van Lange for this R example.


USAGE | CONTRIBUTING | LICENSE

Metadata

Release files for pagexml-tools 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pagexml-tools 0.9.0
File Size Uploaded
pagexml_tools-0.9.0.tar.gz 75.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pagexml-tools 0.9.0
File Interpreter ABI Platform
pagexml_tools-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 160.1 kB

Release files / pagexml_tools-0.9.0.tar.gz

Download URL pagexml_tools-0.9.0.tar.gz
Size 75.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f6e153631a489b9c2a55be259ac016608abec06090455a26b0c90ebb3d0f369e
BLAKE2b-256 checksum
How to use checksums
b68e6df4c07006c6273abafaeacdf63bddcb1777eb8a2ba230faf006bd7de444
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.15 Darwin/27.0.0

Release files / pagexml_tools-0.9.0-py3-none-any.whl

Download URL pagexml_tools-0.9.0-py3-none-any.whl
Size 85.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0ab08a52e73183757f580b4161b5b718c0b6a24da796c10cccb42c80ddf4a96
BLAKE2b-256 checksum
How to use checksums
4c601be8f39ca962b72cd55ba1e96c9dda798e4b1b41229caa9bb6968dbc9089
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.15 Darwin/27.0.0

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page