What's the best way to detect the language of a string?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
CLD (Compact Language Detector) library from Google's Chromium browser
You could wrap the CLD library, which is written in C++
http://code.google.com/p/chromium-compact-language-detector/
If the context of your code have internet access, you can try to use the Google API for language detection. http://code.google.com/apis/ajaxlanguage/documentation/
And, since you are using c#, take a look at this article on how to call the API from c#.
UPDATE: That c# link is gone, here's a cached copy of the core of it:
Basically, you need to create a URI and send it to Google that looks like:
This tells the API that you want to translate "hello world" from English to Hebrew, to which Google's JSON response would look like:
I chose to make a base class that represents a typical Google JSON response:
Then, a Translation object that inherits from this class:
This Translation class has a TranslationResponseData object that looks like this:
Finally, we can make the GoogleTranslator class: