Answer the question
In order to leave comments, you need to log in
How to determine the language of a written message in discord.js?
Hello. I need help with a JavaScript discord bot. I need to detect the language/and the user's written message. That is, a person sends a message (for example: "hello hello") and the bot must determine the language / and send a message ("this is a Russian word, this is an English word")
Answer the question
In order to leave comments, you need to log in
If you need to determine the language of the text, then look towards language identification, for example, there is a fasttext library, and here is the first implementation example on js https://github.com/rse/fasttext-lid (but I saw others in Google, I don't know which is better).
If you need to determine the language of specific words, then it may be interesting to use stemmers for the desired languages and then check for the presence of a word in the dictionary for this language. Or iterate through the entire dictionary, taking into account the Levenshtein distance or other text metrics.
In general, this is not the most trivial task.
"hello hello" what language is this? )) if you need to determine if a string contains Russian text, then text.test(/[a-zA-Z]+/)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question