bindings by Cathal Garvey, Copyright 2017, released under MIT license.
This simply wraps the Whatlang-rs library by Sergey Potapov, exposing a single function to Python which returns a tuple of (language code, script code).
You will require:
- A Rust toolchain
pip install setuptools_rust
Then: python3 setup.py install --user
. The --user
part is essential, as
Rustup doesn't perform a system installation of Rust. Possibly, you could use
a system-managed Rust toolchain (e.g. apt-get install cargo
) to permit a
system-wide install of the library. Or, you could just use python3 setup.py build
and then manually install the library system-wide.
[sudo] pip3 install https://github.com/cathalgarvey/whatlang-py/raw/master/dist/whatlang-0.0.1-cp35-cp35m-linux_x86_64.whl
or:
- Download this repository
- Change directory to the
dist
subdirectory [sudo] pip3 install *.whl
There is only one function in the library: detect_language
, which accepts a
single unicode string and returns a pair of strings or raises a ValueError
on failure.
The strings returned correspond to the three-character language code, and three-character
script code. These are enumerated in Whatlang's docs as the Enums Lang
and
Script
and are returned as strings in the same leading-uppercase format.