Skip to main content

A Python package for analysing and restructuring the output of Automatic Text Recognition (ATR) pipelines.

Project description

archival-structures

Tools for analysing PageXML/ATR transcriptions and scan images of archival documents: detecting and splitting two-page book openings, clustering text lines and page layouts, mining cross-page document-element sequences, ink-colour and missing-transcription detection, and parsing EAD/METS archival finding-aid metadata.

Full documentation (including the per-module API reference) lives in docs/ and is built with Sphinx; see Documentation below.

Techniques and tasks

Archival images and transcriptions are organised as <institute_id>/<archive_id>/<inventory_num_id>/<scan>. The core idea behind this package is that one inventory number's worth of scans is a structured, ordered corpus, not a set of independent images -- so the analysis is built up in layers:

  1. Opening detection and splitting (archival_structures.analysis.opening_detection) -- decide whether a scan is a two-page spread, split it into independent verso/recto pages, and classify a whole inventory number as a book of openings versus a mixed folder/booklet.
  2. Page-layout clustering (archival_structures.analysis.page_layout_clustering) -- cluster whole pages by the spatial arrangement of their text lines, via a grid-pattern TF-IDF fingerprint.
  3. Line clustering (archival_structures.analysis.line_clustering) -- cluster individual text lines by indentation/width/height into a vocabulary of recurring line types (body text, closing lines, marginalia, ...).
  4. Sequence-pattern mining (archival_structures.analysis.sequence_patterns) -- order lines into a corpus-wide reading sequence and segment it into document elements, including elements that span a page break.

Tasks 2 and 3 both depend on splitting first (task 1) -- clustering whole two-page scans conflates the left and right page's geometry into one coordinate frame.

Alongside the text-analysis pipeline:

  • Ink colour, multi-colour text, and missing transcriptions (archival_structures.clustering.colour_clustering) -- robust ink/paper separation via multiotsu + connected-component shape (resistant to small artefacts like a sticker or stain), screening pages for more than one ink colour via LAB chroma spread, and flagging untranscribed page regions whose pixels look like genuine ink rather than blank paper.
  • Coordinate-space bridging (archival_structures.model.image, archival_structures.image) -- converting between a scan's native pixel coordinates, a thumbnail's, and a canvas rendering of a selection, via an affine Transform; converting between PageXML Coords and this package's own Box type; ipywidgets-based interactive region drawing/tagging.
  • Ground-truth annotation (archival_structures.datasets.annotations) -- a JSON schema for labelling scans/lines/cross-page elements, plus an ipywidgets notebook app for producing it.
  • EAD/METS parsing (archival_structures.parsers) -- a separate concern from the PageXML/image pipeline: parsing the archival finding-aid metadata (series/subseries/file structure, page manifests) that describes an archive's holdings.

See docs/findings.md for the concrete, validated-against-real-data lessons learned while building this -- several of the choices above (e.g. splitting before clustering, chroma spread over luminosity-class counting for multi-colour detection) turned out to matter a lot more than they first appeared to.

Demo notebooks

All in notebooks/demo/:

Demo data

The notebooks above need real PageXML/thumbnail data (~341MB across 7 inventory numbers) that isn't committed to this repo -- only the package code is. Download demo-data.zip from the latest release and extract it at the repository root:

unzip demo-data.zip -d .

This recreates data/PageXML/, data/thumbs/, and data/annotations/ with exactly the inventory numbers the demo notebooks reference, so they run unchanged once extracted.

Installation

poetry install

Requires Python >=3.11,<3.15 -- torch's triton dependency caps out at Python <3.15, so the project's declared Python range matches that rather than the more typical <4.0.

Documentation

Built with Sphinx; requires the optional docs dependency group:

poetry install --with docs
cd docs
make html

Project details


Download files

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

Source Distribution

archival_structures-0.1.0.tar.gz (94.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

archival_structures-0.1.0-py3-none-any.whl (111.2 kB view details)

Uploaded Python 3

File details

Details for the file archival_structures-0.1.0.tar.gz.

File metadata

  • Download URL: archival_structures-0.1.0.tar.gz
  • Upload date:
  • Size: 94.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for archival_structures-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a6354e535acb5aa3f340c5d3cf4d9778dfd6ad614959d489c43c66f388e606d
MD5 fc7025244f06214baf48c14fbc43de1e
BLAKE2b-256 357c50f45d38ec34631652ec1247a4f3a12f6b518f720028b380cbdd10a0649a

See more details on using hashes here.

Provenance

The following attestation bundles were made for archival_structures-0.1.0.tar.gz:

Publisher: publish.yml on Data-Scopes/archival-structures

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file archival_structures-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for archival_structures-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 696bec912d707dd6565b9149fddd22dd37fcae2c01acf6babe3d86e76cbcd91a
MD5 9b21e26066d6f1f7908a071150cd3fee
BLAKE2b-256 41fee23d004482f5e503605cebe39a75e8e508214181220b2448186c8d285abc

See more details on using hashes here.

Provenance

The following attestation bundles were made for archival_structures-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Data-Scopes/archival-structures

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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