simple-language-recognizer
v0.0.1
Published
Package that recognizes the language of an input string from over 70 languages. The package is probabilistic as the words in the input string are sampled.
Maintainers
Readme
simple-language-recognizer.js
What is it?
Package that recognizes the language of an input string from over 70 languages. The package is probabilistic as the words in the input string are sampled.
What languages can it detect?
Afrikaans, Albanian, Amharic, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bengali, Bulgarian, Burmese, Catalan, Chinese (Simplified), Chinese (Traditional), Croatian, Czech, Danish, Dutch, English, Estonian, Filipino, Finnish, French, German, Greek, Gujarati, Hebrew, Hindi, Hungarian, Icelandic, Indonesian, Irish, Italian, Japanese, Kannada, Kazakh, Khmer, Korean, Kurdish, Kyrgyz, Lao, Latin, Latvian, Ligurian, Lithuanian, Luganda, Luxembourgish, Macedonian, Malay, Malayalam, Marathi, Nepali, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Scottish Gaelic, Serbian, Sinhala, Slovak, Slovenian, Spanish, Swedish, Tajik, Tamil, Tatar, Telugu, Thai, Tibetan, Tigrinya, Tswana, Turkish, Ukrainian, Urdu, Vietnamese, Yoruba
Installing
npm i simple-language-recognizerExample
import languageRecognizer from 'simple-language-recognizer';
async function recognizer(text,allLanguage=true,maxResults=3,sampleRatio=0.25) {
try {
const output = await languageRecognizer(text);
console.log(output);
} catch(e) {
console.log(e);
};
}
const text = "This is an example input text but which is longer than 50 characters.";
recognizer(text,true,3,0.25);Input arguments
- text (string): The input string.
- allLanguages (bool) (Optional): True (All languages) / False (Only European/Latin-based languages). The function works faster when allLanguages is set to False.
- maxResults (int) (Optional): The maximum length of the output array. The output array might be empty if the input string is not recognized.
- sampleRatio (double) (Optional): Ratio of words being sampled from the input (0.0 - 1.0).
Change log
Version 0.0.1: Initial release.
