Python bindings for whatlang using pyo3
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for whatlang_pyo3-0.6.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec56986e9f9df65a99e61607fbc1c53ede3b841b748bacea49e8f1348c1489d6 |
|
MD5 | 6e148f1e684a23233ba105f54a9b512c |
|
BLAKE2b-256 | 716923b27c873b869f76f06bc4b1bc06b24b1d5798e9020cf7be85179dada621 |
Hashes for whatlang_pyo3-0.6.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4784a16eac7419cdcae08e223bae951906678529a27c0deabd7c25330371c455 |
|
MD5 | 102f3ea921c4974eebc5ed6cc892982f |
|
BLAKE2b-256 | d6cda429873ed93678ba531ce91f5cbe78373772f50db0bcc7782041c7eff1b9 |
Hashes for whatlang_pyo3-0.6.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c47f5d373f081d6316db964e37aec99653d6c1d65a3fef284a75174a24d87c03 |
|
MD5 | 58fda007c03502c2e2260ad90e1cd46f |
|
BLAKE2b-256 | b007d2549479fa6f9de9a52759881c5a97ff9fdafcf8a4b6f83d06a45d370806 |
Hashes for whatlang_pyo3-0.6.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9097d5cabff20e6fecc028e3b075812b8777b1e06bd7b9aa31d38e8751ef0528 |
|
MD5 | 18eba81e42196919f67ac258e1362030 |
|
BLAKE2b-256 | 9fc8c6f52a7a10f91e8c46bf1e98baad0f71072ff2be1904d83fd384582c80f2 |
Hashes for whatlang_pyo3-0.6.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5360175fa01f23bd74f3eb3a7dc30ad3c45f961bdcf5b847485bdd73aa984599 |
|
MD5 | d0dbbe5c792597084a54e4bc7e1fc5b2 |
|
BLAKE2b-256 | 52b9a59b2140bd953259dfdb85f78bda3cc4daf3654f940605d3684196ce9a63 |
Hashes for whatlang_pyo3-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50b40dcd6d8159c31b444e51b3fd7822dbdaa5b27cee749b4bc8fe476dae755a |
|
MD5 | 53c87adf692d732f0ad849de86ae9451 |
|
BLAKE2b-256 | e477dc7ec457150c2a600d13802ec18e41276107804a4ec4ceb4efe87a2dba99 |
Hashes for whatlang_pyo3-0.6.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ced36b35a754fc3fa493453b690940575fe8fc3377195973da1b72766254c682 |
|
MD5 | 90412da249eac09fb391b51d9b60e793 |
|
BLAKE2b-256 | 6f169c10163d6b49f3e3ab44f31259647ae48faff8f2da070c720c8a416144ff |
Hashes for whatlang_pyo3-0.6.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4038a9e23c9ca7f448f50750036251fc47d95ab1551ef17eac8989cd1625fff9 |
|
MD5 | b2d4c4a7d8b4402312973fc5eaf72082 |
|
BLAKE2b-256 | b506cae1a41a0a1497064a93d3f601957ebd64b752dd985ff055994e6ce05a3f |
Hashes for whatlang_pyo3-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa6cabf81a9fa6efd30471f1f84124d05b7e4577a2f46d225ac4b501d239b92a |
|
MD5 | 9df887ceb58d45ef1a7735bdd9398919 |
|
BLAKE2b-256 | 20f8426675b2f6740c7a959132eeaa67b1726e3f1dbbefd41240c8516d175402 |
Hashes for whatlang_pyo3-0.6.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 776652e7f6d6137ef1a1fc3a53f4b869909dd2981f8b81989a42d5b8e3fabf80 |
|
MD5 | 6a2dfc881fb15ac418c6f5ac9d0dc10b |
|
BLAKE2b-256 | 63c9628ca7178cf7e6a2ae89fdcac9fd25b20ccb012789f72476c34b089d883f |
Hashes for whatlang_pyo3-0.6.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 222260f5287e51221101ba36f47b4e1778ea576d8ef507cd0e970fd74ae1953c |
|
MD5 | 777819ee602c68061dc1d541f3bd549b |
|
BLAKE2b-256 | 6d9cb1432038cdd449e8e72d33571c90b8bcea1f75e6b8f3f706b5110552368d |
Hashes for whatlang_pyo3-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 760ba8984767ade5703f66523829e523711d22f30712e1bec900af243f8949c4 |
|
MD5 | ad2daf61b4454f5dc6cc429333b20700 |
|
BLAKE2b-256 | ef8f52540ae06a270e4347aee781418736b0e5c977850b13a97acf04053b76ca |
Hashes for whatlang_pyo3-0.6.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a97e82dacfcdc1aa03582314c93f3eaf5bafc474d95424cefe9318c009b8967 |
|
MD5 | 7a41f7f382be53041a20b3fefdf76be1 |
|
BLAKE2b-256 | 042993a35aa5a6dd1b8fc15bba72cbb8498368c63fc84d34fb5ece433d45808e |
Hashes for whatlang_pyo3-0.6.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25a185d0cb28144e509f77751fea22d42db478732f68d4d44329d0ba4961f8ab |
|
MD5 | 6e108d194d8278cc0090fceff7ed0bbb |
|
BLAKE2b-256 | cf7557e02c1337e1f54df6d4bb29648bbbd9d6c44fa4c4e2b06b6d85832d1243 |
Hashes for whatlang_pyo3-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 937e16083a9a02d07c92831d73466c90e91ac8ac377121d646655a1696abe0f9 |
|
MD5 | ffb2e6764f07718f85dece4772eb4d17 |
|
BLAKE2b-256 | f730d0fba6828ad82917d19f93ba7d218e372e08f5975d342ea21cbf2406c52b |
Hashes for whatlang_pyo3-0.6.0-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d3abe6406677849abe51574efc100298df1c5ad718bf81ec950d15c67c0621c |
|
MD5 | 6c0cab6ab3891b0107df18c939e48f8e |
|
BLAKE2b-256 | f61afd67d6ece2effeb52c9243373e6f232989036f3900332cd953b54ebcb57b |
Hashes for whatlang_pyo3-0.6.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e72ccff70e56339a6a7a84576dbb73337fa5fa2971f4e405e0ba934def165350 |
|
MD5 | 4c348021884a26a4cceb1e514b4c127b |
|
BLAKE2b-256 | cbdfe5fc438fae8fad34e0a44ad0c60b01f9e652d7f7523adc8abf245f69e840 |
Hashes for whatlang_pyo3-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdb256416dfce21c0f4b86da3d3d3bf2805e61b70af19bad39f21699c0927b54 |
|
MD5 | bfb48a463e8f7fca624d771896ed95cf |
|
BLAKE2b-256 | 9f9776ec6d5790c6b596ae2cf4fe3b513e09de9e3d482f86d8ca67ab11c8c9d5 |
Hashes for whatlang_pyo3-0.6.0-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e2e21932210a6a427fa2d09ae94c3d38f35de21cabb0510bf22c0dc426c71fd |
|
MD5 | e66c4f0c56447d28c3b26cebaf6bc591 |
|
BLAKE2b-256 | 9c7470014cf7b375992ab06e2a506f9b030ae6225c36f9107a8ef8dc7ff79250 |
Hashes for whatlang_pyo3-0.6.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f7b86f5fdd9ca2cc89c23028effec67d374c6ea4b350fbcdd00c88828865f6b |
|
MD5 | 0f20ae6ab35ebce94b0a3e277c18ef48 |
|
BLAKE2b-256 | fa791936a6b32e4d0f0ab18d372f1b9e987b18fb6cdd87cc36f20880b3012a78 |
Hashes for whatlang_pyo3-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d3237f1a1bc075c8ff31f40c7241d3baf0ddd30a329909da72bdf291ca5ec56 |
|
MD5 | 042ebebc355854a8218a7300f7c2fbf3 |
|
BLAKE2b-256 | c4377dd2a5733fbd7e30df66b55fb8532f4f518b549a85e9e9ecf2dc912b30e1 |
Hashes for whatlang_pyo3-0.6.0-cp37-cp37m-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 802e61deb2986ca04546c16c535b2f3efe99635dcf2b2ccd4b8f38f1cc1e7257 |
|
MD5 | 6b4677c136a2730e9f72331fa90c3add |
|
BLAKE2b-256 | d729d613c68612f37d5ac98e15904327d02963df0b45ffdce624a4121fc98fe2 |