Skip to main content

Utilty functions to work with TEI Documents

Project description

acdh-tei-pyutils

Github Workflow Tests Status PyPI version codecov

Utilty functions to work with TEI Documents

install

run pip install acdh-tei-pyutils

usage

parse an XML/TEI Document from and URL, string or file:

from acdh_tei_pyutils.tei import TeiReader

doc = TeiReader("https://raw.githubusercontent.com/acdh-oeaw/acdh-tei-pyutils/master/acdh_tei_pyutils/files/tei.xml")
print(doc.tree)
>>> <Element {http://www.tei-c.org/ns/1.0}TEI at 0x7ffb926f9c40>

doc = TeiReader("./acdh_tei_pyutils/files/tei.xml")
doc.tree
>>> <Element {http://www.tei-c.org/ns/1.0}TEI at 0x7ffb926f9c40>

write the current XML/TEI tree object to file

doc.tree_to_file("out.xml")
>>> 'out.xml'

see acdh_tei_pyutils/cli.py for further examples

command line scripts

Batch process a collection of XML/Documents by adding xml:id, xml:base next and prev attributes to the documents root element run:

add-attributes -g "/path/to/your/xmls/*.xml" -b "https://value/of-your/base.com"
add-attributes -g "../../xml/grundbuecher/gb-data/data/editions/*.xml" -b "https://id.acdh.oeaw.ac.at/grundbuecher"

Write mentions as listEvents into index-files:

mentions-to-indices -t "erwähnt in " -i "/path/to/your/xmls/indices/*.xml" -f "/path/to/your/xmls/editions/*.xml"

Write mentions as listEvents of index-files and copy enriched index entries into files

denormalize-indices -f "../../xml/schnitzler/schnitzler-tagebuch-data-public/editions/*.xml" -i "../../xml/schnitzler/schnitzler-tagebuch-data-public/indices/*.xml"
denormalize-indices -f "./data/*/*.xml" -i "./data/indices/*.xml" -m ".//*[@key]/@key" -x ".//tei:title[@level='a']/text()"
denormalize-indices -f "./data/*/*.xml" -i "./data/indices/*.xml" -m ".//*[@key]/@key" -x ".//tei:title[@level='a']/text()" -b pmb2121 -b pmb10815 -b pmb50

Register handle-ids and add them as tei:idno elements:

add-handles -g "../../xml/grundbuecher/gb-data/data/editions/*.xml" -user "user12.3456-01" -pw "verysecret" -hixpath ".//tei:publicationStmt"

develop

  • install dev-dependencies: pip install -r requirements_dev.txt
  • install local package pip install -e .
  • before commiting run flake8 to check linting and coverage run -m pytest -v to run the tests

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-tei-pyutils-1.1.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

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

acdh_tei_pyutils-1.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file acdh-tei-pyutils-1.1.tar.gz.

File metadata

  • Download URL: acdh-tei-pyutils-1.1.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for acdh-tei-pyutils-1.1.tar.gz
Algorithm Hash digest
SHA256 39cb3e801e727e82e7897617811888522d7d27419085880ff3330d02d4490d92
MD5 0c701112fdc77686b5313f49e39df34a
BLAKE2b-256 3ef4020c8e2dea814d57712d809822695277ee24ff9816d878c30055a833cd46

See more details on using hashes here.

File details

Details for the file acdh_tei_pyutils-1.1-py3-none-any.whl.

File metadata

  • Download URL: acdh_tei_pyutils-1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for acdh_tei_pyutils-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f898a2bc7c4ed179a0644d72ddbf09c84675f3282526a6c6cbaf2f321999b55a
MD5 9459a5d8cd686a8d617f51332d3b6008
BLAKE2b-256 08a8c6b4af15b5ea5005e0801c6960221ec451efbc564faff5a34dc635b46ba6

See more details on using hashes here.

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