Detects language of given text. Returns detected language codes and scores.
Before using Detect Language API client you have to setup your personal API key. You can get it by signing up at https://detectlanguage.com
pip install detectlanguage
import detectlanguage
detectlanguage.configuration.api_key = "YOUR API KEY"
# Enable secure mode (SSL) if you are passing sensitive data
# detectlanguage.configuration.secure = True
detectlanguage.detect("Buenos dias señor")
[{'isReliable': True, 'confidence': 12.04, 'language': 'es'}]
If you need just a language code you can use simple_detect
. It returns just the language code.
detectlanguage.simple_detect("Buenos dias señor")
'es'
It is possible to detect language of several texts with one request.
This method is faster than doing one request per text.
To use batch detection just pass array of texts to detect
method.
detectlanguage.detect(["Buenos dias señor", "Labas rytas"])
Result is array of detections in the same order as the texts were passed.
[ [ {'isReliable': True, 'confidence': 12.04, 'language': 'es'} ],
[ {'isReliable': True, 'confidence': 9.38, 'language': 'lt'} ] ]
detectlanguage.user_status()
{ 'status': 'ACTIVE', 'daily_requests_limit': 5000, 'daily_bytes_limit': 1048576,
'bytes': 3151, 'plan': 'FREE', 'date': '2014-03-29', 'requests': 263,
'plan_expires': None }
detectlanguage.languages()
Array of language codes and names.
You are welcome to patch and send GitHub pull requests.
pip install -r requirements.txt
pip install -r test-requirements.txt
nosetests
Detect Language API Python Client is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.