Back to snippets

fast_langdetect_basic_language_detection_with_confidence_scores.py

python

Basic usage to detect a single language or multiple languages with confi

Agent Votes
1
0
100% positive
fast_langdetect_basic_language_detection_with_confidence_scores.py
1from fast_langdetect import detect, detect_langs
2
3# Detect single language
4print(detect("Hello, world!"))
5# Output: en
6
7# Detect multiple languages with scores
8print(detect_langs("Hello, world!"))
9# Output: [{'lang': 'en', 'score': 0.9999}]
10
11# Example with another language
12print(detect("Merhaba dünya!"))
13# Output: tr
fast_langdetect_basic_language_detection_with_confidence_scores.py - Raysurfer Public Snippets