fastlid


Namefastlid JSON
Version 0.1.11 PyPI version JSON
download
home_pagehttps://github.com/ffreemt/fast-langid
SummaryDetect languages via a fasttext model
upload_time2024-07-04 08:23:18
maintainerNone
docs_urlNone
authorfreemt
requires_python<3.10,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fastlid
<!--- repo_name  pack_name  mod_name func_name --->
[![tests](https://github.com/ffreemt/fast-langid/actions/workflows/routine-tests.yml/badge.svg)][![python](https://img.shields.io/static/v1?label=python+&message=3.8-3.9&color=blue)](https://img.shields.io/static/v1?label=python+&message=3.8%2B&color=blue)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)[![PyPI version](https://badge.fury.io/py/fastlid.svg)](https://badge.fury.io/py/fastlid)

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 3.10+.

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

```bash
pip install fastlid
```
or install from `git`
```bash
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
```python
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.
```bash
poetry install  # install python packages
yarn install --dev  # install necesary node packages

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

# ...optionally submit pr...
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ffreemt/fast-langid",
    "name": "fastlid",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.10,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "freemt",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ad/24/ed55e94084ba354447e835de829f233925eac835e3b71ab9c52bd9afe352/fastlid-0.1.11.tar.gz",
    "platform": null,
    "description": "# fastlid\n<!--- repo_name  pack_name  mod_name func_name --->\n[![tests](https://github.com/ffreemt/fast-langid/actions/workflows/routine-tests.yml/badge.svg)][![python](https://img.shields.io/static/v1?label=python+&message=3.8-3.9&color=blue)](https://img.shields.io/static/v1?label=python+&message=3.8%2B&color=blue)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)[![PyPI version](https://badge.fury.io/py/fastlid.svg)](https://badge.fury.io/py/fastlid)\n\nLanguage identification based on fasttext (lid.176.ftz https://fasttext.cc/docs/en/language-identification.html).\n\nPython3.8, 3.9 only -- there seem to be some problems with python 3.10+.\n\nThe `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.\n\nThis module attempts to immitate the follow two features of `langid`\n*   langid.classify: fastlid\n*   langid.set_languages(langs=[...]): fastlid.set_languages = [...]\n    *   import fastlid\n    *   fastlid.set_languages = ['nl','fr'])\n*   TODO: Commandline interface\n\n## Install it\n\n```bash\npip install fastlid\n```\nor install from `git`\n```bash\npip install git+https://github.com/ffreemt/fast-langid.git\n\n# also works pip install git+https://github.com/ffreemt/fast-langid\n```\nor clone the git repo and install from source.\n\n## Use it\n```python\nfrom fastlid import fastlid, supported_langs\n\n# support 176 languages\nprint(supported_langs, len(supported_langs))\n# ['af', 'als', 'am', 'an', 'ar', 'arz', 'as', 'ast', 'av', 'az'] 176\n\nfastlid(\"test this\")\n# ('en', 0.765)\n\nfastlid(\"test this \u6d4b\u8bd5\u4e00\u4e0b\", k=2)\n# (['zh', 'en'], [0.663, 0.124])\n\nfastlid.set_languages = ['fr', 'zh']\nfastlid(\"test this \u6d4b\u8bd5\u5427\")\n# ('zh', 0.01)\n\nfastlid.set_languages = None\nfastlid(\"test this \u6d4b\u8bd5\u5427\")\n('en', 0.686)\n\nfastlid.set_languages = ['fr', 'zh', 'en']\nfastlid(\"test this \u6d4b\u8bd5\u5427\", k=3)\n(['en', 'zh', 'fr'], [0.686, 0.01, 0.006])\n```\n\nN.B. `hanzidentifier` can be used to identify simplified Chinese or/and traditional Chinese should you need to do so.\n\n## For Developers\nInstall `poetry` and `yarn` the way you like it.\n```bash\npoetry install  # install python packages\nyarn install --dev  # install necesary node packages\n\n# ...code...\nyarn test\nyarn final\n\n# ...optionally submit pr...\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Detect languages via a fasttext model",
    "version": "0.1.11",
    "project_urls": {
        "Homepage": "https://github.com/ffreemt/fast-langid",
        "Repository": "https://github.com/ffreemt/fast-langid"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "876536bdc03ed5460f8ab8b234dbb697c7c1d2dcba83be707babade5ff49b7ec",
                "md5": "492fa1f0ade3d72b860e810c3f0c4b99",
                "sha256": "f7415a8e428d871a25b8df8ae6434452a4c819c3419bb587db959c9082576ecd"
            },
            "downloads": -1,
            "filename": "fastlid-0.1.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "492fa1f0ade3d72b860e810c3f0c4b99",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.10,>=3.8",
            "size": 6633,
            "upload_time": "2024-07-04T08:23:16",
            "upload_time_iso_8601": "2024-07-04T08:23:16.117726Z",
            "url": "https://files.pythonhosted.org/packages/87/65/36bdc03ed5460f8ab8b234dbb697c7c1d2dcba83be707babade5ff49b7ec/fastlid-0.1.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ad24ed55e94084ba354447e835de829f233925eac835e3b71ab9c52bd9afe352",
                "md5": "95dc544d298922b7508a8d296d5e43b1",
                "sha256": "16cb752702328eced2e8d5668f0ac54bc006d95d7e46615ab857084150bfac34"
            },
            "downloads": -1,
            "filename": "fastlid-0.1.11.tar.gz",
            "has_sig": false,
            "md5_digest": "95dc544d298922b7508a8d296d5e43b1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.10,>=3.8",
            "size": 5958,
            "upload_time": "2024-07-04T08:23:18",
            "upload_time_iso_8601": "2024-07-04T08:23:18.018593Z",
            "url": "https://files.pythonhosted.org/packages/ad/24/ed55e94084ba354447e835de829f233925eac835e3b71ab9c52bd9afe352/fastlid-0.1.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-04 08:23:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ffreemt",
    "github_project": "fast-langid",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fastlid"
}
        
Elapsed time: 0.34299s