A new machine-actionable corpus for ancient text restoration (2024)

Abstract: The Machine-Actionable Ancient Text (MAAT) Corpus is a new resource providing training and evaluation data for restoring lacunae in ancient Greek, Latin, and Coptic texts. Current text restoration systems require large amounts of data for training and task-relevant means for evaluation. The MAAT Corpus addresses this need by converting texts available in EpiDoc XML format into a machine-actionable format that preserves the most textually salient aspects needed for machine learning: the text itself, lacunae, and textual restorations. Structured test cases are generated from the corpus that align with the actual text restoration task performed by papyrologists and epigraphist, enabling more realistic evaluation than the synthetic tasks used previously. The initial 1.0 beta release contains approximately 134,000 text editions, 178,000 text blocks, and 750,000 individual restorations, with Greek and Latin predominating. This corpus aims to facilitate the development of computational methods to assist scholars in accurately restoring ancient texts.

## introduction for the papyrologist and epigraphist, a fundamental task is the creation of an accurate transcription of the text under consideration. often the physical medium supporting the text has undergone decay, leaving gaps, or "lacunae," in the text. filling these gaps is a painstaking task. @xcite first recognized the potential of computer science for assisting with text restorations of this type, specifically by leveraging string-searching algorithms. advances in computational approaches to text analysis, especially deep learning and large language models, may be able to aid scholars in the task of textual restoration. developing such systems typically requires large amounts of data, both for training, and ideally for providing taskrelevant means for evaluation. here we introduce the 1.0 beta version of the machine-actionable ancient text corpus (maat corpus), which provides training and evaluation data for the development of machine learning models that aid in the restoration of ancient greek, latin, and coptic texts. ## current text restoration corpora there are several different corpora used in creating systems for text restoration of ancient text. two existing systems, pythia @xcite and its successor ithaca @xcite use greek inscription data from the packard humanities institute (packard humanities institute, 2023) that have been converted to a modified leiden convention @xcite format. papavassiliou et al. 2020 created a corpus of mycenaean linear b texts for the restoration of linear b tablets. background large-language models have been trained on corpora as well, such as latin bert @xcite and aristoberto @xcite , greberta @xcite . ## corpora of interest papyrologists and epigraphists have generally agreed upon using a specialized schema developed originally for epigraphy, epidoc @xcite , based on the tei format @xcite . the largest corpus of epigraphy stored in epidoc format is maintained by the epigraphic database heidelberg (epigraphic database heidelberg, 1993), which focuses primarily on latin inscriptions from the roman empire. the largest corpus of papyrological texts is papyri.info, a collaboration among several institutions that hosts papyrological data in greek, latin, coptic, and arabic @xcite . the epidoc format provides extensive capabilities for describing metadata for inscriptions and papyri. it also has an xml-structured format as an alternative to the leiden conventions. texts are described in ab blocks (originally standing for "anonymous block") and provide a richer description language for text editions than the leiden conventions. because the leiden conventions format is more compact, we will use this format for examples printed in this paper. ## features of maat corpus unfortunately, for many machine learning and large language models, the structure of the ab blocks is too rich, since it provides internal structure for annotations, stylistic information and so on (the leiden conventions also communicate some of these features). with respect to building systems for text restoration, a simpler system is required. as assael et al. 2022 note, these corpora need to be "machine-actionable." for this reason, they ought to be easy to feed into machine learning systems for learning and for evaluation. figure 1 shows the text from a typical edition (p.flor 3 324) from papyri.info, a contract for the sale of property (aegyptus. @xcite . for this paper, three things should be noted. first, text restorations are provided in square brackets. for example, in line three, the brackets in the phrase [ἢ ὅ]σων̣ indicate that "ἢ ὅ" has been supplied by the papyrologist and that the letter forms are not visible on the papyrus itself. second, missing text that the editor has not restored is indicated by dots. one dot corresponds to one missing letter; therefore, the number of dots signifies the approximate number of letters known to be missing. the marking "-ca.?" or "---" indicates a gap of unknown extent. third, alternate restorations of the text are sometimes given in the apparatus criticus. these alternate readings represent viable textual conjectures, which were not ultimately chosen by the editor as their preferred reading. while digital editions print alternative restorations less commonly than print editions, they are sometimes encoded in the xml { "corpus_id": "edh", "file_id": "hd056774", "block_index": 1, "id": "edh/hd056774/1", "title": "epitaph from municipium claudium virunum, bei -s. andrä/lavanttal (noricum)", "material": "gesteine", "language": "la", "training_text": " ursuius vius sibi \nfecit @xmath0, "test_cases": [ { "case_index": 1, "id": "edh/hd056774/1/1", "test_case": " ursuius vius sibi \nfecit @xmath1..]", "alternatives": [ "ri" ] } ] } data. in our sample text from figure 1 , two apparatus notes appear for line two of the transcription. to make a corpus machine-actionable for learning, especially for large language models, we stripped away all but the most textually salient aspects of the text, using unicode utf-8 encoding. our corpus includes the preserved text, as well as unclear letters and restorations. although typographical conventions such as casing, interlinear word space, punctuation, accents, breathing marks, and other diacritics are typically not found on the source material, such typography is retained. line breaks (indicated by the lb element in epidoc xml) are also preserved. unclear text, indicated by leiden conventions with a sublinear dot, is treated no differently than preserved text; text that has been restored by an editor is bracketed. for example, the text "καὶ ε[ἰ]σ̣ ό̣ δ̣ ου̣ " converted to "καὶ ε[ἰ]σόδου." occasionally (as in figure 1 ) there are alternative readings of a restored text, but since alternative readings are difficult to process, the first primary text restoration is chosen. abbreviations, especially prevalent in latin inscriptions, are not expanded. gaps in the text that have not been restored by an editor must also be indicated. there are, essentially, three types of gaps: gaps of known length, gaps of approximately known length, and gaps of unknown length. gaps of known length are converted to a dot for each missing letter. similarly, gaps of approximate length are treated as if the gap length is known. the epidoc xml @xmath2. gaps are sometimes indicated within a restored text, and such gaps are moved outside. for example, the text "τὸν πωλοῦντ̣ [α -ca.?-παρὰ]" is converted to "τὸν πωλοῦντ[α]<gap/>[παρὰ]". in the end, all texts in the maat corpus are written in a simplified format for easier use by machine learning models. texts from the ab blocks in epi-doc xml format are converted to a light, leidenlike format, but with a bare minimum of annotative markings: text and gaps of known and unknown length, with restored text in brackets. figure 2 provides our data for a 1 st -2 nd century ce epitaph from the roman province noricum (edh hd056774, 2014). typically, in machine learning tasks, a portion of a training corpus is set aside for evaluation. in the most successful system to date for inscription restoration, ithaca @xcite , one to ten characters are artificially hidden during the testing phase, and the machine (or parallel human evaluator) is tasked with restoring these artificial lacunae. a similar text-masking evaluation method is used in papavassileiou et al., 2023 for mycenaean linear b tablets, although they also ask the model to perform text restoration of some real lacunae. the large number of restorations created by papyrologists and epigraphists found in the base corpora of greek, latin, and coptic texts provide a rich opportunity to create evaluation data that are aligned with the actual text restoration task. although it may be useful to train a system using artificial lacunae, it is more valuable to evaluate on the text restorations done by working papyrologists and epigraphists. these practitioners do not work with random lacunae, since lacunae in situ are not random: they follow a logarithmic distribution in length (see figure 3 ), and tend to occur in certain locations. the immediate textual context of real lacunae also tends to be much deteriorated and uncertain, in comparison to the sites of artificial lacunae. corpus editions blocks restorations dclp (digital corpus of literary papyri in epidoc xml) 1,938 11,581 129,806 ddbdp (duke databank of documentary papyri) 59,693 85,626 507,985 edh (epigraphic database heidelberg) 72,353 80,753 113,944 totals 133,984 177,960 751,735 to that end, we can create test cases by using the actual lacunae and text restorations that are present in papyrological and epigraphic sources and use the (retained) training data with the restored text for evaluation. because there are possible alternative readings for a restored gap, though, it is better to have a structured test case that retains those readings. this will slightly complicate the evaluation metrics. rather than using, for example, character error count for a single restoration, we need to use the minimum character error count for a (possibly singleton) set of alternatives. similarly, calculating the top-n rate will need to consider the presence of the proposed restoration in the set of alternatives. thus, a single test case needs a little more structure, containing at least the text with a gap to be filled, plus its alternatives. for example, for the text "ὠνουμένη ἰσα[....]" the two alternative readings "ροῦς" and "ριον" are required. note that, because letter forms of different types take up different amounts of space on the material substrate (and therefore calculations of the number of missing letters are approximate), alternatives might, in fact, have different character lengths. in these cases, the mask to be restored will comprise the mode of alternative lengths. ## format and distribution of data data in the maat corpus is structured as a set of javascript object notation (json) records @xcite , one record for each ab block. each record contains metadata about the block (an id field, source corpus, source file id, block index within the file, material, and language). it also has the training text, as described above. for each restored text, a test case is created, also containing an id, test case index within the text, the test case itself, and the set of alternatives. for statistical purposes, the number of alternatives, the number, mode, maximum, and minimum lengths of the alternatives are also described. currently, there are approximately 134,000 editions processed in the maat corpus, representing approximately 178,000 ab blocks and 750,000 individual text restorations. there is a small representation of coptic texts in the maat corpus (around 1% of the total, mostly papyri). latin editions outnumber greek editions (54% and 45%, respectively). papyrological texts tend to be longer than inscriptions; papyrological texts tend to be written in greek and inscriptions in latin, so the number of greek blocks is greater than the number of latin ones (53% and 46%, respectively). the number of text restorations in greek greatly outnumber latin ones (83% and 16%, respectively). the gap lengths of restored text created by papyrologists and epigraphists found in the maat corpus vary widely, and follow an unsurprising logarithmic or zipfian distribution. gaps of length 1 (that is, one character) account for 30% of all gaps, and gaps of length 4 or less account for 67%. gaps of length 10 or less account for 87% of all gaps. figure 3 shows the distribution. ## data availability and next steps we are now releasing the machine-actionable ancient text corpus in a beta state at https://zenodo.org/records/12518435 @xcite . the corpus is not meant to compete with current systems, such as papyri.info and edh, whose use cases are different. instead, we hope that the maat corpus will aid the creation of software systems that can help working papyrologists and epigraphists accurately and efficiently hypothesize text restorations in new editions of current and newly recovered texts and inscriptions. code for creating the corpus can be found at https://github.com/wmu-herculaneum-project/maat. we welcome the collaboration of other scholars and institutions in the service of adding additional data to the maat corpus, including data from other ancient languages. our specific interest is in text restoration of greek papyrological texts, but we would like to expand this to arabic and other non-western texts as well. given the similarities of the text restoration task and its evaluation methodology among texts of different language traditions, such expansions promise to be fruitful. in the future, we also intend to create a pathway by which any data made available in dsl-based formats @xcite can be converted for inclusion in future versions of the corpus. ## conclusion this paper introduces and announces the publication of the maat corpus, which provides an easily accessible, versioned corpus of machine-actionable ancient texts that can be used in machine learning. it also makes available evaluation data, via its test cases, that closely track the task of text restoration as done by working papyrologists and epigraphists. the maat corpus currently includes approximately 60 mb of ancient text, making it the largest corpus available for evaluating text restoration tasks. it is also the only dataset that uses actual lacunae and text restorations as test cases for evaluation.