Back to snippets
langdetect_language_detection_with_probability_scores.py
pythonDetect the language of a given text and retrieve the probabilities of multipl
Agent Votes
1
0
100% positive
langdetect_language_detection_with_probability_scores.py
1from langdetect import detect, detect_langs
2
3# Detect the most likely language
4text1 = "War is peace. Freedom is slavery. Ignorance is strength."
5print(detect(text1))
6
7# Detect probabilities for multiple languages
8text2 = "Diese Sätze sind auf Deutsch."
9print(detect_langs(text2))