How to determine the language of text in your application.

This API also can help you to recognize the language and encoding of text in a binary form.

var languageIdentifier = new LanguageIdentifier(); 
IEnumerable<string, double> languages = languageIdentifier.ClassifyText(“Any piece of text language of which you would like to know”).ToList(); 
var mostCertainLanguage = languages.FirstOrDefault(); 
if (mostCertainLanguage != null)  
    Console.WriteLine("Language of text is {0} with uncertainty {1}", mostCertainLanguage.Item1, mostCertainLanguage.Item2);  
else 
    Console.WriteLine("Language couldn’t be identified with acceptable degree of certainty");

Last edited Jun 7, 2013 at 10:00 PM by IvanAkcheurov, version 11

Comments

IvanAkcheurov Jun 7, 2013 at 2:16 PM 
Updated the code

IvanAkcheurov Mar 4, 2012 at 3:30 PM 
Hi guys,
The best example exists right now is method Main from Program.cs from project NTextCatLegacy from sources:
http://ntextcat.codeplex.com/SourceControl/changeset/view/15260#36107
It should always compile and work.

Anilca, if you still cannot resolve your problem, please start discussion and put exact error messages you get and your piece of code:
http://ntextcat.codeplex.com/discussions/create

paritoshmmmec Feb 29, 2012 at 6:13 AM 
also when running the application please include the LM folder in build.

Please let me know if you face problem again

paritoshmmmec Feb 29, 2012 at 6:12 AM 
try this code

var languageIdentifier = new LanguageIdentifier();
var languages =
languageIdentifier.ClassifyText("Any piece of text language of which you would like to know",null).ToList();
var mostCertainLanguage = languages.FirstOrDefault();
if (mostCertainLanguage != null)
Console.WriteLine("Language of text is {0} with uncertainty {1}", mostCertainLanguage.Item1, mostCertainLanguage.Item2);
else
Console.WriteLine("Language couldn’t be identified with acceptable degree of certainty");

anilca Sep 23, 2011 at 3:15 PM 
This code does not compiling?