
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
This is a Ruby wrapper for the Linguin AI API (see API docs) providing Language and Profanity Detection as a Service.
Linguin AI is free for up to 100 detections per day. You can get your API key here.
Add this line to your application's Gemfile:
gem "linguin"
And then execute:
$ bundle install
Or install it yourself as:
$ gem install linguin
Use the Linguin singleton to get started with just a few lines of code:
require "linguin"
Linguin.api_key = "YOUR-API-KEY" # goto https://linguin.ai to get your key
response = Linguin.detect_language("test")
response.success? # => true
response.results # => [{ lang: "en", confidence: 0.97 }, ...]
response = Linguin.detect_profanity("you are a moron")
response.success? # => true
response.score # => 0.998
If something goes wrong (here: empty text):
response = Linguin.detect_language("")
response.success? # => false
response.error
# => { code: 400, message: "The language of an empty text is more of a philosophical question." }
# if you prefer to handle exceptions instead you can use `#detect_language!`:
response = Linguin.detect_language!("")
# => raises Linguin::InputError
See the list of all exceptions here.
To detect the language of multiple texts with one API call, you can pass them as an array. The results will be returned in the same order as the texts.
All texts have to not be empty. Using detect_language!
will result in an exception as for single detections.
The same is true for profanity detection: calling detect_profanity!
with empty texts will result in an exception as for single detections.
response = Linguin.detect_language(["test", "bahnhof", "12341234"])
response.results
# => [ [{ lang: "en", confidence: 0.97 }, ...], [{ ... }], [] ]
response = Linguin.detect_profanity(["a test", "you are a moron"])
response.scores
# => [0.0124, 0.9981]
response = Linguin.detect_language(["test", ""])
response.success? # => false
response.error
# => { code: 400, message: "At least one of the texts provided was empty." }
Linguin.detect_language!(["test", ""])
# => raises Linguin::InputError
You can fetch the status of your account:
status = Linguin.status
status.detections_today # => 4_500
status.daily_limit # => 50_000 or nil for no limit
status.remaining_today # => 45_500 or Float::INFINITY for unlimited
You can fetch the list of supported languages:
languages = Linguin.languages
# => { de: ["German", "Deutsch"], ... }
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Bug reports and pull requests are welcome on GitHub at https://github.com/LinguinAI/linguin-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Linguin project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that linguin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.