{"id":13520238,"url":"https://github.com/Proteusiq/luga","last_synced_at":"2025-03-31T16:30:54.941Z","repository":{"id":45310099,"uuid":"427675479","full_name":"Proteusiq/luga","owner":"Proteusiq","description":"Blazing fast language detection using fastText model","archived":false,"fork":false,"pushed_at":"2022-12-18T17:29:43.000Z","size":620,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-07-25T19:26:38.341Z","etag":null,"topics":["detection","language","language-model","languages","machine-learning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Proteusiq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-13T13:39:31.000Z","updated_at":"2023-12-20T03:13:12.000Z","dependencies_parsed_at":"2023-01-29T19:46:00.898Z","dependency_job_id":null,"html_url":"https://github.com/Proteusiq/luga","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Proteusiq%2Fluga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Proteusiq%2Fluga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Proteusiq%2Fluga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Proteusiq%2Fluga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Proteusiq","download_url":"https://codeload.github.com/Proteusiq/luga/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213468388,"owners_count":15591699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["detection","language","language-model","languages","machine-learning"],"created_at":"2024-08-01T05:02:15.069Z","updated_at":"2024-08-01T05:12:58.650Z","avatar_url":"https://github.com/Proteusiq.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Luga\n==============================\n- A blazing fast language detection using fastText's language models.\n\n![Languages](https://user-images.githubusercontent.com/14926709/143822756-8fd6437f-6c99-4a9f-9718-37f086955583.png)\n\n\n_Luga_ is a Swahili word for language. [fastText](https://github.com/facebookresearch/fastText) provides blazing-fast\nlanguage detection tool. Lamentably, [fastText's](https://fasttext.cc/docs/en/support.html) API is beauty-less, and the documentation is a bit fuzzy.\nIt is also funky that we have to manually [download](https://fasttext.cc/docs/en/language-identification.html) and load models.\n\nHere is where _luga_ comes in. We abstract unnecessary steps and allow you to do precisely one thing: detecting text language.\n\n#### cover image\n[Stand Still. Stay Silent](http://sssscomic.com/index.php) - The relationships between Indo-European and Uralic languages by Minna Sundberg.\n\n### Show, don't tell\n![Luga in Action](example.gif)\n\n\n### Installation\n```bash\npython -m pip install -U luga\n```\n\n### Usage:\n⚠️ Note: The first usage downloads the model for you. It will take a bit longer to import depending on internet speed.\nIt is done only once.\n\n```python\nfrom luga import language\n\nprint(language(\"the world ended yesterday\"))\n\n# Language(name='en', score=0.98)\n```\n\n\nWith the list of texts, we can create a mask for a filtering pipeline, that can be used, for example, with DataFrames\n\n```python\nfrom luga import language\nimport pandas as pd\n\nexamples = [\"Jeg har ikke en rød reje\", \"Det blæser en halv pelican\", \"We are not robots yet\"]\nlanguages(texts=examples, only_language=True, to_array=True) == \"en\"\n# output\n# array([False, False, True])\n\ndataf = pd.DataFrame({\"text\": examples})\ndataf.loc[lambda d: languages(texts=d[\"text\"].to_list(), only_language=True, to_array=True) == \"en\"]\n# output\n# 2    We are not robots yet\n# Name: text, dtype: object\n```\n\n### Without Luga:\n\nDownload the model\n```bash\nwget https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin -O /tmp/lid.176.bin\n```\n\nLoad and use\n```python\nimport fasttext\n\nPATH_TO_MODEL = '/tmp/lid.176.bin'\nfmodel = fasttext.load_model(PATH_TO_MODEL)\nfmodel.predict([\"the world has ended yesterday\"])\n\n# ([['__label__en']], [array([0.98046654], dtype=float32)])\n```\n\n\n### Dev:\n\n```bash\npoetry run pre-commit install\n```\n\n## Release Flow\n```bash\n# assumes git push is completed\ngit tag -l #  lists tags\ngit tag v*.*.* # Major.Minor.Fix\ngit push origin tag v*.*.*\n\n# to delete tag:\ngit tag -d v*.*.* \u0026\u0026 git push origin tag -d v*.*.*\n\n# change project_toml and __init__.py to reflect new version\n```\n\n#### TODO:\n- [X] refactor artifacts.py\n- [X] auto checkers with pre-commit | invoke\n- [X] write more tests\n- [X] write github actions\n- [ ] create an intelligent data checker (a fast List[str], what do with none strings)\n- [ ] make it faster with Cython\n- [ ] get NDArray typing correctly\n- [ ] fix `artifacts.py` line 111 cast to List[str] that causes issues\n- [ ] remove nptyping when more packages move to numpy \u003e 1.21\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FProteusiq%2Fluga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FProteusiq%2Fluga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FProteusiq%2Fluga/lists"}