Processing M . A . Castrén’s Materials: Multilingual Historical Typed and Handwritten Manuscripts (2021)

Abstract: The study forms a technical report of various tasks that have been performed on the materials collected and published by Finnish ethnographer and linguist, Matthias Alexander Castrén (1813–1852). The Finno-Ugrian Society is publishing Castrén’s manuscripts as new critical and digital editions, and at the same time different research groups have also paid attention to these materials. We discuss the workflows and technical infrastructure used, and consider how datasets that benefit different computational tasks could be created to further improve the usability of these materials, and also to aid the further processing of similar archived collections. We specifically focus on the parts of the collections that are processed in a way that improves their usability in more technical applications, complementing the earlier work on the cultural and linguistic aspects of these materials. Most of these datasets are openly available in Zenodo. The study points to specific areas where further research is needed, and provides benchmarks for text recognition tasks.

## introduction as a research domain, the natural language processing has regularly focused on the formal written varieties of the most widely used languages of the world. at the same time there has been a growing interest in both non-standard and informal language @xcite , and their historical varieties @xcite . the research potential of historical language varieties is clearly on the upbound, and one can argue that the need is already quite evident, as digitization processes in libraries and archives around the world have reached relatively mature stages and already have large digital collections available. finnish ethnographer and linguist matthias @xcite produced a large collection of field notes, and also published widely on languages of northern eurasia. recently, two hundred years had passed since his birth, and in this connection the finno-ugrian society launched a project where several of his field notes and grammars are published as commented editions, available both digitally and in print. numerous monographs have already been published in the series @xcite @xcite @xcite @xcite . the complete series will contain more than twenty volumes. this article discusses the processing of original raw materials up to this point, with a goal of setting a vision of how this process can be refined later on. within the research tradition of the uralic languages, matthias castrén is often renowned as the most significant finnish linguist of the 19th century. castrén collected vast materials from almost thirty languages on his expeditions to lapland and northern russia between 1838 and 1849 @xcite . the materials are stored in the national library of finland. the number of handwritten manuscript pages is approximately ten thousand. castrén's work carries a unique historical dimension for the languages he studied, and his manuscripts and extensive correspondence with other researchers of the time are also valuable for the history of scientific research. our study presents individual datasets built from castrén's materials and reports benchmarks on various text recognition experiments. the main repository for related data is manuscripta castreniana collection in zenodo foot_0 , and other locations are specified when datasets are discussed. we also discuss individual experiments with the text recognition of castrén's unpublished and published materials, and contextualize the results more widely within early linguistic descriptions. we analyse some of the challenges met in further processing of this content, and delineate possible ways forward. the most important step we can identify is making these materials better available, so that further work can build upon the contributions of more researchers. this is also the step we are trying to help make. we would hope, for example, that eventually castren's materials would be included in different shared tasks. in the same spirit we also share all our processing code in github foot_1 , which we hope makes these materials easier to access for different researchers in the digital humanities and related fields. ## related work historical dataset creation is one topic that connects closely to ours. especially within the universal dependencies project @xcite there are numerous instances of historical language treebanks. there are five latin treebanks, old church slavonic treebank @xcite , old turkish (derin, 2020) and old french treebank @xcite , just to mention some of them. such resources are in a central role, as they allow training nlp models to address different downstream tasks for these language varieties. naturally, any openly available resource, in plaintext or with annotations, can be used for these purposes. at the same time, the conll-u file format offers a good and well understood structure that can easily be compared. there are examples of such datasets being used in downstream tasks, such as lemmatizers and pos taggers created for latin (clérice, 2021) and old french @xcite . work has been done also on old swedish (for example, @xcite , but an actual diachronic corpus seems to be still under construction @xcite . if such resources existed, the analysis of castrén's 19th century swedish would be in a different state. there is one unannotated diachronic corpus of old literary finnish (institute for the languages of finland, 2013) and one morpho-syntactically annotated corpus of mikael agricola's works (institute for the languages of finland and university of turku, 2020). the latter has already been used to develop a lemmatizer as well @xcite . named entity recognition (ner) for historical publications in finnish has also received attention lately @xcite . a recent survey by @xcite reviewed different named entity recognition systems for early modern textual documents. their conclusion was that benchmarking different ner systems in this domain is not currently possible, and suggest wider use of shared forums such as computational linguistics conferences as one way to coordinate further discussion and practices. study by @xcite where polish lexicographic cards were recognized and organized is in some aspects also close to what we would hope to achieve with materials discussed here. to our knowledge, there are no datasets, nlp tools or resources of historical varieties of the endangered languages included in these collections, especially in castrén's writing system that is essentially an inauguration of a latin based transcription (latin transcription with some cyrillic characters). ## materials we discuss four sections of castrén's materials. the first consists of ethnographic field notes in 19th century swedish under the title ethnographiska, historiska och statistiska anmärkningar. castrén wrote these texts in a extensive area that belongs to the northern regions of the contemporary russian federation. this text is also multilingual, with numerous expressions in cyrillic, but we can approach it largely as a swedish text. this subset contains 188 pages of handwritten texts. we use this dataset in text recognition experiments reported below, but these materials will be added to the zenodo collections at a later stage. the second dataset comes from tundra nenets epic poems that have a russian translation with swedish commentary. the figure 1 displays the typical structure in this manuscript. the page is split into two loosely distinguished columns, with tundra nenets transcription on the left and the rus-sian translation on the right. in the upper right region we see a comment in swedish in parentheses, but there are also parenthetical clarifications in russian, as seen in the bottom right corner. all in all, the material comprises 192 pages. this example also provides a good illustration of how the layout detection of these manuscripts is an additional challenge. this dataset is published as is in zenodo @xcite . the texts have been aligned line by line into the microfilm scans of the original manuscripts in collaboration between the university of innsbruck and the finno-ugrian society, and this material is an excellent test set for various tasks including text to image alignation, line segmentation and handwritten text recognition. the third dataset contains published komi-zyrian grammar of castrén @xcite ) that is written in latin. the grammar is 174 pages of printed text, all together. in the manuscripta castreniana project an english translation with commentary will be published, which adds a new dimension to what kind of computational tasks could be studied with this collection. additionally, this partially proofread dataset is located in zenodo (partanen and rueter, 2021), with 26 proofread pages of which 3 contain manually constructed tables. thereby, this dataset is an example of 19th century printed latin linguistic description, but also serves as the ground truth data for table layout detection as several tables are included with defined table cell structure. this grammar is also available as two different scans, both archived in zenodo. the fourth dataset contains castrén's komi-zyrian wedding laments and their transliteration in the modern komi orthography @xcite . these materials were published with finnish and german translations by aminoff (1880), and our dataset contains aligned versions of the translations and different transcriptions. similar dataset could also be created from castrén's translation of the gospel of st. matthew. crucially, castrén's transcription system cannot be automatically converted into current orthography as it does not contain all phonemic information that the orthography does. however, the dataset, in itself, is very illustrative of a wider problem in applying nlp to these kinds of materials: the textual representation used has such a different level that, if we cannot transform the transcription into a more modern writing system, we cannot access the text with any current tools. currently all text recognition experiments with castrén's data have been done using the transkribus platform. the reason for this has been that it allows collaborative editing, and has, at least for handwritten materials, been the currently leading platform. in our further processing the data from transkribus is exported in page xml format, which in our experience has been very satisfactory. it appears that castrén's materials are still particularly challenging to process, and we aim to delineate some of the more technical reasons next. the first part of the materials was aligned with the microfilm images from xml files where one unaligned transcription version already existed. as these transcriptions were done outside transkribus, with no visual connection to the actual documents, there may be features in the transcription that should be revised. at the same time the transcriptions were done before the text recognition task was even possible, so the character choices were primarily based on what was convenient for the individual researchers. when tens of thousands of pages are analysed together, it would be important to give careful consideration to which characters should be used to represent which of castrén's special characters. this work is partially technical and a matter of deciding the correct unicode characters, but also relates to linguistic analysis. the analysis of the latter type was also conducted for evenki by @xcite . as these early versions have been aligned with microfilm scans, and only later have the better quality versions been scanned from the original documents, it may become necessary to realign the transcriptions with these more accurate versions. the materials have been arranged so that such a task is in principle feasible. the second dataset discussed in this study contains exactly these aligned microfilm scans, which, we believe could be used to measure both the impact of chosen character conventions and the quality of scans to the recognition result. the higher quality images are also stored in zenodo with extensive metadata about the page content @xcite . generally it is very typical for castrén's materials that the same text exists in multiple versions. it is unclear to the current authors how to best connect these versions, but we see potentially high value in such an undertaking. ## processing tools we have archived our processing scripts on github and zenodo so that they would be maximally useful for a wider community of researchers. text recognized materials from transkribus can be exported in page xml format. the structure is highly standardized, but also relatively complicated. we provide methods to read the lines and their bounding boxes from the xml files into a python dictionary. after this different operations can be applied, but at a different level: there are already many packages often provide deeper language specific functionality that should be leveraged. example include uralicnlp @xcite for basic nlp analysis of uralic languages, and murre for specific dialectal and historical text normalization or lemmatization scenarios @xcite @xcite . the nlp for latin also seems fairly developed, and available models could be applied @xcite . we see as specific challenges in this the multilinguality and the continuous presence of words and expressions in different languages. ## further usage the materials we have discussed have been created for two purposes: 1) openly licensed ground truth material for text recognition models, and 2) recognized, manually corrected, text for ethnographic and linguistic research. text recognition models are at the moment line-based and the latter mainly relies on the subject knowledge of the researcher. neither of these tasks necessarily demands further automatic processing of the materials, at least as long as the research is based on visual use of original versions and the recognized text is used as an aid and search tool to navigate in the document. however, we consider it still extremely important to be able to extract the text correctly from the files. in the current dataset both the line and layout element structure is indicated by order numbers, and simple concatenation of the lines thereby, in principle, yields the wanted order. however, there are cases where the situation is more complicated. the running order of the elements and lines may not be manually corrected, and it relies on individual conventions whether there is some way to mark whether the order has been verified manually. in our dataset we find that the running order of the text is generally correct at the page level, and especially so in document pages where layout is simple. this includes the printed komi-zyrian grammar and ethnographic notes. in the former table layout detection would need attention, and in the latter problems arise primarily from margin notes and comments between lines. currently those are not easily placed to the correct locations in the text. in complexly layouted documents with several columns we also find a question of how to indicate the relationship across the columns, as one line is often translation or comment of the other. this issue is seen on almost all pages of the tundra nenets epic narrative dataset. ## conclusion our experiments show that the currently available tools to process 19th century latin grammar materials in an endangered language can be almost flawlessly recognized with out-of-the-box text recognition models. with handwritten materials the publicly available models need to be customized, but the current accuracy may give at least some starting point if the language and time period match. the divergence of transcription systems and their complex relation to the contemporary orthographies is one challenge that needs to be separately addressed. to advance actual nlp applications, we also suggest that a sample from castrén's materials would be published as a treebank or other annotated structure. such multilingual collection may not fit larger projects such as universal dependencies, but similar conventions and file structures could easily be used. how this can be connected to proofread ground truth resources, commentaries and digital editions is another question, but there are few materials better for testing this than castrén's data that is openly available and still acutely relevant for contemporary research.