Language Identification via Compositional Data Analysis: A Linear-Time Classifier Based on Log-Ratio Geometry
This paper proposes a computationally efficient, linear-time language identification classifier that models character and bigram frequencies as compositional data using centered log-ratio (CLR) transformations and Laplace smoothing, achieving robust accuracy while offering a deterministic and interpretable alternative to resource-intensive neural architectures.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are a detective trying to solve a mystery, but instead of fingerprints or footprints, your clues are the tiny, invisible patterns of letters in a sentence. This is the world of language identification, a crucial step in computer science that helps machines figure out if a block of text is written in English, French, or perhaps a secret code. For a long time, computers have tried to solve this in two main ways. The first way is like hiring a super-smart, but very expensive and hungry, robot that needs massive amounts of electricity and memory to read every word and guess the language. The second way is like using a simple tally sheet, counting how often the letter "e" or "t" appears. While the tally sheet is fast and cheap, it has a tricky flaw: it treats language like a bag of marbles where the total number of marbles can change, but in reality, language is more like a pie chart where all the slices must always add up to exactly 100%. If you try to measure the distance between two pie charts using a standard ruler, you get confused results because the slices are all tied together. This paper asks: Can we fix the simple, fast tally sheet so it respects the "pie chart" rules, making it both quick and incredibly accurate without needing a supercomputer?
The authors of this paper, Paul-Andrei Pog˘acean and Sanda-Maria Avram, say yes. They propose a clever new method that treats language frequencies not just as simple numbers, but as compositional data—a fancy way of saying "parts of a whole that must sum to unity." To fix the "ruler" problem, they use a mathematical magic trick called the Centered Log-Ratio (CLR) transformation. Imagine you have a pie chart where the slices are stuck together; this transformation is like carefully cutting the pie and laying it flat on a table so you can measure the distance between slices without them pulling on each other. By doing this, they can use standard, fast math (Euclidean distance) to compare languages, but the math now respects the unique geometry of language.
Their approach is a "deterministic" classifier, which means it doesn't learn or guess based on training data like a neural network; it follows a strict set of rules. They built a pipeline that counts single letters (unigrams) and pairs of letters (bigrams), smooths out the data to handle missing pieces, and then applies their special geometric transformation. They tested this on six languages: English, German, Turkish, Romanian, Hungarian, and Dutch. The results are striking. For short texts (under 50 characters), their method achieves about 84.0% accuracy. As the text gets longer, the accuracy climbs steadily, hitting 95.6% for medium-length texts and a perfect 100.0% for sequences longer than 150 characters.
What makes this particularly interesting is what the paper argues against. The authors explicitly reject the idea that you need massive, expensive neural networks (which take quadratic time, or ) to get good results. They also show that simply using standard distance measurements on raw frequency data (like the raw Euclidean distance) leads to poor results, especially for short texts, because it ignores the "pie chart" constraint. Their method, which runs in linear time (), is much faster and requires far less computing power, making it perfect for small devices like phones or edge hardware.
However, the paper is careful to note where this method hits a wall. It works best for languages that use alphabetic systems (like the Latin alphabet). It struggles with "code-switching," where a single sentence mixes two languages, because the math assumes the text belongs to just one "pie." It also hasn't been tested on non-alphabetic systems like Chinese characters or Arabic script, where the rules for counting "letters" are totally different. But for the languages they tested, the method suggests that by respecting the geometry of language, we can build a language detector that is both lightning-fast and incredibly precise, offering a transparent, explainable alternative to the "black box" of deep learning. In short, they found that sometimes, the best way to understand a language isn't to build a bigger brain, but to measure the existing patterns with a better ruler.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.