Hostname: page-component-74656f9884-kv2lp Total loading time: 0 Render date: 2026-11-06T06:09:29.807Z Has data issue: false hasContentIssue false

Compression versus traditional machine learning classifiers to detect code-switching in varieties and dialects: Arabic as a case study

Published online by Cambridge University Press:  05 May 2020

Taghreed Tarmom
Affiliation:
School of Computing, University of Leeds, Leeds, UK
William Teahan
Affiliation:
School of Computer Science and Electronic Engineering, Bangor University, Bangor, UK
Eric Atwell*
Affiliation:
School of Computing, University of Leeds, Leeds, UK
Mohammad Ammar Alsalka
Affiliation:
School of Computing, University of Leeds, Leeds, UK
*
*Corresponding author. E-mail: E.S.Atwell@leeds.ac.uk
Rights & Permissions [Opens in a new window]

Abstract

The occurrence of code-switching in online communication, when a writer switches among multiple languages, presents a challenge for natural language processing tools, since they are designed for texts written in a single language. To answer the challenge, this paper presents detailed research on ways to detect code-switching in Arabic text automatically. We compare the prediction by partial matching (PPM) compression-based classifier, implemented in Tawa, and a traditional machine learning classifier sequential minimal optimization (SMO), implemented in Waikato Environment for Knowledge Analysis, working specifically on Arabic text taken from Facebook. Three experiments were conducted in order to: (1) detect code-switching among the Egyptian dialect and English; (2) detect code-switching among the Egyptian dialect, the Saudi dialect, and English; and (3) detect code-switching among the Egyptian dialect, the Saudi dialect, Modern Standard Arabic (MSA), and English. Our experiments showed that PPM achieved a higher accuracy rate than SMO with 99.8% versus 97.5% in the first experiment and 97.8% versus 80.7% in the second. In the third experiment, PPM achieved a lower accuracy rate than SMO with 53.2% versus 60.2%. Code-switching between Egyptian Arabic and English text is easiest to detect because Arabic and English are generally written in different character sets. It is more difficult to distinguish between Arabic dialects and MSA as these use the same character set, and most users of Arabic, especially Saudis and Egyptians, frequently mix MSA with their dialects. We also note that the MSA corpus used for training the MSA model may not represent MSA Facebook text well, being built from news websites. This paper also describes in detail the new Arabic corpora created for this research and our experiments.

Figure 0

Table 1. Summary of our corpora produced for this research

Figure 1

Figure 1. Most popular social network platforms in Saudi Arabia 2018 (in millions; Global Media Insight Website 2019).

Figure 2

Figure 2. A sample from the BAEC corpus.

Figure 3

Figure 3. A map of Saudi Arabia showing the locations of the dialects (based on Al-Moghrabi 2015).

Figure 4

Table 2. The top 10 most frequent words from the EDC and from the SDC

Figure 5

Table 3. Confusion matrix for two classes

Figure 6

Table 4. The results of the first experiment

Figure 7

Figure 4. Sample output from the first experiment’s output using PPM.

Figure 8

Table 5. The results of the second experiment

Figure 9

Figure 5. An example of confusion between the Saudi and Egyptian dialects from the second experiment’s output using PPM.

Figure 10

Table 6. The results of the third experiment

Figure 11

Figure 6. Sample of some Egyptian dialect sentences predicted as MSA from the third experiment’s output using PPM.

Figure 12

Table 7. Minimum code lengths for different models