Skip to main content

fastlid

[tests]pythonCode style: blackLicense: MITPyPI version

Language identification based on fasttext (lid.176.ftz https://fasttext.cc/docs/en/language-identification.html).

Python3.8, 3.9 only -- there seem to be some problems with python

The lid.176.ftz file is licensed under Creative Commons Attribution-Share-Alike License 3.0 and is not part of this module. It is automatically downloaded from its external origin on the first run of this module.

This module attempts to immitate the follow two features of langid

  • langid.classify: fastlid
  • langid.set_languages(langs=[...]): fastlid.set_languages = [...]
    • import fastlid
    • fastlid.set_languages = ['nl','fr'])
  • TODO: Commandline interface

Install it

pip install fastlid

or install from git

pip install git+https://github.com/ffreemt/fast-langid.git

# also works pip install git+https://github.com/ffreemt/fast-langid

or clone the git repo and install from source.

Use it

from fastlid import fastlid, supported_langs

# support 176 languages
print(supported_langs, len(supported_langs))
# ['af', 'als', 'am', 'an', 'ar', 'arz', 'as', 'ast', 'av', 'az'] 176

fastlid("test this")
# ('en', 0.765)

fastlid("test this 测试一下", k=2)
# (['zh', 'en'], [0.663, 0.124])

fastlid.set_languages = ['fr', 'zh']
fastlid("test this 测试吧")
# ('zh', 0.01)

fastlid.set_languages = None
fastlid("test this 测试吧")
('en', 0.686)

fastlid.set_languages = ['fr', 'zh', 'en']
fastlid("test this 测试吧", k=3)
(['en', 'zh', 'fr'], [0.686, 0.01, 0.006])

N.B. hanzidentifier can be used to identify simplified Chinese or/and traditional Chinese should you need to do so.

For Developers

Install poetry and yarn the way you like it.

poetry install  # install python packages
yarn install --dev  # install necesary node packages

# ...code...
yarn test
yarn final

# ...optionally submit pr...

Metadata

Release files for fastlid 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastlid 0.1.12
File Size Uploaded Provenance Actions
fastlid-0.1.12.tar.gz 6.0 kB Without provenance Details for fastlid-0.1.12.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastlid 0.1.12
File Interpreter ABI Platform Actions
fastlid-0.1.12-py3-none-any.whl Python 3 none any Details for fastlid-0.1.12-py3-none-any.whl

Total release size: 12.6 kB

Release files / fastlid-0.1.12.tar.gz

Download URL fastlid-0.1.12.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
02b4c412e4d5786b7e7a40a78a82fb641fb0d4ace60d7c6496e8a66c32d1be4c
BLAKE2b-256 checksum
How to use checksums
777427edc69d74de1139a1dc0b17102fb235be28567e9c060822883d20e818ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.8.10 Windows/10

Release files / fastlid-0.1.12-py3-none-any.whl

Download URL fastlid-0.1.12-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b0a4bb6bccad720e257c0a290b651fec3da03c1fb0d9131813d85e72a8746f4
BLAKE2b-256 checksum
How to use checksums
992c2b90912e838e38b324ae096d65b59e976f3099e05e83bb21b93599bc7a38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.8.10 Windows/10

Security for fastlid 0.1.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page