Detecting de minimis Code-Switching in Historical G erman Books (2020)

Abstract: Code-switching has long interested linguists, with computational work in particular focusing on speech and social media data (Sitaram et al., 2019). This paper contrasts these informal instances of code-switching to its appearance in more formal registers, by examining the mixture of languages in the Deutsches Textarchiv (DTA), a corpus of 1406 primarily German books from the 17th to 19th centuries. We automatically annotate and manually inspect spans of six embedded languages (Latin, French, English, Italian, Spanish, and Greek) in the corpus. We quantitatively analyze the differences between code-switching patterns in these books and those in more typically studied speech and social media corpora. Furthermore, we address the practical task of predicting code-switching from features of the matrix language alone in the DTA corpus. Such classifiers can help reduce errors when optical character recognition or speech transcription is applied to a large corpus with rare embedded languages.

## metrics for characterizing code-switched corpora in this section we briefly introduce three metrics for measuring characteristics of code-switched corpora. the metrics, as defined by @xcite on the basis of previous work, include: m-index, measuring the inequality of the distribution of languages; (normalized) i-index, measuring the frequency of switching in a code-switched corpus; and burstiness, measuring the degree of periodicity in codeswitching patterns in the corpus. the multilingual index (m-index), developed by @xcite , is a token-count-based measure that "quantifies the inequality of the distribution of language tags in a corpus of at least two languages" @xcite . it is defined as follows: note that i normalized ranges from 0 to 1, representing the absolute minimum and maximum numbers of possible switches within the corpus, regardless of the underlying language distribution. therefore, one can direct compare this metric across different corpora. burstiness @xcite ) "quantifies whether switching occurs in bursts or has a more periodical manner" @xcite . it is defined as: ## datasets and analysis we now describe our corpora and analyze them for their patterns of code-switching. ## predictive tasks for studying code-switching results in §3.2 demonstrate that the code-switching patterns in historical books are significantly different than in usually studied domains, such as social media. in this section, we consider two tasks that are uniquely suitable for investigating code-switching in historical books. as discussed in §1, both tasks aim to improve ocr performance on the books. for both tasks, we utilize a 80%/10%/10% train/dev/test book-level split of the dta corpus. for the first task, we predict whether there are non-german languages present in a book for the dta corpus. for our book-level baseline, we pick the top 1,000 words in each book and use word count as features. then a vector that contains the count for each word in the vocabulary is used as the feature vector x for the regression model. we then train a logistic regression model for the prediction task. the logit function is β 0 + β 1 x, where β 0 and β 1 are model parameters. the reason why we choose logistic regression for this task is that we want a simple model that is good for a binary classification task as our baseline. we use sklearn implementation @xcite (v 0.22.2) for the model. the model outputs log probabilities of the book containing only german or german plus foreign languages. for the second task, our goal is to predict which language the next character (for the dta corpus) or the next word (for the lince corpora) would be in given a sequence of characters/words that have been read so far. hence this is a seq2seq @xcite model. of all the choices we have for such a model, we use a character/word lstm model as our baseline just for illustration purpose. the reason why we choose a character level model for the dta corpus is that we want to simulate the environment for ocr where each character is sequentially scanned and predictions for the next character precision recall f1 0.83 0.80 0.81 ## conclusion in this paper, we study the code-switching patterns in 1,406 historical german books. we automatically annotate and manually inspect code-switched text spans. we then quantitatively show that the codeswitching patterns in these books are different from those in typically studied informal code-switching domains, such as social media. we propose two interesting tasks that, if well handled, would help improve ocr performance on code-switched historical books. finally, we provide baseline results for the two tasks. the first task gives decent baseline performance, and we see an obvious precision-recall tradeoff by input chunk size on the second task where we have the dta corpus as our input. we also see that locating code-switching points is a more difficult task in historical text than in informal domains such as social media, since it occurs rarely in old books. the f1 score for the sequential prediction task could be further improved by utilizing different model architectures. we leave this for future work. additionally, our study opens an avenue for more analysis of code-switching patterns in historical texts.