Detecting Code-Switching in a Multilingual Alpine Heritage Corpus

Martin Volk, Simon ClematideCodeSwitch @ EMNLP 2014 · OpenReview

Abstract

Researchers at the University of Zurich have developed a pipeline to detect and annotate "code-switching"—the practice of mixing languages—within a massive 150-year archive of Swiss Alpine literature. By combining Part-of-Speech (PoS) tagging "failures" with specialized language identification, they achieved 78% precision in identifying foreign fragments within sentences, revealing how linguistic habits in the Alps shifted from the 19th century to the modern era.

Introduction

Most Natural Language Processing (NLP) tools are "monolingual by design." If a German PoS tagger is applied to a sentence containing an English quote, it typically "hallucinates," assigning nonsense labels to the foreign words or marking them as proper nouns. This presents a significant challenge for the Text+Berg project, which digitized the yearbooks of the Swiss Alpine Club (SAC) dating back to 1864.

The SAC yearbooks are a "linguistic fondue" of German, French, Italian, Romansh, English, and Latin, reflecting the multilingual backgrounds of their scientist and mountaineer authors. To build a high-quality searchable corpus, researchers needed to automatically detect intra-sentential code-switching to apply appropriate linguistic tools to specific fragments.

Methodology

The proposed multi-stage detection strategy leverages a common NLP "bug" as a feature:

  1. Sentence-Level Identification: Lingua-Ident determines the primary language of sentences longer than 40 characters.
  2. The "Unknown Lemma" Trigger: The system identifies sequences of words inside quotation marks that the standard PoS tagger fails to recognize (assigning an "unknown" lemma).
  3. Length Filtering: To minimize noise, only candidate fragments longer than 15 characters are considered.
  4. Verification: Candidate fragments are processed via Langid.py. If the predicted language differs from the sentence's primary language, it is flagged as a code-switch.
  5. Annotation: Detected switches are wrapped in TEI-conformant <foreign> tags.

Results and Analysis

The system was evaluated on a subset of 10 yearbooks from two distinct periods (1868–1878 and 1926–1935).

Performance of the code-switching detection pipeline across two historical periods.

The pipeline achieved 78% precision in identifying both the switch and the correct language label. When considering only the detection of a switch (regardless of label accuracy), precision rose to 92%. However, the 15-character threshold results in a recall trade-off, missing approximately 31% of actual code-switches, which are often short geographic names or brief phrases.

The data reveals a clear cultural shift in linguistic influence. In the 19th-century sample, only 9% of German code-switches were into English. By the 1920s and 30s, this figure rose to 23%, reflecting the growing global status of English.

Breakdown of correctly identified language switches by sentence and segment language.

The researchers also observed a "One-Code-Switch-Language-per-Discourse" pattern: within a single article, authors rarely switch into more than one foreign language. If an article is in German and contains an English quote, subsequent switches are highly likely to also be English.

Limitations and Future Work

The current reliance on quotation marks as a primary trigger misses code-switches delimited by parentheses or commas. Additionally, the system faces challenges with Swiss German dialects and Romansh due to a lack of robust training data. Future improvements may involve using parallel translated versions of the yearbooks to "triangulate" code-switches by identifying phrases that remain identical across different language versions of the same article.

Summary updated

BibTeX
@inproceedings{volk2014detecting,
  author = {Martin Volk and Simon Clematide},
  title = {{Detecting Code-Switching in a Multilingual Alpine Heritage Corpus}},
  booktitle = {CodeSwitch @ EMNLP},
  year = {2014},
  url = {https://openreview.net/forum?id=5lUVyQ4TXj},
}
Figure