using LanguageDetection;
LanguageDetector ld = new LanguageDetector();
ld.AddAllLanguages();
string dasdfas = "????????";
string lanCode = ld.Detect(dasdfas);
// string languageNaturalName = ld.Detect(lanCode); //returns "English" for language code "en"
Console.WriteLine(lanCode);
Console.ReadLine();
Iam using this code but it shows only english language
Tuhin PaulPosted Feb 2, 2024, 2:26 PM
1. Check Language Support:
Check that the library you're using supports the languages you are testing. Some libraries may have limited language support.
2. Check Text Input:
Make sure that the input text (dasdfas in your case) contains a sufficient amount of text for accurate language detection. Very short or ambiguous text might lead to less accurate results.
3. Library Configuration:
Check if the library has any configuration options that you can adjust. Some libraries may have settings related to language models or confidence thresholds.
4.Review Documentation:
Read the documentation of the LanguageDetection library to see if there are any specific guidelines or recommendations for usage.
5.Explore Alternative Libraries:
If you continue to face issues, you might want to explore alternative language detection libraries. Libraries like LangDetectSharp, TextCat, or CLD2 are commonly used for language detection.
Sachin SinghPosted Feb 1, 2024, 6:43 AM
Jithu ThomasPosted Jan 31, 2024, 5:44 PM
Hi,
Please follow this code and it is working: -
Output: -
Please accept the answer if you found the same is useful!
SriPosted Jan 31, 2024, 3:32 PM
HI Srikanth,
i tried your code,tested with 2 languages.it is working and returning relative language code (used LanguageDetection.NETStandard lib)
using LanguageDetection;
LanguageDetector ld = new LanguageDetector();
ld.AddAllLanguages();
string dasdfas = "???? ??? ???? ??";
string lanCode = ld.Detect(dasdfas);
Console.WriteLine(lanCode);//output : hin
Console.ReadLine();
Srikanth VankayalapatiPosted Jan 31, 2024, 8:08 AM
Hi Jithu Thomas,
Thanks for your reply.
When i have give text like hindi, chinies, japanies text its shows null result.
Thanks
Srikanth
Jithu ThomasPosted Jan 31, 2024, 7:32 AM
To improve the accuracy of language detection, you should use a more representative text that includes actual words and phrases from the language you want to detect. For example:
Replace the
sampleTextwith a more typical text for the languages you are interested in detecting. This should yield more accurate results. Keep in mind that no language detection library is perfect, and the accuracy may vary depending on the quality and length of the input text.