Ruby wrapper for the Big Huge Labs Thesaurus API.
Add this line to your application's Gemfile:
gem 'dinosaurus'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dinosaurus
Add your api key using the configure
method. If you're in the Rails
environemnt then this can be done in an initializer file.
Dinosaurus.configure do |config|
config.api_key = 'djksfhjk'
end
Now, lookup words in the Thesaurus:
require "dinosaurus"
results = Dinosaurus.lookup('word')
The 'results' object is a hash with some special accessors added.
# You can use it like a normal hash:
results['noun']
# => { 'syn' => [..., ..., ...], 'ant' => [..., ...] }
# Or you can access it with symbols.
results[:noun]
# => { 'syn' => [..., ..., ...], 'ant' => [..., ...] }
# Or you can take advantage of the special accesor methods. The
# methods provided are
# - synonyms
# - antonyms
# - related_terms
# - similar_terms
results.synonyms
# => [..., ..., ...]
Certain convenience methods are provided on the top level namespace. Each method returns an array.
Dinosaurus.synonyms_of('word')
Dinosaurus.antonyms_of('word')
Dinosaurus.related_to('word')
Dinosaurus.similar_to('word')
Slightly more information can be found on the RubyDocs.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)