Classifying TEI Encoding for D utch D ra C or with Transformer Models (2025)

Abstract: Computational Drama Analysis relies on well-structured textual data, yet many dramatic works remain in need of encoding. The Dutch dramatic tradition is one such an example, with currently 180 plays available in the DraCor database, while many more plays await integration still. To facilitate this process, we propose a semi-automated TEI encoding annotation methodology using transformer encoder language models to classify structural elements in Dutch drama. We fine-tune 4 Dutch models on the DutchDraCor dataset to predict the 9 most relevant labels used in the DraCor TEI encoding, experimenting with 2 model input settings. Our results show that incorporating additional context through beginning-of-sequence (BOS) and end-of-sequence (EOS) tokens greatly improves performance, increasing the average macro F1 score across models from 0.717 to 0.923 (+0.206). Using the best-performing model, we generate silver-standard DraCor labels for EmDComF, an unstructured corpus of early modern Dutch comedies and farces, paving the way for its integration into DutchDraCor after validation.

## introduction & related work the drama corpora project (dracor) is a rapidly growing open database that employs tei xml encoding to standardize language-independent, digitally readable formatting of dramatic texts @xcite . this encoding facilitates computational and comparative research on drama across historical periods, languages, and cultures. however, manually encoding texts according to the text encoding initiative (tei consortium, 2025) is a labor-intensive and time-consuming process, which presents a major bottleneck in the expansion and scalability of dracor. this challenge is evident for the dutch dramatic tradition among others, which has only recently been incorporated into dra-cor. currently, dutchdracor contains 180 encoded plays, while hundreds of historical dutch plays remain unencoded @xcite , which complicates further structural and comparative analysis. accelerating the structural encoding of these plays would not only advance research in dutch literary studies but also support the emerging field of computational drama analysis @xcite , enabling large-scale, cross-linguistic, and diachronic comparisons of dramatic traditions. to address this bottleneck, recent research has explored the use of machine learning (ml) to support or automate aspects of tei annotation in digital literary corpora. @xcite investigate the automatic enrichment of german dramatic text with structural tei elements. using finetuned bert-based models, they predict 5 elements ("act", "scene", "stage", "speaker", "speech") and achieve promising results in identifying these structural features from plain text after sentence tokenization. similarly, @xcite focus on the fine-grained classification of stage directions in french theater. they propose a detailed 13-class typology of stage directions and fine-tune transformers to classify these, demonstrating that even with limited training data, transfer learning techniques can support the structural annotation tasks relevant for computational literary studies. building on these approaches, this work aims to automatically annotate historical dutch drama with structural dracor labels by leveraging the existing dutchdracor as a dataset. assigning a label from the most fundamental set of tei elements to each line of text from dutchdracor, we model this task as a multiclass classification problem. innovatively, we experiment with incorporating additional contextual information as adjacent lines in the model input, introducing beginning-of-sequence (bos) and end-of-sequence (eos) tokens, to operationalize the structurally repetitive nature of dramatic texts. to our knowledge, this feature of drama has not been put to use in similar classification contexts, as related work focuses on classifying individual textual instances, often sentences. we hypothesize, however, that expanding the context will improve models' performance for this task, as it might help models to classify speakers, spoken text, act divisions and stage directions when the immediately preceding and subsequent context is given. the ultimate aim of this research is to support the semi-automated annotation of unstructured dramatic texts for dutchdracor, reducing the manual workload for human annotators. after validation, the automatically annotated labels following from this work in other unstructured plays can serve as gold-standard tei markup and facilitate dracor integration. this work presents a methodology that offers scalable solutions to support the incorporation of dramatic literary traditions into dracor, even if no specifically historically adapted language models exist, as we expect it to be transferable to encoding drama in other languages and contexts. our contributions to automatically encode drama therefore include: we create and release the dutchdracor4ml dataset, enabling supervised learning for tei encoding classification in historical dutch. ## operationalizing dutchdracor given that dutchdracor contains 180 manually annotated plays with tei encoding, we can operationalize these annotations to create a fine-tuning dataset for tei encoding classification. in total, tei files in dutchdracor contain 52 unique labels. however, predicting all 52 labels is unnecessary, as rule-based approaches can help create some of the umbrella tei elements, such as speaker turns containing a speaker and their spoken text, or the list of characters containing all roles of the play. we therefore focus on extracting the most relevant labels from the dutchdracor plays on the condition that a label contains text. after manual inspection, the following 9 labels seemed to encode all textual instances of a play: "line", for spoken lines by each "speaker"; "stage" for stage directions; "head" for structural indications such as act and scene divisions; "persname" for author names and the list of characters, which is in some plays annotated with "role"; "paragraph" elements indicating legal clauses regarding ownership, dedications, or other prefaces; and "title" and "titlepart" elements, which marks statements from the title page regarding place of publishing and the editor. creating random 70-20-10% splits based on the 180 dutchdracor plays, all text contained in the aforementioned labels was extracted per split for training, testing and development respectively (section 3), resulting in the label distribution showed in ## model fine-tuning we leverage the operationalized dutchdracor dataset to fine-tune existing language models for classification. for this, we choose language models trained on dutch. these include gysbert (manjavacas arevalo and fonteyn, 2022), fine-tuned on historical dutch, robbert (delobelle et al., 2020) and bertje (de vries et al., 2019), both fine-tuned on contemporary dutch, and finally gysdrama, a gysbert model fine-tuned by continuing full-model pre-training on dutch dramatic texts (debaene et al., forthcoming). each of these models are given the dataset for fine-tuning in 2 model input settings. in setting t, extracted text is given and the model is tasked to predict the correct label. in setting t+c, extracted text is contextualized with adjacent lines, namely the preceding and subsequent line, and delimited with beginning-ofsequence (bos) and end-of-sequence (eos) tokens. the model is then tasked to predict the correct label. an example from the opening scene of vondel's gysbreght van aemstel (1637), with both model input settings: model input label 1t. gysbreght van aemstel. head 2t. het eerste bedryf. head 3t. gysbreght van aemstel speaker 4t. het hemelsche gerecht heeft zich... line 1t+c. [bos] gysbreght van aemstel. [eos] het eerste bedryf. head 2t+c. gysbreght van aemstel. [bos] het eerste bedryf. [eos] gysbreght van aemstel head 3t+c. het eerste bedryf. ## results ## conclusion & future work this work suggests that incorporating contextual information substantially enhances tei encoding classification in historical dutch drama, improving performance across both historical dutch models (gysbert, gysdrama) and generalpurpose dutch models (bertje, robbert). by expanding the input beyond isolated text segments, transformer-based encoder models achieve a deeper understanding of dramatic structures, leading to more accurate predictions. notably, even models not pre-trained on historical language successfully classify tei labels when given additional context, highlighting fine-tuning and contextualization as effective strategies for adapting modern nlp techniques to this specific annotation task for historical and literary corpora. beyond dutch drama, these findings suggest broader applications for machine learning and deep learning techniques in tei encoding, particularly in other dramatic traditions facing similar challenges in encoding standardization and accessibility. transformer encoder models, with contextualized input, offer a scalable approach to facilitating computational drama analysis across languages and periods, even when domain-specific language models are not readily available. future work should explore cross-linguistic adaptations and deeper integration with tei workflows, advancing the intersection of nlp and digital humanities for more comprehensive literary and theater studies.