acdh-tei-pyutils


Nameacdh-tei-pyutils JSON
Version 1.6 PyPI version JSON
download
home_pagehttps://github.com/acdh-oeaw/acdh-tei-pyutils
SummaryUtilty functions to work with TEI Documents
upload_time2024-11-05 08:42:06
maintainerNone
docs_urlNone
authorPeter Andorfer, Daniel Stoxreiter
requires_python>=3.7
licenseMIT
keywords acdh-tei-pyutils
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # acdh-tei-pyutils

[![Github Workflow Tests Status](https://github.com/acdh-oeaw/acdh-tei-pyutils/workflows/Test/badge.svg)](https://github.com/acdh-oeaw/acdh-tei-pyutils/workflows/Test/badge.svg)
[![PyPI version](https://badge.fury.io/py/acdh-tei-pyutils.svg)](https://badge.fury.io/py/acdh-tei-pyutils)
[![codecov](https://codecov.io/gh/acdh-oeaw/acdh-tei-pyutils/branch/main/graph/badge.svg?token=y6HUg72XnH)](https://codecov.io/gh/acdh-oeaw/acdh-tei-pyutils)

Utilty functions to work with TEI Documents

## install

run `pip install acdh-tei-pyutils`

## usage

some examples on how to use this package

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

```python
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
```python
doc.tree_to_file("out.xml")
>>> 'out.xml'
```

see [acdh_tei_pyutils/cli.py](https://github.com/acdh-oeaw/acdh-tei-pyutils/blob/main/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:

```bash
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:

```bash
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

```bash
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:

```bash
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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/acdh-oeaw/acdh-tei-pyutils",
    "name": "acdh-tei-pyutils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "acdh-tei-pyutils",
    "author": "Peter Andorfer, Daniel Stoxreiter",
    "author_email": "peter.andorfer@oeaw.ac.at",
    "download_url": "https://files.pythonhosted.org/packages/90/b5/7fdadb24c2e5bb410aa56ff8db32156b5c431624062ba233964f82e684b0/acdh_tei_pyutils-1.6.tar.gz",
    "platform": null,
    "description": "# acdh-tei-pyutils\n\n[![Github Workflow Tests Status](https://github.com/acdh-oeaw/acdh-tei-pyutils/workflows/Test/badge.svg)](https://github.com/acdh-oeaw/acdh-tei-pyutils/workflows/Test/badge.svg)\n[![PyPI version](https://badge.fury.io/py/acdh-tei-pyutils.svg)](https://badge.fury.io/py/acdh-tei-pyutils)\n[![codecov](https://codecov.io/gh/acdh-oeaw/acdh-tei-pyutils/branch/main/graph/badge.svg?token=y6HUg72XnH)](https://codecov.io/gh/acdh-oeaw/acdh-tei-pyutils)\n\nUtilty functions to work with TEI Documents\n\n## install\n\nrun `pip install acdh-tei-pyutils`\n\n## usage\n\nsome examples on how to use this package\n\n### parse an XML/TEI Document from and URL, string or file:\n\n```python\nfrom acdh_tei_pyutils.tei import TeiReader\n\ndoc = TeiReader(\"https://raw.githubusercontent.com/acdh-oeaw/acdh-tei-pyutils/main/acdh_tei_pyutils/files/tei.xml\")\nprint(doc.tree)\n>>> <Element {http://www.tei-c.org/ns/1.0}TEI at 0x7ffb926f9c40>\n\ndoc = TeiReader(\"./acdh_tei_pyutils/files/tei.xml\")\ndoc.tree\n>>> <Element {http://www.tei-c.org/ns/1.0}TEI at 0x7ffb926f9c40>\n```\n\n### write the current XML/TEI tree object to file\n```python\ndoc.tree_to_file(\"out.xml\")\n>>> 'out.xml'\n```\n\nsee [acdh_tei_pyutils/cli.py](https://github.com/acdh-oeaw/acdh-tei-pyutils/blob/main/acdh_tei_pyutils/cli.py) for further examples\n\n### command line scripts\n\nBatch process a collection of XML/Documents by adding xml:id, xml:base next and prev attributes to the documents root element run:\n\n```bash\nadd-attributes -g \"/path/to/your/xmls/*.xml\" -b \"https://value/of-your/base.com\"\nadd-attributes -g \"../../xml/grundbuecher/gb-data/data/editions/*.xml\" -b \"https://id.acdh.oeaw.ac.at/grundbuecher\"\n```\n\nWrite mentions as listEvents into index-files:\n\n```bash\nmentions-to-indices -t \"erw\u00e4hnt in \" -i \"/path/to/your/xmls/indices/*.xml\" -f \"/path/to/your/xmls/editions/*.xml\"\n```\n\nWrite mentions as listEvents of index-files and copy enriched index entries into files\n\n```bash\ndenormalize-indices -f \"../../xml/schnitzler/schnitzler-tagebuch-data-public/editions/*.xml\" -i \"../../xml/schnitzler/schnitzler-tagebuch-data-public/indices/*.xml\"\ndenormalize-indices -f \"./data/*/*.xml\" -i \"./data/indices/*.xml\" -m \".//*[@key]/@key\" -x \".//tei:title[@level='a']/text()\"\ndenormalize-indices -f \"./data/*/*.xml\" -i \"./data/indices/*.xml\" -m \".//*[@key]/@key\" -x \".//tei:title[@level='a']/text()\" -b pmb2121 -b pmb10815 -b pmb50\n```\n\nRegister handle-ids and add them as tei:idno elements:\n\n```bash\nadd-handles -g \"../../xml/grundbuecher/gb-data/data/editions/*.xml\" -user \"user12.3456-01\" -pw \"verysecret\" -hixpath \".//tei:publicationStmt\"\n```\n\n## develop\n\n* install dev-dependencies: `pip install -r requirements_dev.txt`\n* install local package `pip install -e .`\n* before commiting run `flake8` to check linting and `coverage run -m pytest -v` to run the tests\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Utilty functions to work with TEI Documents",
    "version": "1.6",
    "project_urls": {
        "Homepage": "https://github.com/acdh-oeaw/acdh-tei-pyutils"
    },
    "split_keywords": [
        "acdh-tei-pyutils"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "00980fadf37f2ce6d41b19bb1bb121a90af115469e61b71b1adc0343dfee4bef",
                "md5": "a318865d7437455e1949009ace64f3e3",
                "sha256": "94b586bb6c83dc583b7da51fb141fd56afee58f4f842950c7ac85fe01c8ca059"
            },
            "downloads": -1,
            "filename": "acdh_tei_pyutils-1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a318865d7437455e1949009ace64f3e3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 19111,
            "upload_time": "2024-11-05T08:42:04",
            "upload_time_iso_8601": "2024-11-05T08:42:04.704964Z",
            "url": "https://files.pythonhosted.org/packages/00/98/0fadf37f2ce6d41b19bb1bb121a90af115469e61b71b1adc0343dfee4bef/acdh_tei_pyutils-1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90b57fdadb24c2e5bb410aa56ff8db32156b5c431624062ba233964f82e684b0",
                "md5": "f2c4f4a2af2454ce380232048657c994",
                "sha256": "387f99bf5248bf0716d6a3e7ce049937a1e8f2754e454bbc84fc9b6cd876b5f0"
            },
            "downloads": -1,
            "filename": "acdh_tei_pyutils-1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "f2c4f4a2af2454ce380232048657c994",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 19338,
            "upload_time": "2024-11-05T08:42:06",
            "upload_time_iso_8601": "2024-11-05T08:42:06.044719Z",
            "url": "https://files.pythonhosted.org/packages/90/b5/7fdadb24c2e5bb410aa56ff8db32156b5c431624062ba233964f82e684b0/acdh_tei_pyutils-1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 08:42:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "acdh-oeaw",
    "github_project": "acdh-tei-pyutils",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "acdh-tei-pyutils"
}
        
Elapsed time: 0.40560s