Class: MeaningCloud::Topics

Inherits:
Object
  • Object
show all
Defined in:
lib/meaning_cloud/topics.rb

Overview

A class to hold all topic extraction related code.

Class Method Summary collapse

Class Method Details

.extract_topics(options = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/meaning_cloud/topics.rb', line 4

def self.extract_topics(options = nil)
  fail(Exception, 'Missing key') if MeaningCloud.configuration.key.nil?

  options ||= {}

  options = {
    of: :json,
    key: MeaningCloud.configuration.key,
    lang: :en,
    tt: 'ec',
    uw: 'y'
  }.merge(options)

  query = URI.encode_www_form(options)

  result = RestClient.post("#{API_BASE}?#{query}", {})
  JSON.parse(result)
end