WhatLang is a Python library for detecting the language of a text. It is based on the WhatLang Rust library.
Installation
pip install whatlang-pyo3
Usage
Detect
>>> from whatlang import detect
>>> info = detect("This is written in English")
"Language: eng - Script: Latin - Confidence: 0.11450955767632877 - Is reliable: false"
>>> info.lang
"eng"
>>> info.script
"Latin"
>>> info.confidence
0.11450955767632877
>>> info.is_reliable
False
>>> info.to_iso()
"Language: en - Script: Latin - Confidence: 0.11450955767632877 - Is reliable: false"
Detect language
You can also detect the language of a text without the script and the confidence.
>>> from whatlang import detect_lang
>>> detect_lang("This is written in English")
"eng"
>>> detect_lang("Ceci est écrit en français")
"fra"
>>> detect_lang("Ceci est écrit en français").iso
"fr"
Detect script
You can also detect the script of a text without the language and the confidence.
>>> from whatlang import detect_script
>>> detect_script("This is written in English")
Name: Latin - Languages: spa, eng, por, ind, fra, deu, jav, vie, ita, tur, pol, ron, hrv, nld, uzb, hun, aze, ces, zul, swe, aka, sna, afr, fin, slk, tgl, tuk, dan, nob, cat, lit, slv, epo, lav, est, lat
>>> detect_script.name
"Latin"
>>> detect_script.langs
['spa', 'eng', 'por', 'ind', 'fra', 'deu', 'jav', 'vie', 'ita', 'tur', 'pol', 'ron', 'hrv', 'nld', 'uzb', 'hun', 'aze', 'ces', 'zul', 'swe', 'aka', 'sna', 'afr', 'fin', 'slk', 'tgl', 'tuk', 'dan', 'nob', 'cat', 'lit', 'slv', 'epo', 'lav', 'est', 'lat']
Batch detection
You can also detect the language of a list of texts, and take advantage of the parallelism with the n_jobs parameter.
>>> from whatlang import batch_detect
>>> batch_detect(["This is written in English", "Ceci est écrit en français"], n_jobs=-1)
[LanguageInfo(lang='eng', script='Latin', confidence=0.11450955767632877, is_reliable=False), LanguageInfo(lang='fra', script='Latin', confidence=0.11450955767632877, is_reliable=False)]
The performance of the batch detection is much better than the detection of a single text, it can be up to 5 times faster.
Contributing
Contributions are welcome! Please open an issue or a pull request.
Install maturin
We use maturin for the development of this library.
pip install maturin
Build
maturin build --release
License
This project is licensed under the MIT License - see the LICENSE file for details
Metadata
Release files for whatlang-pyo3 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| whatlang_pyo3-0.6.0.tar.gz | 3.3 MB | Details |
Built distributions (wheels)
Total release size: 25.2 MB
Release files / whatlang_pyo3-0.6.0.tar.gz
| Download URL | whatlang_pyo3-0.6.0.tar.gz |
|---|---|
| Size | 3.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f2dd45d1f50999d2242af47fd80adfc14af0da4798a4d2adc250c038a4f8ca1
|
|
BLAKE2b-256 checksum How to use checksums |
8bf931aa73257f6f125eb59e1ff8ed95f062b9de7c1432d2248cddcc6ad5c876
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.10 PyPy 3.10 7.3 |
|
SHA-256 checksum How to use checksums |
ec56986e9f9df65a99e61607fbc1c53ede3b841b748bacea49e8f1348c1489d6
|
|
BLAKE2b-256 checksum How to use checksums |
716923b27c873b869f76f06bc4b1bc06b24b1d5798e9020cf7be85179dada621
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
4784a16eac7419cdcae08e223bae951906678529a27c0deabd7c25330371c455
|
|
BLAKE2b-256 checksum How to use checksums |
d6cda429873ed93678ba531ce91f5cbe78373772f50db0bcc7782041c7eff1b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.8 PyPy 3.8 7.3 |
|
SHA-256 checksum How to use checksums |
c47f5d373f081d6316db964e37aec99653d6c1d65a3fef284a75174a24d87c03
|
|
BLAKE2b-256 checksum How to use checksums |
b007d2549479fa6f9de9a52759881c5a97ff9fdafcf8a4b6f83d06a45d370806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.7 PyPy 3.7 7.3 |
|
SHA-256 checksum How to use checksums |
9097d5cabff20e6fecc028e3b075812b8777b1e06bd7b9aa31d38e8751ef0528
|
|
BLAKE2b-256 checksum How to use checksums |
9fc8c6f52a7a10f91e8c46bf1e98baad0f71072ff2be1904d83fd384582c80f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp312-none-win_amd64.whl
| Download URL | whatlang_pyo3-0.6.0-cp312-none-win_amd64.whl |
|---|---|
| Size | 351.6 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5360175fa01f23bd74f3eb3a7dc30ad3c45f961bdcf5b847485bdd73aa984599
|
|
BLAKE2b-256 checksum How to use checksums |
52b9a59b2140bd953259dfdb85f78bda3cc4daf3654f940605d3684196ce9a63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
50b40dcd6d8159c31b444e51b3fd7822dbdaa5b27cee749b4bc8fe476dae755a
|
|
BLAKE2b-256 checksum How to use checksums |
e477dc7ec457150c2a600d13802ec18e41276107804a4ec4ceb4efe87a2dba99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | whatlang_pyo3-0.6.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.12 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ced36b35a754fc3fa493453b690940575fe8fc3377195973da1b72766254c682
|
|
BLAKE2b-256 checksum How to use checksums |
6f169c10163d6b49f3e3ab44f31259647ae48faff8f2da070c720c8a416144ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp311-none-win_amd64.whl
| Download URL | whatlang_pyo3-0.6.0-cp311-none-win_amd64.whl |
|---|---|
| Size | 351.6 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4038a9e23c9ca7f448f50750036251fc47d95ab1551ef17eac8989cd1625fff9
|
|
BLAKE2b-256 checksum How to use checksums |
b506cae1a41a0a1497064a93d3f601957ebd64b752dd985ff055994e6ce05a3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
aa6cabf81a9fa6efd30471f1f84124d05b7e4577a2f46d225ac4b501d239b92a
|
|
BLAKE2b-256 checksum How to use checksums |
20f8426675b2f6740c7a959132eeaa67b1726e3f1dbbefd41240c8516d175402
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | whatlang_pyo3-0.6.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.11 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
776652e7f6d6137ef1a1fc3a53f4b869909dd2981f8b81989a42d5b8e3fabf80
|
|
BLAKE2b-256 checksum How to use checksums |
63c9628ca7178cf7e6a2ae89fdcac9fd25b20ccb012789f72476c34b089d883f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp310-none-win_amd64.whl
| Download URL | whatlang_pyo3-0.6.0-cp310-none-win_amd64.whl |
|---|---|
| Size | 351.6 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
222260f5287e51221101ba36f47b4e1778ea576d8ef507cd0e970fd74ae1953c
|
|
BLAKE2b-256 checksum How to use checksums |
6d9cb1432038cdd449e8e72d33571c90b8bcea1f75e6b8f3f706b5110552368d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
760ba8984767ade5703f66523829e523711d22f30712e1bec900af243f8949c4
|
|
BLAKE2b-256 checksum How to use checksums |
ef8f52540ae06a270e4347aee781418736b0e5c977850b13a97acf04053b76ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | whatlang_pyo3-0.6.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.10 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0a97e82dacfcdc1aa03582314c93f3eaf5bafc474d95424cefe9318c009b8967
|
|
BLAKE2b-256 checksum How to use checksums |
042993a35aa5a6dd1b8fc15bba72cbb8498368c63fc84d34fb5ece433d45808e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp39-none-win_amd64.whl
| Download URL | whatlang_pyo3-0.6.0-cp39-none-win_amd64.whl |
|---|---|
| Size | 352.3 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
25a185d0cb28144e509f77751fea22d42db478732f68d4d44329d0ba4961f8ab
|
|
BLAKE2b-256 checksum How to use checksums |
cf7557e02c1337e1f54df6d4bb29648bbbd9d6c44fa4c4e2b06b6d85832d1243
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
937e16083a9a02d07c92831d73466c90e91ac8ac377121d646655a1696abe0f9
|
|
BLAKE2b-256 checksum How to use checksums |
f730d0fba6828ad82917d19f93ba7d218e372e08f5975d342ea21cbf2406c52b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | whatlang_pyo3-0.6.0-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.9 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7d3abe6406677849abe51574efc100298df1c5ad718bf81ec950d15c67c0621c
|
|
BLAKE2b-256 checksum How to use checksums |
f61afd67d6ece2effeb52c9243373e6f232989036f3900332cd953b54ebcb57b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp38-none-win_amd64.whl
| Download URL | whatlang_pyo3-0.6.0-cp38-none-win_amd64.whl |
|---|---|
| Size | 351.7 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e72ccff70e56339a6a7a84576dbb73337fa5fa2971f4e405e0ba934def165350
|
|
BLAKE2b-256 checksum How to use checksums |
cbdfe5fc438fae8fad34e0a44ad0c60b01f9e652d7f7523adc8abf245f69e840
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
bdb256416dfce21c0f4b86da3d3d3bf2805e61b70af19bad39f21699c0927b54
|
|
BLAKE2b-256 checksum How to use checksums |
9f9776ec6d5790c6b596ae2cf4fe3b513e09de9e3d482f86d8ca67ab11c8c9d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | whatlang_pyo3-0.6.0-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.8 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4e2e21932210a6a427fa2d09ae94c3d38f35de21cabb0510bf22c0dc426c71fd
|
|
BLAKE2b-256 checksum How to use checksums |
9c7470014cf7b375992ab06e2a506f9b030ae6225c36f9107a8ef8dc7ff79250
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp37-none-win_amd64.whl
| Download URL | whatlang_pyo3-0.6.0-cp37-none-win_amd64.whl |
|---|---|
| Size | 351.6 kB |
| Tags | CPython 3.7 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1f7b86f5fdd9ca2cc89c23028effec67d374c6ea4b350fbcdd00c88828865f6b
|
|
BLAKE2b-256 checksum How to use checksums |
fa791936a6b32e4d0f0ab18d372f1b9e987b18fb6cdd87cc36f20880b3012a78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | whatlang_pyo3-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3d3237f1a1bc075c8ff31f40c7241d3baf0ddd30a329909da72bdf291ca5ec56
|
|
BLAKE2b-256 checksum How to use checksums |
c4377dd2a5733fbd7e30df66b55fb8532f4f518b549a85e9e9ecf2dc912b30e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / whatlang_pyo3-0.6.0-cp37-cp37m-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | whatlang_pyo3-0.6.0-cp37-cp37m-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
802e61deb2986ca04546c16c535b2f3efe99635dcf2b2ccd4b8f38f1cc1e7257
|
|
BLAKE2b-256 checksum How to use checksums |
d729d613c68612f37d5ac98e15904327d02963df0b45ffdce624a4121fc98fe2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|