Spelling correctors for scripts like Chinese work because they know which characters sound or look alike. A wrong character that is still a real character fits its context, so the corrector needs a prior saying "this character is often confused with that one." Bilingual writers create a separate problem. They often build a single word from two languages, as when Egyptian Arabic speakers attach the Arabic prefix bi- to an English verb stem, or Turkish-German speakers attach Turkish case endings to German nouns. This is called intra-word code-switching. These hybrid words appear in no dictionary, so a corrector tends to "fix" them into something monolingual. When a real typo does land inside such a word, the corrector cannot tell which notion of "similar characters" to apply. A dotted-letter confusion matters in the Arabic prefix. A keyboard or sound confusion matters in the English stem.
We propose a corrector that first estimates, character by character, which language each part of a word belongs to, and then uses that estimate to choose and weight the character-similarity prior that guides correction. We make two predictions. Correct hybrid words will be changed far less often. Real substitutions inside guest stems will be caught more often, because each stem is judged against the confusion patterns of its own language rather than one pooled table.
Core Claim
Character-similarity priors should depend on language at the level of the morpheme, not the sentence. Concretely, take a base character-level corrector and its candidate distribution at position $i$. We rescore each candidate character $c$ for observed character $x_i$ as
$$s_i(c) = \log p_{\text{LM}}(c \mid \text{context}) + \sum_{l} q_i(l)\,\alpha_l\,\mathrm{sim}_l(x_i, c),$$
where $p_{\text{LM}}$ is the base corrector's probability, $q_i(l)$ is a predicted probability that position $i$ belongs to language $l$, $\mathrm{sim}_l$ is a phonetic-plus-visual similarity defined for language $l$'s script and sound system, and $\alpha_l$ is a per-language weight tuned on development data. Two things are new. The first is that the similarity is routed per morpheme. The second is that the strength of the prior is soft-gated by language uncertainty. When $q_i$ puts all its mass on one language, the formula reduces to the existing decoding method DISC. The gain, if any, has to come from the hybrid regions.
Where This Sits
The mechanism comes from Chinese spelling correction. SpellGCN ties BERT's output classifiers together through graphs of sound-alike and look-alike characters. REALISE adds Pinyin and glyph-image encoders and gates between them. DISC needs no training: it adds a weighted similarity score at decoding time, and with the ReLM corrector it lowers the false positive rate on SIGHAN15 from 12.7% to 9.5%. We reuse DISC's additive rescoring because it is cheap and leaves the base model untouched. All three methods assume one language and one similarity space, with Pinyin edit distance at its core. That assumption is exactly what fails inside hybrid words.
The language-boundary component comes from intra-word code-switching research. Mager et al. segment hybrid words and label each segment's language jointly, reaching 68.5 segmentation F1 against 58.5 for a pipeline on Spanish–Wixarika. LIDVec injects language-ID embeddings into XLM-R and raises morphological tagging accuracy on Turkish-German MIXED tokens from 61.75% to 73.22%. Both assume clean spelling. We use their segmenters to produce $q_i$, and we test whether a typo corrupts that estimate.
Two papers motivate the work by showing the gap directly. Weisberg Mitelman et al. detect Arabic prefixes on Hebrew stems in Judeo-Arabic and transliterate them, reaching 1.40% label error rate on the Kuzari text. They report failures on visually similar output letters such as ؤ versus ئ, and they explicitly lack a correction module. Zhang et al. correct code-switched Mandarin-English speech recognition output using audio features. Their method works between words, needs the audio, and has no visual channel. Garley et al. supply the failure mode we target: tools misread nativized loan forms as misspellings of native words.
Gaser et al. constrain the design. They show that exact morphological segmentation does not automatically help downstream models. We therefore use soft language posteriors rather than hard morpheme splits.
Research Program
We build per-language similarity functions for four script and language combinations.
For Arabic script, we use rasm-skeleton identity, where the rasm is the letter shape with its dots removed, plus dot-count differences and hamza-seat variants. For Hebrew script carrying Arabic or Hebrew, we use classic visual pairs such as ד/ר, ה/ח, and ו/י, plus the Arabic-in-Hebrew mapping ambiguities. For Latin-script English stems in Egyptian text, we use keyboard adjacency and grapheme-to-phoneme edit distance. For Turkish and German, we use diacritic pairs (ı/i, ş/s, ü/u) and phonetic distance.
Each function mixes a phonetic term and a visual term with a mixing weight tuned on development data, following DISC's finding that weighting phonetics more heavily (β = 0.7) works for Chinese. We do not assume that weighting transfers to these languages.
We train subword language identifiers on the available boundary annotations: the SAGT treebank, Mager et al.'s German–Turkish and Spanish–Wixarika data, ArzEnSEG, and Friedberg Judeo-Arabic prefix labels. We then plug the rescoring into three base correctors: a character model in the style of HeArBERT for Judeo-Arabic, and XLM-R and a byte-level sequence model for the other languages.
Evaluation needs two kinds of data. The first is synthetic substitutions injected separately into host affixes, guest stems, and the seam between them, sampled from held-out confusion distributions that the similarity tables do not encode. The second is real errors. We will annotate about two thousand hybrid tokens from informal German–Turkish tweets and ArzEn transcripts, and we will use the Kuzari transliteration setting, where the visual ambiguities occur naturally. We also run on SIGHAN15 to confirm the method reduces to DISC on monolingual text.
Baselines
The naive reference point is the base corrector with no similarity prior, decoded greedily. It shows how much any prior helps.
The strongest existing method is DISC applied with a single similarity table that pools the confusion pairs of both languages in each pair. This is the obvious port of DISC to code-switched text. It uses the same base model, the same candidate set, and the same similarity resources as our method, so it is the fairest test of whether language routing matters. Its only reported number is on Chinese: false positive rate falling from 12.7% to 9.5% on SIGHAN15 with ReLM. No reported result was found on Lacuna for any spelling corrector on code-switched hybrid words. For Judeo-Arabic transliteration, the reference is the 1.40% Kuzari label error rate of Weisberg Mitelman et al..
The strongest learned competitor is the same base model fine-tuned on synthetic noisy code-switched text generated from our own similarity tables. It therefore has every piece of knowledge our decoder has.
Two ablations isolate the key ingredient. The first replaces the predicted $q_i$ with uniform weights, which tests whether routing matters at all. The second replaces it with gold language labels, which sets an upper bound and measures how much language-identification error costs.
All systems receive the same training data, and the same number of tuning trials on development data for $\alpha_l$, the phonetic-visual weights, or fine-tuning hyperparameters. To count as beating the pooled-table DISC baseline, our method must lower the false positive rate on clean hybrid tokens by a margin outside bootstrap confidence intervals while not losing correction F1 on corrupted guest stems. On monolingual Chinese, it must stay within noise of DISC.
Why not just…?
Why not just fine-tune a multilingual or byte-level model on synthetic noisy code-switched text? This is the real threat. A byte-level model given enough corrupted hybrid words could learn implicitly which confusions apply where. Prior results point the other way without settling it. On SIGHAN15, plain BERT reaches 73.0% correction F1 against SpellGCN's 75.9% (SpellGCN), and XLM-R alone handles MIXED tokens poorly (LIDVec). Neither result involves typos inside hybrid words, though. Our fine-tuned baseline uses exactly the tables our decoder uses. The held-out confusion distributions and the real-error test sets then show whether explicit routing generalizes where fine-tuning memorizes. If the fine-tuned model matches us on real errors, we will report that routing is unnecessary. We will also test our decoder on top of the fine-tuned model, since the two approaches can be combined.
Why not just run language ID first and send each segment to a monolingual corrector? Hard pipelines spread early mistakes downstream. Mager et al. lose ten F1 points to a pipeline, and LIDVec's hard-split variant underperforms its embedding variant. A typo can also flip the language decision, so the wrong corrector receives the segment. We run this pipeline as a baseline and report it separately for tokens whose language prediction changed under corruption. That subset is where the soft gating should matter most.
Why not just use one pooled confusion table? This is the pooled-table DISC baseline above. Our concern is that pooling lets English keyboard confusions "correct" Arabic prefixes and vice versa, raising false positives on valid hybrid words. If pooling performs as well, the per-morpheme claim is false. The uniform-$q_i$ ablation answers the same question within our own system.
Decisive Checks
The central test splits results by position in the word: host affix, guest stem, and seam. Each result is reported as correction F1 and as false positive rate on clean tokens. Our prediction is specific: gains over pooled-table DISC should come almost entirely from guest stems and from clean hybrid tokens, with no change on purely monolingual tokens. If gains are spread evenly, or appear on monolingual tokens, the improvement comes from extra tuning rather than routing.
A second check measures how much language-ID accuracy drops when input is corrupted, and how much of the gap between gold and predicted $q_i$ that drop explains.
A third check uses Kuzari transliteration. Rescoring the output side with a Hebrew-to-Arabic visual similarity should specifically reduce ؤ/ئ-type errors below the 1.40% label error rate baseline. This error category was named as unsolved by the original authors.
References
- SpellGCN: Incorporating Phonological and Visual Similarities into Language Models for Chinese Spelling Check
- Read, Listen, and See: Leveraging Multimodal Information Helps Chinese Spell Checking
- DISC: Plug-and-Play Decoding Intervention with Similarity of Characters for Chinese Spelling Check
- Subword-Level Language Identification for Intra-Word Code-Switching
- A Language-aware Approach to Code-switched Morphological Tagging
- Code-Switching and Back-Transliteration Using a Bilingual Model
- End-to-End Spelling Correction Conditioned on Acoustic Feature for Code-Switching Speech Recognition
- Beefmoves: Dissemination, Diversity, and Dynamics of English Borrowings in a German Hip Hop Forum
- Exploring Segmentation Approaches for Neural Machine Translation of Code-Switched Egyptian Arabic-English Text