Skip to main content

License: GPL

TXT2TEI

An aid to encoding plays as XML-TEI

txt2tei is a Python script to encode Spanish Siglo de Oro plays as XML-TEI files. It takes a minimally annotated tabular TXT file resembling the printed layout with a reduced set of simple tags. The script speeds up the process of encoding TEI files by automating their annotation, requiring just an (almost) visual edition of the sourceTXT files.

These scripts are part of the research project Sound and Meaning in Spanish Golden Age Literature.

Requirements

The programme requires following libraries:

  • BeautifulSoup 4
  • pandas
  • datetime
  • unidecode
  • lxml >= 4.9.2
  • chardet

txt2tei runs on lxml and tei2txt on BS4. They may be unified in the future though.

Installation

Download the python scripts and the files sexos.csv and authors.xml in the same directory. You can also install it as a pip package, in which case it is not necessary to save the data files in your working directory.

pip install txt2tei

Use

Edit the personalised section of txt2tei.py to suit your needs and run the following commands:

./txt2tei.py tabularfile.txt

If installed with pip, the syntax differs:

txt2tei tabularfile.txt

Additionally, the script tei2txt.py performs the inverse operation

./tei2txt.py xmlteifile.xml

Description

The tabular file must be encoded as UTF-8 Unicode text with LF terminators (Unix encoding). The script will end with error if used on a text with CRLF terminators (DOS encoding) or other exotic encodings. It should be no problem as any respectable editor lets you change the encoding. Alternatively, there are simple one-liner tools around to convert from one format to another. In any case, the content must follow the following conventions:

<x>Comment
<a>Author's name (Just one single word, e.g. Calderón, Lope, Tirso...
<t>Title
<g>Genre
<s>Subgenre
<o>Source*URL
<f>Date
<x> The tag el marks the dramatis personae of  <castList>
<el>DRAMATIS PERSONAE (optional)|CHARACTER 1, a character*CHARACTER 2, another character*CHARACTER 3, a third one*CHARACTER 4, and just one more
<j>Act
<sc>Scene
<i>Stage direction
<x>Comment
CHARACTER ONE
<x>A tabulator marks the speeches
        Verse 1,
        verse 2.
CHARACTER 2
        <i>Internal stage direction
        Verse 3
        verse 4 (beginning)
CHARACTER 1
                Verse 4 (middle)
<x>An additional tab marks the continuation of a shared verse
CHARACTER 3
                        Verse 4 (end)
    verse 5,
    verse 6.
  ...
MUSIC
<e>Echo
CHARACTER 4
        <i>Reads:
<p>Prose
MULTIPLE CHARACTERS #character1 #character2
<x> Instead of letting the programme guess the characters in a collective parlamente, they can be indicated here explicitly

In order toi assign sexes to the characters, there is a CSV file in the format:

NAME,MALE,True

The first field is the name, the second the sex, and the third if was manully checked. This can be done with the provided script makelist.py

Known issues

The programme only recognises "Calderón", "Lope" and "Calderón (atri.)" as authors. Adding new authors is trivial, as they can just be added to the dictionary authors.

Lope's ids are placeholders. Proper numbers should be given.

Most important: The programme is aimed to Spanish 17th century plays. The language conventions (e.g., this is an issue concerning sex of collective characters or a shared parlament in which 'Y' will be parsed as 'AND') and structure (versified plays) may need some tinkering to be applied to other kind of plays.

Contributions

Feel free to contribute using the GitHub Issue Tracker for feedback, suggestions, or bug reports.

Changelog

1.0.6-2

  • Added chardet to dependencies
  • Solved deprecated 'rU'

1.0.6

  • Solved empty date crash.
  • Handling BOM and Hasefroch line terminators
  • Changelog markdown syntax

1.0.5

  • Solved pronouns-related crash

How to cite txt2tei

Authors of scientific papers including results generated using txt2tei are encouraged to cite the following paper.

@article{SanzLazaroF_RHD2023, 
    author    = {Sanz-Lázaro, Fernando},
    title     = {Del fonema al verso: una caja de herramientas digitales de escansión teatral},
    volume    = {8},
    date  = {2023},
    journal   = {Revista de Humanidades Digitales},
    pages = {74-89},
    doi = {https://doi.org/10.5944/rhd.vol.8.2023.37830}
}

Copyright (C) 2022 Fernando Sanz-Lázaro <fsanzl@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Metadata

Release files for txt2tei 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for txt2tei 1.0.7
File Size Uploaded Provenance Actions
txt2tei-1.0.7.tar.gz 37.1 kB Without provenance Details for txt2tei-1.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for txt2tei 1.0.7
File Interpreter ABI Platform Actions
txt2tei-1.0.7-py3-none-any.whl Python 3 none any Details for txt2tei-1.0.7-py3-none-any.whl

Total release size: 76.2 kB

Release files / txt2tei-1.0.7.tar.gz

Download URL txt2tei-1.0.7.tar.gz
Size 37.1 kB
Tags Source
SHA-256 checksum
How to use checksums
40f0329d9e752b86589ff640deb0b718533da5144c509512e2df82e918d26696
BLAKE2b-256 checksum
How to use checksums
b11d00a0251045440b87f22cc987448e67f49cc547dd18ec2754f3daead9abc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / txt2tei-1.0.7-py3-none-any.whl

Download URL txt2tei-1.0.7-py3-none-any.whl
Size 39.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b57997505ce849488b69e24ffaa24348a011a8de6b2d29be4c2dc5be57ddd6b
BLAKE2b-256 checksum
How to use checksums
fc939d93e973f98f57eb7170cb467e8350356a555ce5010aafc9c025b48baa69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Security for txt2tei 1.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page