Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Language Detection API Ruby Client
Ruby
tag: v1.0.1

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.travis.yml
Gemfile
LICENSE
README.md
Rakefile
detect_language.gemspec

README.md

Detect Language API Client Build Status

Detects language of given text. Returns detected language codes and scores.

Before using Detect Language API client you setup your personal API key. You can get it by signing up at http://detectlanguage.com

Installation

Add this line to your application's Gemfile:

gem 'detect_language'

Or install it yourself as:

$ gem install detect_language

Configuration

If you are using Rails, create initializer config/initializers/detect_language.rb and add following code there. Otherwise just integrate following code into your apps configuration.

DetectLanguage.configure do |config|
  config.api_key = "YOUR API KEY"
end

Usage

Language detection

DetectLanguage.detect("Buenos dias señor")

Result

[ {"language"=>"es", "isReliable"=>false, "confidence"=>0.3271028037383178},
  {"language"=>"pt", "isReliable"=>false, "confidence"=>0.08356545961002786} ]

Simple language detection

If you need just a language code you can use simple_detect. It returns just the language code.

DetectLanguage.simple_detect("Buenos dias señor")

Result

"es"

License

Detect Language API Client is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.

Something went wrong with that request. Please try again.