diff --git a/README.md b/README.md index e76f0a6..9f8d653 100644 --- a/README.md +++ b/README.md @@ -69,9 +69,6 @@ client.entry_antonyms_synonyms('monotonous') # Inflections of a word inflections = client.inflection('changed') -# Wordlist results (based on categorys, filters, etc...) -related = client.wordlist(lexicalCategory: 'Noun', word_length: '>5,<10') - # Or the search endpoint search_results = client.search('condition', prefix: true) ``` @@ -85,10 +82,6 @@ filters = { lang: 'es' } # To use multiple values on a single filter, make it an array filters = { lexicalCategory: ['Noun', 'Verb'] } - -# The wordlist endpoint specifically may include "nested" filters -# These filters (exclude, exclude_senses, etc...) require arrays -filters = { exclude: [domains: %w(sport art)] } ``` Argument names need to be in camelCase, not snake_case. However, the objects returned from API calls use snake_case attributes. diff --git a/lib/oxford_dictionary/client.rb b/lib/oxford_dictionary/client.rb index 63768a8..7ba8e75 100644 --- a/lib/oxford_dictionary/client.rb +++ b/lib/oxford_dictionary/client.rb @@ -1,7 +1,6 @@ require 'oxford_dictionary/endpoints/entry_endpoint' require 'oxford_dictionary/endpoints/inflection_endpoint' require 'oxford_dictionary/endpoints/search_endpoint' -require 'oxford_dictionary/endpoints/wordlist_endpoint' require 'oxford_dictionary/endpoints/entries' require 'oxford_dictionary/endpoints/lemmas' @@ -18,7 +17,6 @@ class Client include OxfordDictionary::Endpoints::EntryEndpoint include OxfordDictionary::Endpoints::InflectionEndpoint include OxfordDictionary::Endpoints::SearchEndpoint - include OxfordDictionary::Endpoints::WordlistEndpoint attr_reader :app_id, :app_key diff --git a/lib/oxford_dictionary/endpoints/wordlist_endpoint.rb b/lib/oxford_dictionary/endpoints/wordlist_endpoint.rb deleted file mode 100644 index 02cedc4..0000000 --- a/lib/oxford_dictionary/endpoints/wordlist_endpoint.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'oxford_dictionary/deprecated_request' -require 'oxford_dictionary/api_objects/list_response' - -module OxfordDictionary - module Endpoints - # Interface to '/wordlist' endpoint - module WordlistEndpoint - extend Gem::Deprecate - include OxfordDictionary::DeprecatedRequest - - ENDPOINT = 'wordlist'.freeze - ADVANCED_FILTERS = [:exact, :exclude, :exclude_senses, - :exclude_prime_senses, :limit, :offset, - :prefix, :word_length].freeze - - def wordlist(params = {}) - # Check first so that we don't waste an API call - if too_many_filter_values(params) - raise(Error.new(400), 'Do not use more than 5 values for a filter') - end - ListResponse.new(request(ENDPOINT, nil, params)) - end - deprecate :wordlist, :none, 2019, 6 - - private - - def too_many_filter_values(params) - params.each do |k, v| - return true if v.size > 5 && !ADVANCED_FILTERS.include?(k) - end - false - end - end - end -end diff --git a/spec/endpoint_specs/wordlist_endpoint_spec.rb b/spec/endpoint_specs/wordlist_endpoint_spec.rb deleted file mode 100644 index 22ba1f5..0000000 --- a/spec/endpoint_specs/wordlist_endpoint_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'spec_helper' - -describe OxfordDictionary::Endpoints::WordlistEndpoint do - before do - stub_get('wordlist/en/registers=Rare;domains=Art', 'wordlist_rare_art.json') - first_part = 'wordlist/en/lexicalCategory=Noun' - second_part = 'exclude=domains=sport&word_length=>5,<10&prefix=goal' - advanced = 'exclude=domains=sport,art;registers=informal' - advanced_two = '&word_length=>5&prefix=goal' - stub_get( - "#{first_part}?#{second_part}&exact=false", - 'wordlist_goal_advanced.json' - ) - stub_get( - "#{first_part}?#{advanced}#{advanced_two}&exact=false", - 'wordlist_complex.json' - ) - end - let(:client) { OxfordDictionary.new(app_id: 'ID', app_key: 'SECRET') } - - context '#wordlist with basic filters' do - let(:resp) { client.wordlist(registers: 'Rare', domains: 'Art') } - it 'is a wordlist request' do - expect(resp.results).to be_an Array - expect(resp.results.size).to eq(3) - expect(resp.results[0].word).to eq('eurhythmic') - end - end - - context '#wordlist with word length filter' do - let(:resp) do - client.wordlist( - lexicalCategory: 'Noun', - exclude: [domains: 'sport'], - word_length: '>5,<10', - prefix: 'goal' - ) - end - it 'is working as expected' do - expect(resp.results).to be_an Array - expect(resp.results.size).to eq(9) - expect(resp.results[0].word).to eq('goal area') - end - end - - context '#wordlist with very complex filter' do - let(:resp) do - client.wordlist( - lexicalCategory: 'Noun', - exclude: [domains: %w(sport art), registers: 'informal'], - word_length: '>5', - prefix: 'goal' - ) - end - it 'is working as expected' do - expect(resp.results).to be_an Array - expect(resp.results.size).to eq(11) - expect(resp.results[1].id).to eq('goal_average') - end - end - - context '#wordlist with too many filter arguments' do - arguments = %(Allusive Archaic Cant Dated Slang Rare) - it 'raises a 400 error' do - expect { client.wordlist(registers: arguments) } - .to raise_exception(OxfordDictionary::Error, /Do not use more/) - end - end -end diff --git a/spec/fixtures/wordlist_complex.json b/spec/fixtures/wordlist_complex.json deleted file mode 100644 index 070951b..0000000 --- a/spec/fixtures/wordlist_complex.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "metadata": { - "limit": 5000, - "sourceLanguage": "en", - "total": 11, - "offset": 0, - "provider": "Oxford University Press" - }, - "results": [ - { - "matchType": "headword", - "matchString": "goal", - "word": "goal area", - "id": "goal_area" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal average", - "id": "goal_average" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal cage", - "id": "goal_cage" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal difference", - "id": "goal_difference" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goalie", - "id": "goalie" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal kick", - "id": "goal_kick" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal line", - "id": "goal_line" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goalmouth", - "id": "goalmouth" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal sneak", - "id": "goal_sneak" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goaltending", - "id": "goaltending" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal umpire", - "id": "goal_umpire" - } - ] -} diff --git a/spec/fixtures/wordlist_goal_advanced.json b/spec/fixtures/wordlist_goal_advanced.json deleted file mode 100644 index 7f2f2d0..0000000 --- a/spec/fixtures/wordlist_goal_advanced.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "metadata": { - "limit": 5000, - "sourceLanguage": "en", - "total": 9, - "offset": 0, - "provider": "Oxford University Press" - }, - "results": [ - { - "matchType": "headword", - "matchString": "goal", - "word": "goal area", - "id": "goal_area" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal cage", - "id": "goal_cage" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goalhanger", - "id": "goalhanger" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goalie", - "id": "goalie" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal kick", - "id": "goal_kick" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal line", - "id": "goal_line" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goalmouth", - "id": "goalmouth" - }, - { - "matchType": "headword", - "matchString": "goal", - "word": "goal sneak", - "id": "goal_sneak" - }, - { - "matchType": "variantForm", - "matchString": "goal_poacher", - "word": "poacher", - "id": "poacher" - } - ] -} diff --git a/spec/fixtures/wordlist_rare_art.json b/spec/fixtures/wordlist_rare_art.json deleted file mode 100644 index 1700792..0000000 --- a/spec/fixtures/wordlist_rare_art.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "metadata": { - "limit": 5000, - "sourceLanguage": "en", - "total": 3, - "offset": 0, - "provider": "Oxford University Press" - }, - "results": [ - { - "word": "eurhythmic", - "id": "eurhythmic" - }, - { - "word": "storiated", - "id": "storiated" - }, - { - "word": "xylography", - "id": "xylography" - } - ] -}