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 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.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64698e77338b67a3d3952389b40cdcdd48da4897ff2622f2ce1c214bc1f222a0 |
|
MD5 | dc6cd4d41e0aedb777ec637ffdbf8db7 |
|
BLAKE2b-256 | dfc87bbdcf3b7f7bed763e56e6d99312aa6a7a16423cc212ae691ae79d086ef6 |
Hashes for whatlang_pyo3-0.5.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc18831d0f10bc20848c007305025ae4323f8b2923da909e8d96a5773a46d6ce |
|
MD5 | 88a32e859afedd81c1120e49d133bda5 |
|
BLAKE2b-256 | ff5536604a2b88a1497a8c5c0103c502c19e0d3c03c0b14f38fab53cff40e7ff |
Hashes for whatlang_pyo3-0.5.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c204e8ba4ea4ecd87431afb09b8960c1397a5eea98ea73f731e7094e631db78 |
|
MD5 | 5c055dd24c688831e4b17f0ac0837b08 |
|
BLAKE2b-256 | 55ae3b0e92801e22df6befc5b1dc7b29da7c0ddfdbe8978befd26fd18378ca82 |
Hashes for whatlang_pyo3-0.5.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23cd7ff538530860672b0a9f18398e645ef676025cf225940d4597f8af6a6958 |
|
MD5 | 66b190793bb602ffd59625f2045335e7 |
|
BLAKE2b-256 | 7ec8fc10c88670f6699be8dd64a72450845170db86b74d9d2f2fe7763f21c6e1 |
Hashes for whatlang_pyo3-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f68a1897a7cd2b554e052463095a02a0ee4d4dc026cd156b069c70f08a05bace |
|
MD5 | 195ad6e5cc20376dc7933b62eced1377 |
|
BLAKE2b-256 | 471d4baf03b61df3b4653ed251db3592467d5f9c69ce9a1cf0ac3cfda74ea525 |
Hashes for whatlang_pyo3-0.5.0-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cf07b82dc2ed4c83c6aa5104bc410d1615ccbd02a30a06870d02788291d7259 |
|
MD5 | 063ec6b1bb5b33113fee0dc6dc49bfbf |
|
BLAKE2b-256 | 07a50fe51198fca3e7896fecc1241e54d5c83398a046f0b85b455f3c5f52b87d |
Hashes for whatlang_pyo3-0.5.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 363378b0fff3a27336b79ca3cefe957fd5ee9bc93bbf47afef305daac6154558 |
|
MD5 | d35b564f9de6c913ce4f66e9e70faece |
|
BLAKE2b-256 | 6a5b9ee2e22175a3481f2225e28e4e90c1bece9fdaf590f62e663bf87ba3d51a |
Hashes for whatlang_pyo3-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d384e4522f38d4da5fe8fe3017fe72451706651953cc6a27cda99e5d303ffee6 |
|
MD5 | 0f8dacff5ba9aa844e8068b7967a9846 |
|
BLAKE2b-256 | 3d7104fe9d4f10524c63c57c27e0f2f6861724d39f2b2c846adca0e7d547bed2 |
Hashes for whatlang_pyo3-0.5.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdd693461e9843d0a3be4ef3bd88a96a902d4a1503a2baa1e0f0e6e0fcf009a6 |
|
MD5 | 255174bcafd0d462fee0a3d5c1e5041d |
|
BLAKE2b-256 | c466786941a4dca84b2d0e6ad8648597e6b0c59c611cedb7a7856a3834bc7097 |
Hashes for whatlang_pyo3-0.5.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b055cbe9c220da59fa5a2cf5c74d670f76619b5a1cf2e0d118f82985afe5e251 |
|
MD5 | abd9e137a009f927123244a0dcd8de44 |
|
BLAKE2b-256 | 3a2137ce0ba319a138c3e99fd0804efc1b6d10f84ae266eaa0d5fa5af6123595 |
Hashes for whatlang_pyo3-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac62e5a94303595ff891dbcdebb1ce0e93143d3b81179287cd23e78d35ef6bf0 |
|
MD5 | 3a877244f4c1ca535a3cbc493dc6a315 |
|
BLAKE2b-256 | c293a739759d5ed01f54f1811a0a3bfc1f8a58d3543ac8ce312665391d8db1c9 |
Hashes for whatlang_pyo3-0.5.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38182da96afc9de36d50af4a88e597caae8f95dd80e57349385ca1df65487abc |
|
MD5 | 5951066dc3ff2250eb7e1228d5a976e3 |
|
BLAKE2b-256 | 51467267bf14fd7554400b3cdf1e6514410832beb02ee6389c435d39b3ccacea |
Hashes for whatlang_pyo3-0.5.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c9988afd90816ac4cb4c1358dd4b700c0b29d43fd935e76cf361c4b9506460d |
|
MD5 | aa6c188d8e0cd385c165bffee99b03ac |
|
BLAKE2b-256 | d72343c3819482b6a4e273a38a74e1a6071b7edcce26dac60ac1a111a3f8600f |
Hashes for whatlang_pyo3-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9420eba497509017c10786232e267247604bef55db3bfa6595b959b18431d2e5 |
|
MD5 | 86152d3f3a4925e9ae9abc00f1835560 |
|
BLAKE2b-256 | f490740528e9001485fea361d2dffe60cf6d2a3297fd60a52f089419eb4a9b7d |
Hashes for whatlang_pyo3-0.5.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd9da0fe5d3c6346e0c818380d15020938db1998504121127f4d4faaee3ada49 |
|
MD5 | 78a3bbdf6e1cdf3d66514f0188f14e71 |
|
BLAKE2b-256 | db0b7a31af1d8963199b121f8309bf8024afb9e17e42aabcd5f8568ea7754643 |
Hashes for whatlang_pyo3-0.5.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90f7beb3cf61932d54d19d5310344008437db926e551fb1c251009e5d7862b5d |
|
MD5 | 20e6f61525228451ee16b0e99c11ce69 |
|
BLAKE2b-256 | bc9d84b2c95f2f17dd39367ae6e8c2977fbca5d130f15a9908ad80a9829eab23 |
Hashes for whatlang_pyo3-0.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2cd2813ed7558679ac656844988ac50da07891aff11246947411515af0fcbef |
|
MD5 | 2740330c2f2e6f7717153782264b4c3b |
|
BLAKE2b-256 | fd88231184a523c0511787b1ed793580f7e760ad2ab1033f430fdd394900ab9f |
Hashes for whatlang_pyo3-0.5.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c89f4e6f7f9b2b4aa2d494553f94e644ad587854f54a40ed351854f9d81e8f8 |
|
MD5 | e376db33a8c57c4d4144d8e9315ddd63 |
|
BLAKE2b-256 | aa432963e1871653510da7128840506b1e0fa0936b2137d412d6fcbcdfcef45e |