Skip to main content

some utility function to interact with the Transkribus-API

Project description

acdh-transkribus-utils

PyPI version flake8 Lint Test codecov

A python package providing some utility functions for interacting with the Transkribus-API

Installation

pip install acdh-transkribus-utils

Usage

Authentication

Set Transkribus-Credentials as environment variables:

export TRANSKRIBUS_USER=some@mail.com
export TRANSKRIBUS_PASSWORD=verysecret

(or create a file called env.secret similar to env.dummy and run source export_env_variables.sh) you can pass in your credentials also as params e.g.

import os

from transkribus_utils.transkribus_utils import ACDHTranskribusUtils


tr_user = os.environ.get("TRANSKRIBUS_USER")
tr_pw = os.environ.get("TRANSKRIBUS_PASSWORD")

client = ACDHTranskribusUtils(user=tr_user, password=tr_pw)

List all collections

collections = client.list_collections()
for x in collections[-7:]:
    print(x["colId"], x["colName"])

# 188933 bv-play
# 188991 Kasten_blau_45_11
# 190357 acdh-transkribus-utils
# 193145 palm
# 195363 Österreichische Bundesverfassung: Datenset A
# 196428 Österreichische Bundesverfassung: Datenset B
# 196429 Österreichische Bundesverfassung: Datenset C

List all documents from a given collection

col_id = 142911
documents = client.list_docs(col_id)
n = -3
for x in documents[n:]:
    print(x["docId"], x["title"], x["author"], x["nrOfPages"])

# 950920 Kasten_blau_44_9_0050 Pfalz-Neuburg, Eleonore Magdalena Theresia von 1
# 950921 Kasten_blau_44_9_0037 Pfalz, Johann Wilhelm Joseph Janaz von der 4
# 950922 Kasten_blau_44_9_0239 Pfalz, Johann Wilhelm Joseph Janaz von der 1

Download METS files from Collection

from transkribus_utils.transkribus_utils import ACDHTranskribusUtils

COL_ID = 51052
client = ACDHTranskribusUtils()
client.collection_to_mets(COL_ID)
# downloads a METS for each document in the given collection into a folder `./{COL_ID}

client.collection_to_mets(COL_ID, file_path='./foo')
# downloads a METS for each document in the given collection into a folder `./foo/{COL_ID}

client.collection_to_mets(COL_ID, filter_by_doc_ids=[230161, 230155])
# downloads only METS for document with ID 230161 and 230155 into a folder `./{COL_ID}

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

acdh-transkribus-utils-2.10.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

acdh_transkribus_utils-2.10-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file acdh-transkribus-utils-2.10.tar.gz.

File metadata

  • Download URL: acdh-transkribus-utils-2.10.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for acdh-transkribus-utils-2.10.tar.gz
Algorithm Hash digest
SHA256 cb726b3f60c41d5c551e223e0fbd104ee7c7fe347f790347f3bbcf2a5be48d3b
MD5 11f961c350b1090bd762ad066f15a604
BLAKE2b-256 a1014be877ea8f7e2a9bc22e6d7c5e926d27c0b5aa42cdfb4f185eb27a16917a

See more details on using hashes here.

File details

Details for the file acdh_transkribus_utils-2.10-py3-none-any.whl.

File metadata

File hashes

Hashes for acdh_transkribus_utils-2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 be205152b06607dc921a9ab3c535a38dcd74597de50d20bb36f4b6d2866de02e
MD5 b1cace21ed07f424e8d1fb4cc4b59d2d
BLAKE2b-256 99952f3edc03ad9b667a99f7a38a38ed3e21ca2a5438e6db3d09c96da5ec9c1d

See more details on using hashes here.

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