Class: IBMWatson::NLU::Service

Inherits:
BaseService show all
Defined in:
lib/ibm_watson/nlu/service.rb

Defined Under Namespace

Classes: FeatureDefinition

Constant Summary collapse

QUERY_VERSION =
"2017-02-27"

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, url, version

Constructor Details

This class inherits a constructor from IBMWatson::BaseService

Instance Method Details

#analyze_text(text, language: 'en', keywords: false) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ibm_watson/nlu/service.rb', line 12

def analyze_text(text, language: 'en', keywords: false)
  handle_timeout do
    # additional parameters not being implemented:
    #  - html (analyzing html)
    #  - url (analyzing urls)
    #  - clean (not sure what it does yet)

    features = {}
    features[:keywords] = {} if keywords
    # Features not implemented yet:
    # - concepts
    # - categories
    # - emotion
    # - entities
    # - metadata
    # - relations
    # - semantic_roles
    # - sentiment

    parameters = {
      text: text,
      language: language,
      # return_analyzed_text: true,
      features: features,
    }

    result = post "analyze?version=#{QUERY_VERSION}", parameters

    IBMWatson::NLU::AnalyzeResult.new(result)
  end
end