Skip to content

detectlanguage/detectlanguage-python

Repository files navigation

Detect Language API Python Client

PyPI version Build Status

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

Installation

pip install detectlanguage

Upgrading

When upgrading please check changelog for breaking changes.

Configuration

import detectlanguage

detectlanguage.configuration.api_key = "YOUR API KEY"

# You can use proxy if needed
# detectlanguage.configuration.proxies = {'https': 'https://user:pass@proxy:8080'}

Usage

Detect language

detectlanguage.detect("Dolce far niente")

Result

[{'language': 'it', 'score': 0.5074}]

Detect single code

If you need just a language code you can use detect_code.

detectlanguage.detect_code("Dolce far niente")

Result

'it'

Batch detection

It is possible to detect language of several texts with one request. This method is faster than doing one request per text.

detectlanguage.detect_batch(["Dolce far niente", "Hello world"])

Result

Result is array of detections in the same order as the texts were passed.

[[{'language': 'it', 'score': 0.5074}], [{'language': 'en', 'score': 0.9098}]]

Get your account status

detectlanguage.account_status()

Result

{ 'status': 'ACTIVE', 'daily_requests_limit': 5000, 'daily_bytes_limit': 1048576,
  'bytes': 3151, 'plan': 'FREE', 'date': '2014-03-29', 'requests': 263,
  'plan_expires': None }

Get list of supported languages

detectlanguage.languages()

Result

[{'code': 'aa', 'name': 'Afar'}, {'code': 'ab', 'name': 'Abkhazian'}, ...]

License

Detect Language API Python Client is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.

About

Detect Language API Python Client

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages