Class: TencentCloud::Nlp::V20190408::Client

Inherits:
Common::AbstractClient
  • Object
show all
Defined in:
lib/v20190408/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(credential, region, profile = nil) ⇒ Client

Returns a new instance of Client.



24
25
26
27
28
29
# File 'lib/v20190408/client.rb', line 24

def initialize(credential, region, profile = nil)
    api_version = '2019-04-08'
    api_endpoint = 'nlp.tencentcloudapi.com'
    sdk_version = 'NLP_' + File.read(File.expand_path('../VERSION', __dir__)).strip
    super(credential, region, api_version, api_endpoint, sdk_version, profile)
end

Instance Method Details

#AnalyzeSentiment(request) ⇒ Object

@rtype: :class:‘Tencentcloud::nlp::V20190408::AnalyzeSentimentResponse`

Parameters:

  • request:

    Request instance for AnalyzeSentiment.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/v20190408/client.rb', line 37

def AnalyzeSentiment(request)
  body = send_request('AnalyzeSentiment', request.serialize)
  response = JSON.parse(body)
  if response['Response'].key?('Error') == false
    model = AnalyzeSentimentResponse.new
    model.deserialize(response['Response'])
    model
  else
    code = response['Response']['Error']['Code']
    message = response['Response']['Error']['Message']
    reqid = response['Response']['RequestId']
    raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
  end
rescue TencentCloud::Common::TencentCloudSDKException => e
  raise e
rescue StandardError => e
  raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
end

#ClassifyContent(request) ⇒ Object

@rtype: :class:‘Tencentcloud::nlp::V20190408::ClassifyContentResponse`

Parameters:

  • request:

    Request instance for ClassifyContent.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/v20190408/client.rb', line 63

def ClassifyContent(request)
  body = send_request('ClassifyContent', request.serialize)
  response = JSON.parse(body)
  if response['Response'].key?('Error') == false
    model = ClassifyContentResponse.new
    model.deserialize(response['Response'])
    model
  else
    code = response['Response']['Error']['Code']
    message = response['Response']['Error']['Message']
    reqid = response['Response']['RequestId']
    raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
  end
rescue TencentCloud::Common::TencentCloudSDKException => e
  raise e
rescue StandardError => e
  raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
end

#ComposeCouplet(request) ⇒ Object

@rtype: :class:‘Tencentcloud::nlp::V20190408::ComposeCoupletResponse`

Parameters:

  • request:

    Request instance for ComposeCouplet.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/v20190408/client.rb', line 89

def ComposeCouplet(request)
  body = send_request('ComposeCouplet', request.serialize)
  response = JSON.parse(body)
  if response['Response'].key?('Error') == false
    model = ComposeCoupletResponse.new
    model.deserialize(response['Response'])
    model
  else
    code = response['Response']['Error']['Code']
    message = response['Response']['Error']['Message']
    reqid = response['Response']['RequestId']
    raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
  end
rescue TencentCloud::Common::TencentCloudSDKException => e
  raise e
rescue StandardError => e
  raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
end

#EvaluateSentenceSimilarity(request) ⇒ Object

@rtype: :class:‘Tencentcloud::nlp::V20190408::EvaluateSentenceSimilarityResponse`

Parameters:

  • request:

    Request instance for EvaluateSentenceSimilarity.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/v20190408/client.rb', line 115

def EvaluateSentenceSimilarity(request)
  body = send_request('EvaluateSentenceSimilarity', request.serialize)
  response = JSON.parse(body)
  if response['Response'].key?('Error') == false
    model = EvaluateSentenceSimilarityResponse.new
    model.deserialize(response['Response'])
    model
  else
    code = response['Response']['Error']['Code']
    message = response['Response']['Error']['Message']
    reqid = response['Response']['RequestId']
    raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
  end
rescue TencentCloud::Common::TencentCloudSDKException => e
  raise e
rescue StandardError => e
  raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
end

#ParseWords(request) ⇒ Object

@rtype: :class:‘Tencentcloud::nlp::V20190408::ParseWordsResponse`

Parameters:

  • request:

    Request instance for ParseWords.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/v20190408/client.rb', line 139

def ParseWords(request)
  body = send_request('ParseWords', request.serialize)
  response = JSON.parse(body)
  if response['Response'].key?('Error') == false
    model = ParseWordsResponse.new
    model.deserialize(response['Response'])
    model
  else
    code = response['Response']['Error']['Code']
    message = response['Response']['Error']['Message']
    reqid = response['Response']['RequestId']
    raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
  end
rescue TencentCloud::Common::TencentCloudSDKException => e
  raise e
rescue StandardError => e
  raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
end

#SentenceCorrection(request) ⇒ Object

@rtype: :class:‘Tencentcloud::nlp::V20190408::SentenceCorrectionResponse`

Parameters:

  • request:

    Request instance for SentenceCorrection.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/v20190408/client.rb', line 163

def SentenceCorrection(request)
  body = send_request('SentenceCorrection', request.serialize)
  response = JSON.parse(body)
  if response['Response'].key?('Error') == false
    model = SentenceCorrectionResponse.new
    model.deserialize(response['Response'])
    model
  else
    code = response['Response']['Error']['Code']
    message = response['Response']['Error']['Message']
    reqid = response['Response']['RequestId']
    raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
  end
rescue TencentCloud::Common::TencentCloudSDKException => e
  raise e
rescue StandardError => e
  raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
end