Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

whichlang

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whichlang

  • 0.1.5
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

Whatlang

Ruby bindings for Whichlang, a natural language detection for Rust.

This is a fork of the original whatlang-rb but this adds an interface to the whichlang library. It's faster and detects languages better (although not as many languages).

Features

Features are derived from original Whichlang library, which includes:

  • Throughput above 100 MB/s for short and long strings.
  • Good accuracy (99.5% on my validation dataset, but it really depends on the size of your input.)
  • Supported languages: Arabic, Dutch, English, French, German, Hindi, Italian, Japanese, Korean, Mandarin, Portuguese, Russian, Spanish, Swedish, Turkish, and Vietnamese.

Installation

Requirements

You need Rust's build environment to install this gem.

For Unix like system, run

% curl https://sh.rustup.rs -sSf | sh

For Windows, download and run installer.

See Rust official installation page for details.

Gem installation

Add this line to your application's Gemfile:

gem 'whichlang'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install whichlang

Usage

require "whichlang"

text = "Благодаря Эсперанто вы обрётете друзей по всему миру!"

info = whichlang.detect(text) # => "rus"

text = "Jen la trinkejo fermitis, ni iras tra mallumo kaj pluvo."

info = whichlang.detect(text) # => "spa"

# blank spaces and nil are ignored
info = whichlang.detect(" ") # => nil
info = whichlang.detect("") # => nil
info = whichlang.detect(nil) # => nil

Development

After checking out the repo, run bundle config set local vendor/bundle && bundle install to install dependencies. Then, run bundle exec rake test to run the tests. You can also run bundle exec rake console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in Cargo.toml, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://gitlab.com/bendangelo/whichlang-rb.

License

This RubyGem distributed under the Ruby's license. See {file:COPYING} file.

FAQs

Package last updated on 03 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc