https://github.com/deradon/that_language-client
API client for ThatLanguage.
https://github.com/deradon/that_language-client
language ruby ruby-gem rubygem that-language
Last synced: 2 days ago
JSON representation
API client for ThatLanguage.
- Host: GitHub
- URL: https://github.com/deradon/that_language-client
- Owner: Deradon
- License: mit
- Created: 2015-12-07T13:40:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-02T23:03:05.000Z (almost 10 years ago)
- Last Synced: 2025-01-11T15:48:11.446Z (over 1 year ago)
- Topics: language, ruby, ruby-gem, rubygem, that-language
- Language: Ruby
- Size: 29.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://travis-ci.org/Deradon/that_language-client)
# ThatLanguage::Client
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'that_language-client'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install that_language-client
## Examples
```ruby
text = "This is just a random english sentence."
## == Language
ThatLanguage.language(text)
# => "English"
## == LanguageCode
ThatLanguage.language_code(text)
# => "en"
## == Detect
detect = ThatLanguage.detect(text)
# => # "English"
detect.language_code
# => "en"
detect.confidence
# => 0.5631093821386951
detect.to_h
# => {"language"=>"English", "language_code"=>"en", "confidence"=>0.5631093821386951}
## == Details
details = ThatLanguage.details(text)
# => # OpenStruct
winner.language
# => "English"
winner.language_code
# => "en"
winner.confidence
# => 0.5631093821386951
winner.value
# => 3.9417656749708656
winner.hit_ratio
# => 0.8571428571428571
winner.hit_count
# => 6
winner.words_count
# => 7
results = details.results
# => [#
# {
# "results" => [
# {
# "language"=>"English",
# "language_code"=>"en",
# "confidence"=>0.5631093821386951,
# "value"=>3.9417656749708656,
# "hit_ratio"=>0.8571428571428571,
# "hit_count"=>6,
# "words_count"=>7
# },
# {
# "language"=>"Sundanese",
# "language_code"=>"su",
# "confidence"=>0.26101716738575337,
# "value"=>1.8271201717002734,
# "hit_ratio"=>0.7142857142857143,
# "hit_count"=>5,
# "words_count"=>7
# },
# # ...
# ]
# }
## == Available
ThatLanguage.available
# => { "de" => "German", "en" => "English", ... }
ThatLanguage.available_languages
# => ["German", "English", ...]
ThatLanguage.available_language_codes
# => ["de", "en", ...]
## == API Version
ThatLanguage.api_version
# => "42"
```
## Configure
Configure the host to use:
```ruby
ThatLanguage::Client.configure do |config|
config.host = "my-custom-that-language-api.com"
end
```
## Development
After checking out the repo, run `bin/setup` to install dependencies.
Then, run `rake rspec` 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`.
To release a new version, update the version number in `version.rb`, and then run
`bundle exec rake release`, which will create a git tag for the version,
push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Deradon/that_language-client.
This project is intended to be a safe, welcoming space for collaboration,
and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).