Module: Textalytics::Api::Base

Includes:
ClassificationEntity, LanguageEntity, SentimentEntity, TopicsEntity, Helpers
Included in:
Client
Defined in:
lib/textalytics/api/base.rb

Constant Summary

Constants included from Helpers

Helpers::CLASSIFICATION, Helpers::LANGUAGE, Helpers::SENTIMENT, Helpers::TOPICS

Instance Method Summary collapse

Instance Method Details

#classification(options = {}) ⇒ Object

Classification API



14
15
16
17
18
19
20
# File 'lib/textalytics/api/base.rb', line 14

def classification(options={})
  options[:key] = @classification_key
  options[:of] = 'json'
  query = { query: options}
  response = get(CLASSIFICATION, query)
  Classification.new(response)
end

#language(options = {}) ⇒ Object

Language Identification API



50
51
52
53
54
55
56
# File 'lib/textalytics/api/base.rb', line 50

def language(options = {})
  options[:key] = @language_key
  options[:of] = 'json'
  query = { query: options}
  response = get(LANGUAGE, query)
  Language.new(response)
end

#sentiment(options = {}) ⇒ Object

Sentiment API



25
26
27
28
29
30
31
# File 'lib/textalytics/api/base.rb', line 25

def sentiment(options = {})
  options[:key] = @sentiment_key
  options[:of] = 'json'
  query = { query: options}
  response = get(SENTIMENT, query)
  Sentiment.new(response)
end

#topics(options = {}) ⇒ Object

Topics Extraction API



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/textalytics/api/base.rb', line 35

def topics(options = {})
  options[:key] = @topics_key
  options[:of] = 'json'

  unless options.has_key?(:tt)
    options[:tt] = 'a'
  end

  query = { query: options}
  response = get(TOPICS, query)
  Topics.new(response)
end