Language Identification
Given a text, determine the Natural Language it is written in.
Method
Build a Trigram Model
P(ci∣ci−2:i−1,ℓ)
for every language ℓ.
Apply Bayes Rule and the Markov Property to get the most likely language
ℓ∗=ℓargmax(P(ℓ∣c1:N))=ℓargmax(P(ℓ)⋅P(c1:N∣ℓ))=ℓargmax(P(ℓ)⋅i=1∏NP(ci∣ci−2:i−1,ℓ))
The Prior Probability of the language is not a critical factor.
Intuition
When l is not the correct language all probabilities of character sequences ci−2:i will be low. For the correct language they will be a lot higher.