acdh-tei-pyutils
Utilty functions to work with TEI Documents
install
run pip install acdh-tei-pyutils
uv add acdh-tei-pyutils
usage
some examples on how to use this package
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/main/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:
# using uv
uv run add-attributes -g "/path/to/your/xmls/*.xml" -b "https://value/of-your/base.com"
# pip installed
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
# docs
uv run denormalize-indices --help
# examples
uv run denormalize-indices -f "../../xml/schnitzler/schnitzler-tagebuch-data-public/editions/*.xml" -i "../../xml/schnitzler/schnitzler-tagebuch-data-public/indices/*.xml"
uv run denormalize-indices -f "./data/*/*.xml" -i "./data/indices/*.xml" -m ".//*[@key]/@key" -x ".//tei:title[@level='a']/text()"
uv run denormalize-indices -f "./data/*/*.xml" -i "./data/indices/*.xml" -m ".//*[@key]/@key" -x ".//tei:title[@level='a']/text()" -b pmb2121 -b pmb10815 -b pmb50
uv run denormalize-indices -f "./data/*/*.xml" -i "./data/indices/*.xml" --standoff # writes entity-lists into a tei:standOff element and not in a back element.
develop
- project uses uv
- linting/formatting
uv run ruff check .uv run ruff format . - before commiting run
flake8to check linting anduv run coverage run -m pytest -vto run the tests
bump version
uv version --bump minor
Metadata
Release files for acdh-tei-pyutils 2.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| acdh_tei_pyutils-2.4.0.tar.gz | 13.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| acdh_tei_pyutils-2.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.6 kB
Release files / acdh_tei_pyutils-2.4.0.tar.gz
| Download URL | acdh_tei_pyutils-2.4.0.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c825ad1522f0325342ca012a8adc4fca8c476d9f3b366a73ae40eba3b44a7f9
|
|
BLAKE2b-256 checksum How to use checksums |
e189cd5e3bf9a0ec1028083674c180b6dd28d504f57e6c1142404658aa0e3dee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / acdh_tei_pyutils-2.4.0-py3-none-any.whl
| Download URL | acdh_tei_pyutils-2.4.0-py3-none-any.whl |
|---|---|
| Size | 19.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44e4b0a134549a6ec4ee5622651cb99217dbc829a4b0bd28f249e24dd925a75d
|
|
BLAKE2b-256 checksum How to use checksums |
33565c34e42e0be5ddb1e1e9951704ac9ee7f00c4edcc7c0a79f3029e461e5d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|