Class: TxNlp::Text

Inherits:
Base
  • Object
show all
Defined in:
lib/tx_nlp/text.rb

Constant Summary

Constants inherited from Base

Base::HOST

Instance Method Summary collapse

Methods inherited from Base

#encode_parameters, #fixed_paramaters, #full_request_url, #json, #orginal_parameters, #region, #request_object, #request_params, #secret_id, #secret_key, #signature, #string_for_sign, #to_params, #url

Constructor Details

#initialize(text, action_type = 'SimilarWords') ⇒ Text

Returns a new instance of Text.



5
6
7
8
9
# File 'lib/tx_nlp/text.rb', line 5

def initialize(text, action_type = 'SimilarWords')
  @action_type = action_type
  @encode_text = text.tr("\n", ' ')
  @escape_text = CGI.escape(@encode_text)
end

Instance Method Details

#indent_resultObject



19
20
21
22
23
24
25
26
27
# File 'lib/tx_nlp/text.rb', line 19

def indent_result
  if json['Response']['Error']
    json
  else
    new_content = raw_result.join(',')

    new_content
  end
end

#raw_resultObject



11
12
13
14
15
16
17
# File 'lib/tx_nlp/text.rb', line 11

def raw_result
  if json['Response']['Error']
    json
  else
    original_data = json['Response']["SimilarWords"]
  end
end