Module: NexosisApi::Client::Vocabulary
- Included in:
- NexosisApi::Client
- Defined in:
- lib/nexosis_api/client/vocabulary.rb
Overview
Vocabluary-based API operations
Instance Method Summary collapse
-
#get_vocabulary(vocabulary_id, type = 'word', page = 0, page_size = 50) ⇒ NexosisApi::PagedArray of NexosisApi::VocabularyWord
Gets a list of Vocabulary Words from a vocabulary.
-
#list_vocabularies(datasource_name = nil, created_from_session = nil, page = 0, page_size = 50) ⇒ NexosisApi::PagedArray of NexosisApi::VocabularySummary
Gets summary information about the Vocabulary built from the Text columns in a session vocabularies created for this data source name.
Instance Method Details
#get_vocabulary(vocabulary_id, type = 'word', page = 0, page_size = 50) ⇒ NexosisApi::PagedArray of NexosisApi::VocabularyWord
Note:
words will be sorted in rank order
Gets a list of Vocabulary Words from a vocabulary
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/nexosis_api/client/vocabulary.rb', line 42 def get_vocabulary(vocabulary_id, type = 'word', page = 0, page_size = 50) raise ArgumentError, 'vocabulary_id was not provided and is not optional' if vocabulary_id.nil? vocab_url = "/vocabulary/#{vocabulary_id}" query = { page: page, pageSize: page_size } query.store('type', type) unless type.nil? response = self.class.get(vocab_url, headers: @headers, query: query) raise HttpException.new("There was a problem getting a vocabulary: #{response.code}.", "getting vocabulary #{vocabulary_id}", response) unless response.success? NexosisApi::PagedArray.new(response.parsed_response, response.parsed_response['items'] .map { |item| NexosisApi::VocabularyWord.new(item) }) end |
#list_vocabularies(datasource_name = nil, created_from_session = nil, page = 0, page_size = 50) ⇒ NexosisApi::PagedArray of NexosisApi::VocabularySummary
Gets summary information about the Vocabulary built from the Text columns in a session vocabularies created for this data source name. vocabularies created for the given session.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nexosis_api/client/vocabulary.rb', line 17 def list_vocabularies(datasource_name = nil, created_from_session=nil, page = 0, page_size = 50) vocab_url = '/vocabulary' query = { page: page, pageSize: page_size } query.store('created_from_session', datasource_name) unless created_from_session.nil? query.store('dataSourceName', datasource_name) unless datasource_name.nil? response = self.class.get(vocab_url, headers: @headers, query: query) raise HttpException.new("There was a problem listing vocabularies: #{response.code}.", "listing vocabularies with data source name #{datasource_name}", response) unless response.success? NexosisApi::PagedArray.new(response.parsed_response, response.parsed_response['items'] .map { |item| NexosisApi::VocabularySummary.new(item) }) end |