
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Ruby bindings for Chromium Compact Language Detector (source). This gem is using source codes from chromium-compact-language-detector port.
Add this line to your application's Gemfile:
gem 'language_detection'
And then execute:
$ bundle
Or install it yourself as:
$ gem install language_detection
>> require 'language_detection'
=> true
>> language = LanguageDetection.perform("This is some example text for language detection")
=> #<LanguageDetection::Language:0x007fae0404f628 @name="english", @code="en", @reliable=true, @text_bytes=51, @details=[#<LanguageDetection::Language:0x007fae0404eb10 @name="english", @code="en", @details=[], @percent=100, @score=49.43273905996759>]>
>> language.name
=> "english"
>> language.code
=> "en"
>> language.reliable
=> true
>> language.details # contains up to 3 languages sorted by score
=> [#<LanguageDetection::Language:0x007fae0404eb10 @name="english", @code="en", @details=[], @percent=100, @score=49.43273905996759>]
>> language.details.first.percent
=> 100
>> language.details.first.score
=> 49.43273905996759
the other way is to include LanguageDetection
module in your class
class Article
include LanguageDetection
attr_accessor :title, :content
def initialize(params = {})
@title = params[:title]
@content = params[:content]
end
def to_s
"#{title}\n#{content}"
end
end
which provides Article#language
method using Article#to_s
method as parameter
>> article = Article.new :title => "Web development that doesn't hurt", :content => "Tens of thousands of Rails applications are already live..."
>> article.language
=> #<LanguageDetection::Language:0x007fae049dd8e8 @name="english", @code="en", @reliable=true, @text_bytes=93, @details=[#<LanguageDetection::Language:0x007fae049dd118 @name="english", @code="en", @details=[], @percent=100, @score=80.22690437601297>]>
or you can add String#language
method by require 'language_detection/string'
>> require 'language_detection'
=> true
>> require 'language_detection/string'
=> true
>> "Web development that doesn't hurt".language
=> #<LanguageDetection::Language:0x007fae049cfec8 @name="english", @code="en", @reliable=true, @text_bytes=36, @details=[#<LanguageDetection::Language:0x007fae049cf7e8 @name="english", @code="en", @details=[], @percent=100, @score=39.70826580226905>]>
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that language_detection 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.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.