Ruby wrapper to consume the Oxford Dictionary API
$ gem install oxford_dictionary
# To use in your script/application
require 'oxford_dictionary'
After registering for an API key, setup the client:
client = OxfordDictionary::Client.new(app_id: 'ID', app_key: 'SECRET')
client = OxfordDictionary.new(app_id: 'ID', app_key: 'SECRET')
This wrapper follows the schema laid out by the API quite closely. The data schema for the different API calls can be found here.
entry = client.entry(word: 'vapid', dataset: 'en-gb', params: {})
# Access the first entry
# Refer to the API documentation for the schema of the returned data structure
first_lexical_entry = entry.lexicalEntries.first
# With some filters
filters = { lexicalCategory: 'Verb', domains: 'Art'}
client.entry(word: 'truth', dataset: 'en-gb', params: filters)
# To have multiple values for a single filter use comma separated terms
filters = { lexicalCategory: 'Verb,Noun' }
# You can also search for the results for different datasets
# Refer to the Oxford Dictionaries documentation for all the
# possible datasets
client.entry(word: 'ace', dataset: 'es', params: {})
# You can query for results from a specific "field"
# Refer to the Oxford Dictionaries documentation for all the
# possible fields
client.entry(word: 'explain', dataset: 'en-gb', params: { fields: 'examples' })
client.lemma(word: 'condition', language: 'en', params: {})
client.translation(
word: 'condition',
source_language: 'en',
target_language: 'es',
params: {}
)
client.sentence(word: 'paraphrase', language: 'en', params: {})
client.search(language: 'en-gb', params: { q: 'vapid' })
client.thesaurus(
word: 'book',
language: 'en',
params: { fields: 'synonyms,antonyms'}
)
# Or use { fields: 'synonyms' } for just synonyms
After checking out the repo, run bin/setup
to install dependencies.
Run bin/console
for an interactive prompt that will allow you to experiment.
Bug reports and pull requests are more than welcome!
Please make tests for anything that is added.
bundle exec rake
will run rspec/rubocop.
- Read this often cited resource on contributing to open source projects on GitHub
- Fork the project
- Code and commit in your own feature branch
- Open a PR and nag me to close it!
The gem is available as open source under the terms of the MIT License.