{"id":13858690,"url":"https://github.com/peterc/whatlanguage","last_synced_at":"2025-07-14T01:32:00.089Z","repository":{"id":424816,"uuid":"44852","full_name":"peterc/whatlanguage","owner":"peterc","description":"A language detection library for Ruby that uses bloom filters for speed.","archived":false,"fork":false,"pushed_at":"2022-08-21T15:02:00.000Z","size":17460,"stargazers_count":683,"open_issues_count":12,"forks_count":69,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-07-02T04:53:35.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/peterc.png","metadata":{"files":{"readme":"README.md","changelog":"History.txt","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2008-08-22T03:53:15.000Z","updated_at":"2025-04-29T19:17:51.000Z","dependencies_parsed_at":"2022-07-08T01:50:40.796Z","dependency_job_id":null,"html_url":"https://github.com/peterc/whatlanguage","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/peterc/whatlanguage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterc%2Fwhatlanguage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterc%2Fwhatlanguage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterc%2Fwhatlanguage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterc%2Fwhatlanguage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterc","download_url":"https://codeload.github.com/peterc/whatlanguage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterc%2Fwhatlanguage/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265231106,"owners_count":23731522,"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":[],"created_at":"2024-08-05T03:02:17.647Z","updated_at":"2025-07-14T01:31:55.198Z","avatar_url":"https://github.com/peterc.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# whatlanguage\n\nby Peter Cooper\n\nText language detection. Quick, fast, memory efficient, and all in pure Ruby. Uses Bloom filters for aforementioned speed and memory benefits. It works well on texts of over 10 words in length (e.g. blog posts or comments) and *very poorly* on short or Twitter-esque text, so be aware.\n\nWorks with Dutch, English, Farsi, French, German, Italian, Pinyin, Swedish, Portuguese, Russian, Arabic, Finnish, Greek, Hebrew, Hungarian, Korean, Norwegian, Polish and Spanish out of the box.\n\n## Important note\n\nThis library was first built in 2007 and has received only a few minor updates over the years. There are now more efficient and effective algorithms for doing language detection which I am investigating for a future WhatLanguage.\n\nThis library has been updated to be distributed and to work on modern Ruby implementations but other than that, has had no significant improvements.\n\n## Synopsis\n\nFull Example\n\n```ruby\nrequire 'whatlanguage'\n\ntexts = []\ntexts \u003c\u003c %q{Deux autres personnes ont été arrêtées durant la nuit}\ntexts \u003c\u003c %q{The links between the attempted car bombings in Glasgow and London are becoming clearer}\ntexts \u003c\u003c %q{En estado de máxima alertaen su nivel de crítico}\ntexts \u003c\u003c %q{Returns the object in enum with the maximum value.}\ntexts \u003c\u003c %q{Propose des données au sujet de la langue espagnole.}\ntexts \u003c\u003c %q{La palabra \"mezquita\" se usa en español para referirse a todo tipo de edificios dedicados.}\ntexts \u003c\u003c %q{اللغة التي هي هذه؟}\ntexts \u003c\u003c %q{Mitä kieltä tämä on?}\ntexts \u003c\u003c %q{Ποια γλώσσα είναι αυτή;}\ntexts \u003c\u003c %q{באיזו שפה זה?}\ntexts \u003c\u003c %q{Milyen nyelv ez?}\ntexts \u003c\u003c %q{이 어떤 언어인가?}\ntexts \u003c\u003c %q{Hvilket språk er dette?}\ntexts \u003c\u003c %q{W jakim języku to jest?}\n\ntexts.each { |text| puts \"#{text[0..18]}... is in #{text.language.to_s.capitalize}\" }\n```\n\nInitialize WhatLanguage with all filters\n\n```ruby\nwl = WhatLanguage.new(:all)\n```\n\nReturn language with best score\n\n```ruby\nwl.language(text)\n```\n\nReturn hash with scores for all relevant languages\n\n```ruby\nwl.process_text(text)\n```\n\nConvenience methods on String\n\n```ruby\n\"This is a test\".language   # =\u003e :english\n\"This is a test\".language_iso   # =\u003e :en\n```\n\nInitialize WhatLanguage with certain languages\n\n```ruby\nwl = WhatLanguage.new(:english, :german, :french)\n```\n\n## Requirements\n\nNone, minor libraries (BloominSimple and BitField) included with this release.\n\n## Installation\n\n    gem install whatlanguage\n\nTo test, go into irb, then:\n\n```ruby\nrequire 'whatlanguage'\n\"Je suis un homme\".language\n```\n\n## Credits\n\nContributions from Konrad Reiche, Salimane Adjao Moustapha, and others appreciated.\n\n## License\n\nMIT License\n\nCopyright (c) 2007-2016 Peter Cooper\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterc%2Fwhatlanguage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterc%2Fwhatlanguage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterc%2Fwhatlanguage/lists"}