tencentcloud-sdk-nlp 1.0.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/VERSION +1 -0
- data/lib/tencentcloud-sdk-nlp.rb +11 -0
- data/lib/v20190408/client.rb +671 -0
- data/lib/v20190408/models.rb +1623 -0
- metadata +66 -0
@@ -0,0 +1,671 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'json'
|
18
|
+
|
19
|
+
module TencentCloud
|
20
|
+
module Nlp
|
21
|
+
module V20190408
|
22
|
+
class Client < TencentCloud::Common::AbstractClient
|
23
|
+
|
24
|
+
def initialize(credential, region, profile = nil)
|
25
|
+
api_version = '2019-04-08'
|
26
|
+
api_endpoint = 'nlp.tencentcloudapi.com'
|
27
|
+
sdk_version = 'NLP_' + File.read(File.expand_path('../VERSION', __dir__)).strip
|
28
|
+
super(credential, region, api_version, api_endpoint, sdk_version, profile)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
# 利用人工智能算法,自动抽取文本中的关键信息并生成指定长度的文本摘要。可用于新闻标题生成、科技文献摘要生成和商品评论摘要等。
|
33
|
+
|
34
|
+
# @param request: Request instance for AutoSummarization.
|
35
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::AutoSummarizationRequest`
|
36
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::AutoSummarizationResponse`
|
37
|
+
def AutoSummarization(request)
|
38
|
+
body = send_request('AutoSummarization', request.serialize)
|
39
|
+
response = JSON.parse(body)
|
40
|
+
if response['Response'].key?('Error') == false
|
41
|
+
model = AutoSummarizationResponse.new
|
42
|
+
model.deserialize(response['Response'])
|
43
|
+
model
|
44
|
+
else
|
45
|
+
code = response['Response']['Error']['Code']
|
46
|
+
message = response['Response']['Error']['Message']
|
47
|
+
reqid = response['Response']['RequestId']
|
48
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
49
|
+
end
|
50
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
51
|
+
raise e
|
52
|
+
rescue StandardError => e
|
53
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
54
|
+
end
|
55
|
+
|
56
|
+
# 闲聊服务基于腾讯领先的NLP引擎能力、数据运算能力和千亿级互联网语料数据的支持,同时集成了广泛的知识问答能力,可实现上百种自定义属性配置,以及儿童语言风格及说话方式,从而让聊天变得更睿智、简单和有趣。
|
57
|
+
|
58
|
+
|
59
|
+
# @param request: Request instance for ChatBot.
|
60
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::ChatBotRequest`
|
61
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::ChatBotResponse`
|
62
|
+
def ChatBot(request)
|
63
|
+
body = send_request('ChatBot', request.serialize)
|
64
|
+
response = JSON.parse(body)
|
65
|
+
if response['Response'].key?('Error') == false
|
66
|
+
model = ChatBotResponse.new
|
67
|
+
model.deserialize(response['Response'])
|
68
|
+
model
|
69
|
+
else
|
70
|
+
code = response['Response']['Error']['Code']
|
71
|
+
message = response['Response']['Error']['Message']
|
72
|
+
reqid = response['Response']['RequestId']
|
73
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
74
|
+
end
|
75
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
76
|
+
raise e
|
77
|
+
rescue StandardError => e
|
78
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
79
|
+
end
|
80
|
+
|
81
|
+
# 根据指定的名称、描述创建自定义词库。
|
82
|
+
|
83
|
+
# @param request: Request instance for CreateDict.
|
84
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::CreateDictRequest`
|
85
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::CreateDictResponse`
|
86
|
+
def CreateDict(request)
|
87
|
+
body = send_request('CreateDict', request.serialize)
|
88
|
+
response = JSON.parse(body)
|
89
|
+
if response['Response'].key?('Error') == false
|
90
|
+
model = CreateDictResponse.new
|
91
|
+
model.deserialize(response['Response'])
|
92
|
+
model
|
93
|
+
else
|
94
|
+
code = response['Response']['Error']['Code']
|
95
|
+
message = response['Response']['Error']['Message']
|
96
|
+
reqid = response['Response']['RequestId']
|
97
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
98
|
+
end
|
99
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
100
|
+
raise e
|
101
|
+
rescue StandardError => e
|
102
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
103
|
+
end
|
104
|
+
|
105
|
+
# 向指定的词库中添加词条。
|
106
|
+
|
107
|
+
# @param request: Request instance for CreateWordItems.
|
108
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::CreateWordItemsRequest`
|
109
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::CreateWordItemsResponse`
|
110
|
+
def CreateWordItems(request)
|
111
|
+
body = send_request('CreateWordItems', request.serialize)
|
112
|
+
response = JSON.parse(body)
|
113
|
+
if response['Response'].key?('Error') == false
|
114
|
+
model = CreateWordItemsResponse.new
|
115
|
+
model.deserialize(response['Response'])
|
116
|
+
model
|
117
|
+
else
|
118
|
+
code = response['Response']['Error']['Code']
|
119
|
+
message = response['Response']['Error']['Message']
|
120
|
+
reqid = response['Response']['RequestId']
|
121
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
122
|
+
end
|
123
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
124
|
+
raise e
|
125
|
+
rescue StandardError => e
|
126
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
127
|
+
end
|
128
|
+
|
129
|
+
# 删除自定义词库,会附带相应删除词库包含的所有词条。
|
130
|
+
|
131
|
+
# @param request: Request instance for DeleteDict.
|
132
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::DeleteDictRequest`
|
133
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::DeleteDictResponse`
|
134
|
+
def DeleteDict(request)
|
135
|
+
body = send_request('DeleteDict', request.serialize)
|
136
|
+
response = JSON.parse(body)
|
137
|
+
if response['Response'].key?('Error') == false
|
138
|
+
model = DeleteDictResponse.new
|
139
|
+
model.deserialize(response['Response'])
|
140
|
+
model
|
141
|
+
else
|
142
|
+
code = response['Response']['Error']['Code']
|
143
|
+
message = response['Response']['Error']['Message']
|
144
|
+
reqid = response['Response']['RequestId']
|
145
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
146
|
+
end
|
147
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
148
|
+
raise e
|
149
|
+
rescue StandardError => e
|
150
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
151
|
+
end
|
152
|
+
|
153
|
+
# 用于删除自定义词库中的词条。
|
154
|
+
|
155
|
+
# @param request: Request instance for DeleteWordItems.
|
156
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::DeleteWordItemsRequest`
|
157
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::DeleteWordItemsResponse`
|
158
|
+
def DeleteWordItems(request)
|
159
|
+
body = send_request('DeleteWordItems', request.serialize)
|
160
|
+
response = JSON.parse(body)
|
161
|
+
if response['Response'].key?('Error') == false
|
162
|
+
model = DeleteWordItemsResponse.new
|
163
|
+
model.deserialize(response['Response'])
|
164
|
+
model
|
165
|
+
else
|
166
|
+
code = response['Response']['Error']['Code']
|
167
|
+
message = response['Response']['Error']['Message']
|
168
|
+
reqid = response['Response']['RequestId']
|
169
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
170
|
+
end
|
171
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
172
|
+
raise e
|
173
|
+
rescue StandardError => e
|
174
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
175
|
+
end
|
176
|
+
|
177
|
+
# 句法依存分析接口能够分析出句子中词与词之间的相互依存关系,并揭示其句法结构,包括主谓关系、动宾关系、核心关系等等,可用于提取句子主干、提取句子核心词等,在机器翻译、自动问答、知识抽取等领域都有很好的应用。
|
178
|
+
|
179
|
+
# @param request: Request instance for DependencyParsing.
|
180
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::DependencyParsingRequest`
|
181
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::DependencyParsingResponse`
|
182
|
+
def DependencyParsing(request)
|
183
|
+
body = send_request('DependencyParsing', request.serialize)
|
184
|
+
response = JSON.parse(body)
|
185
|
+
if response['Response'].key?('Error') == false
|
186
|
+
model = DependencyParsingResponse.new
|
187
|
+
model.deserialize(response['Response'])
|
188
|
+
model
|
189
|
+
else
|
190
|
+
code = response['Response']['Error']['Code']
|
191
|
+
message = response['Response']['Error']['Message']
|
192
|
+
reqid = response['Response']['RequestId']
|
193
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
194
|
+
end
|
195
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
196
|
+
raise e
|
197
|
+
rescue StandardError => e
|
198
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
199
|
+
end
|
200
|
+
|
201
|
+
# 根据id或名称查询自定义词库信息。
|
202
|
+
|
203
|
+
# @param request: Request instance for DescribeDict.
|
204
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::DescribeDictRequest`
|
205
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::DescribeDictResponse`
|
206
|
+
def DescribeDict(request)
|
207
|
+
body = send_request('DescribeDict', request.serialize)
|
208
|
+
response = JSON.parse(body)
|
209
|
+
if response['Response'].key?('Error') == false
|
210
|
+
model = DescribeDictResponse.new
|
211
|
+
model.deserialize(response['Response'])
|
212
|
+
model
|
213
|
+
else
|
214
|
+
code = response['Response']['Error']['Code']
|
215
|
+
message = response['Response']['Error']['Message']
|
216
|
+
reqid = response['Response']['RequestId']
|
217
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
218
|
+
end
|
219
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
220
|
+
raise e
|
221
|
+
rescue StandardError => e
|
222
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
223
|
+
end
|
224
|
+
|
225
|
+
# 返回属于当前用户的所有自定义词库列表。
|
226
|
+
|
227
|
+
# @param request: Request instance for DescribeDicts.
|
228
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::DescribeDictsRequest`
|
229
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::DescribeDictsResponse`
|
230
|
+
def DescribeDicts(request)
|
231
|
+
body = send_request('DescribeDicts', request.serialize)
|
232
|
+
response = JSON.parse(body)
|
233
|
+
if response['Response'].key?('Error') == false
|
234
|
+
model = DescribeDictsResponse.new
|
235
|
+
model.deserialize(response['Response'])
|
236
|
+
model
|
237
|
+
else
|
238
|
+
code = response['Response']['Error']['Code']
|
239
|
+
message = response['Response']['Error']['Message']
|
240
|
+
reqid = response['Response']['RequestId']
|
241
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
242
|
+
end
|
243
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
244
|
+
raise e
|
245
|
+
rescue StandardError => e
|
246
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
247
|
+
end
|
248
|
+
|
249
|
+
# 输入实体名称,返回实体相关的信息如实体别名、实体英文名、实体详细信息、相关实体等。
|
250
|
+
|
251
|
+
# @param request: Request instance for DescribeEntity.
|
252
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::DescribeEntityRequest`
|
253
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::DescribeEntityResponse`
|
254
|
+
def DescribeEntity(request)
|
255
|
+
body = send_request('DescribeEntity', request.serialize)
|
256
|
+
response = JSON.parse(body)
|
257
|
+
if response['Response'].key?('Error') == false
|
258
|
+
model = DescribeEntityResponse.new
|
259
|
+
model.deserialize(response['Response'])
|
260
|
+
model
|
261
|
+
else
|
262
|
+
code = response['Response']['Error']['Code']
|
263
|
+
message = response['Response']['Error']['Message']
|
264
|
+
reqid = response['Response']['RequestId']
|
265
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
266
|
+
end
|
267
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
268
|
+
raise e
|
269
|
+
rescue StandardError => e
|
270
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
271
|
+
end
|
272
|
+
|
273
|
+
# 输入两个实体,返回两个实体间的关系,例如马化腾与腾讯公司不仅是相关实体,二者还存在隶属关系(马化腾属于腾讯公司)。
|
274
|
+
|
275
|
+
# @param request: Request instance for DescribeRelation.
|
276
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::DescribeRelationRequest`
|
277
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::DescribeRelationResponse`
|
278
|
+
def DescribeRelation(request)
|
279
|
+
body = send_request('DescribeRelation', request.serialize)
|
280
|
+
response = JSON.parse(body)
|
281
|
+
if response['Response'].key?('Error') == false
|
282
|
+
model = DescribeRelationResponse.new
|
283
|
+
model.deserialize(response['Response'])
|
284
|
+
model
|
285
|
+
else
|
286
|
+
code = response['Response']['Error']['Code']
|
287
|
+
message = response['Response']['Error']['Message']
|
288
|
+
reqid = response['Response']['RequestId']
|
289
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
290
|
+
end
|
291
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
292
|
+
raise e
|
293
|
+
rescue StandardError => e
|
294
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
295
|
+
end
|
296
|
+
|
297
|
+
# 三元组查询,主要分为两类,SP查询和PO查询。SP查询表示已知主语和谓语查询宾语,PO查询表示已知宾语和谓语查询主语。每一个SP或PO查询都是一个可独立执行的查询,TQL支持SP查询的嵌套查询,即主语可以是一个嵌套的子查询。其他复杂的三元组查询方法,请参考官网API文档示例。
|
298
|
+
|
299
|
+
# @param request: Request instance for DescribeTriple.
|
300
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::DescribeTripleRequest`
|
301
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::DescribeTripleResponse`
|
302
|
+
def DescribeTriple(request)
|
303
|
+
body = send_request('DescribeTriple', request.serialize)
|
304
|
+
response = JSON.parse(body)
|
305
|
+
if response['Response'].key?('Error') == false
|
306
|
+
model = DescribeTripleResponse.new
|
307
|
+
model.deserialize(response['Response'])
|
308
|
+
model
|
309
|
+
else
|
310
|
+
code = response['Response']['Error']['Code']
|
311
|
+
message = response['Response']['Error']['Message']
|
312
|
+
reqid = response['Response']['RequestId']
|
313
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
314
|
+
end
|
315
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
316
|
+
raise e
|
317
|
+
rescue StandardError => e
|
318
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
319
|
+
end
|
320
|
+
|
321
|
+
# 依据自定义词库的ID,查询对应的词条信息。
|
322
|
+
|
323
|
+
# @param request: Request instance for DescribeWordItems.
|
324
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::DescribeWordItemsRequest`
|
325
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::DescribeWordItemsResponse`
|
326
|
+
def DescribeWordItems(request)
|
327
|
+
body = send_request('DescribeWordItems', request.serialize)
|
328
|
+
response = JSON.parse(body)
|
329
|
+
if response['Response'].key?('Error') == false
|
330
|
+
model = DescribeWordItemsResponse.new
|
331
|
+
model.deserialize(response['Response'])
|
332
|
+
model
|
333
|
+
else
|
334
|
+
code = response['Response']['Error']['Code']
|
335
|
+
message = response['Response']['Error']['Message']
|
336
|
+
reqid = response['Response']['RequestId']
|
337
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
338
|
+
end
|
339
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
340
|
+
raise e
|
341
|
+
rescue StandardError => e
|
342
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
343
|
+
end
|
344
|
+
|
345
|
+
# 基于关键词提取平台,通过对文本内容进行深度分析,提取出文本内容中的关键信息,为用户实现诸如新闻内容关键词自动提取、评论关键词提取等提供基础服务。
|
346
|
+
|
347
|
+
# @param request: Request instance for KeywordsExtraction.
|
348
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::KeywordsExtractionRequest`
|
349
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::KeywordsExtractionResponse`
|
350
|
+
def KeywordsExtraction(request)
|
351
|
+
body = send_request('KeywordsExtraction', request.serialize)
|
352
|
+
response = JSON.parse(body)
|
353
|
+
if response['Response'].key?('Error') == false
|
354
|
+
model = KeywordsExtractionResponse.new
|
355
|
+
model.deserialize(response['Response'])
|
356
|
+
model
|
357
|
+
else
|
358
|
+
code = response['Response']['Error']['Code']
|
359
|
+
message = response['Response']['Error']['Message']
|
360
|
+
reqid = response['Response']['RequestId']
|
361
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
362
|
+
end
|
363
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
364
|
+
raise e
|
365
|
+
rescue StandardError => e
|
366
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
367
|
+
end
|
368
|
+
|
369
|
+
# 词法分析接口提供以下三个功能:
|
370
|
+
|
371
|
+
# 1、智能分词:将连续的自然语言文本,切分成具有语义合理性和完整性的词汇序列;
|
372
|
+
|
373
|
+
# 2、词性标注:为每一个词附上对应的词性,例如名词、代词、形容词、动词等;
|
374
|
+
|
375
|
+
# 3、命名实体识别:快速识别文本中的实体,例如人名、地名、机构名等。
|
376
|
+
|
377
|
+
# 所有的功能均基于千亿级大规模互联网语料进行持续迭代更新,以保证效果不断提升,用户无需担心新词发现、歧义消除、调用性能等问题。目前词法分析已经在泛互联网、金融、政务等不同垂直领域提供业务支持,并取得良好的效果。
|
378
|
+
|
379
|
+
# @param request: Request instance for LexicalAnalysis.
|
380
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::LexicalAnalysisRequest`
|
381
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::LexicalAnalysisResponse`
|
382
|
+
def LexicalAnalysis(request)
|
383
|
+
body = send_request('LexicalAnalysis', request.serialize)
|
384
|
+
response = JSON.parse(body)
|
385
|
+
if response['Response'].key?('Error') == false
|
386
|
+
model = LexicalAnalysisResponse.new
|
387
|
+
model.deserialize(response['Response'])
|
388
|
+
model
|
389
|
+
else
|
390
|
+
code = response['Response']['Error']['Code']
|
391
|
+
message = response['Response']['Error']['Message']
|
392
|
+
reqid = response['Response']['RequestId']
|
393
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
394
|
+
end
|
395
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
396
|
+
raise e
|
397
|
+
rescue StandardError => e
|
398
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
399
|
+
end
|
400
|
+
|
401
|
+
# 查询指定自定义词库中的词条是否存在。
|
402
|
+
|
403
|
+
# @param request: Request instance for SearchWordItems.
|
404
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::SearchWordItemsRequest`
|
405
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::SearchWordItemsResponse`
|
406
|
+
def SearchWordItems(request)
|
407
|
+
body = send_request('SearchWordItems', request.serialize)
|
408
|
+
response = JSON.parse(body)
|
409
|
+
if response['Response'].key?('Error') == false
|
410
|
+
model = SearchWordItemsResponse.new
|
411
|
+
model.deserialize(response['Response'])
|
412
|
+
model
|
413
|
+
else
|
414
|
+
code = response['Response']['Error']['Code']
|
415
|
+
message = response['Response']['Error']['Message']
|
416
|
+
reqid = response['Response']['RequestId']
|
417
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
418
|
+
end
|
419
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
420
|
+
raise e
|
421
|
+
rescue StandardError => e
|
422
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
423
|
+
end
|
424
|
+
|
425
|
+
# 句向量接口能够将输入的句子映射成一个固定维度的向量,用来表示这个句子的语义特征,可用于文本聚类、文本相似度、文本分类等任务,能够显著提高它们的效果。
|
426
|
+
|
427
|
+
# 该句向量服务由腾讯云自然语言处理团队联合微信智言团队共同打造,基于千亿级大规模互联网语料并采用Bert等领先的深度神经网络模型训练而成,在腾讯内部诸多业务的NLP任务上实测效果显著。
|
428
|
+
|
429
|
+
# @param request: Request instance for SentenceEmbedding.
|
430
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::SentenceEmbeddingRequest`
|
431
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::SentenceEmbeddingResponse`
|
432
|
+
def SentenceEmbedding(request)
|
433
|
+
body = send_request('SentenceEmbedding', request.serialize)
|
434
|
+
response = JSON.parse(body)
|
435
|
+
if response['Response'].key?('Error') == false
|
436
|
+
model = SentenceEmbeddingResponse.new
|
437
|
+
model.deserialize(response['Response'])
|
438
|
+
model
|
439
|
+
else
|
440
|
+
code = response['Response']['Error']['Code']
|
441
|
+
message = response['Response']['Error']['Message']
|
442
|
+
reqid = response['Response']['RequestId']
|
443
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
444
|
+
end
|
445
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
446
|
+
raise e
|
447
|
+
rescue StandardError => e
|
448
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
449
|
+
end
|
450
|
+
|
451
|
+
# 情感分析接口能够对带有情感色彩的主观性文本进行分析、处理、归纳和推理,识别出用户的情感倾向,是积极还是消极,并且提供各自概率。
|
452
|
+
|
453
|
+
# 该功能基于千亿级大规模互联网语料和LSTM、BERT等深度神经网络模型进行训练,并持续迭代更新,以保证效果不断提升。
|
454
|
+
|
455
|
+
# @param request: Request instance for SentimentAnalysis.
|
456
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::SentimentAnalysisRequest`
|
457
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::SentimentAnalysisResponse`
|
458
|
+
def SentimentAnalysis(request)
|
459
|
+
body = send_request('SentimentAnalysis', request.serialize)
|
460
|
+
response = JSON.parse(body)
|
461
|
+
if response['Response'].key?('Error') == false
|
462
|
+
model = SentimentAnalysisResponse.new
|
463
|
+
model.deserialize(response['Response'])
|
464
|
+
model
|
465
|
+
else
|
466
|
+
code = response['Response']['Error']['Code']
|
467
|
+
message = response['Response']['Error']['Message']
|
468
|
+
reqid = response['Response']['RequestId']
|
469
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
470
|
+
end
|
471
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
472
|
+
raise e
|
473
|
+
rescue StandardError => e
|
474
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
475
|
+
end
|
476
|
+
|
477
|
+
# 相似词接口能够基于同义词库及词向量技术,检索出与输入词语在语义上最相似的若干个词语,可广泛用于检索系统、问答系统、文档归档等场景。
|
478
|
+
|
479
|
+
# @param request: Request instance for SimilarWords.
|
480
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::SimilarWordsRequest`
|
481
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::SimilarWordsResponse`
|
482
|
+
def SimilarWords(request)
|
483
|
+
body = send_request('SimilarWords', request.serialize)
|
484
|
+
response = JSON.parse(body)
|
485
|
+
if response['Response'].key?('Error') == false
|
486
|
+
model = SimilarWordsResponse.new
|
487
|
+
model.deserialize(response['Response'])
|
488
|
+
model
|
489
|
+
else
|
490
|
+
code = response['Response']['Error']['Code']
|
491
|
+
message = response['Response']['Error']['Message']
|
492
|
+
reqid = response['Response']['RequestId']
|
493
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
494
|
+
end
|
495
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
496
|
+
raise e
|
497
|
+
rescue StandardError => e
|
498
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
499
|
+
end
|
500
|
+
|
501
|
+
# 文本分类接口能够对用户输入的文本进行自动分类,将其映射到具体的类目上,用户只需要提供待分类的文本,而无需关注具体实现。
|
502
|
+
|
503
|
+
# 该功能基于千亿级大规模互联网语料和LSTM、BERT等深度神经网络模型进行训练,并持续迭代更新,以保证效果不断提升。
|
504
|
+
|
505
|
+
# 目前已提供:
|
506
|
+
|
507
|
+
# - 通用领域分类体系,二级分类,包括15个分类类目,分别是汽车、科技、健康、体育、旅行、教育、职业、文化、军事、房产、娱乐、女性、奥运、财经以及其他,适用于通用的场景。
|
508
|
+
|
509
|
+
# - 新闻领域分类体系,五级分类,包括35个一级分类类目,228个二级分类,493个三级分类,204个四级分类,40个五级分类(详细请见附录->文本分类映射表),已应用于腾讯新闻的文章分类。
|
510
|
+
|
511
|
+
# @param request: Request instance for TextClassification.
|
512
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::TextClassificationRequest`
|
513
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::TextClassificationResponse`
|
514
|
+
def TextClassification(request)
|
515
|
+
body = send_request('TextClassification', request.serialize)
|
516
|
+
response = JSON.parse(body)
|
517
|
+
if response['Response'].key?('Error') == false
|
518
|
+
model = TextClassificationResponse.new
|
519
|
+
model.deserialize(response['Response'])
|
520
|
+
model
|
521
|
+
else
|
522
|
+
code = response['Response']['Error']['Code']
|
523
|
+
message = response['Response']['Error']['Message']
|
524
|
+
reqid = response['Response']['RequestId']
|
525
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
526
|
+
end
|
527
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
528
|
+
raise e
|
529
|
+
rescue StandardError => e
|
530
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
531
|
+
end
|
532
|
+
|
533
|
+
# 提供对中文文本的自动纠错功能,能够识别输入文本中的错误片段,定位错误并给出正确的文本结果;支持长度不超过2000字符(含标点符号)的长文本纠错。
|
534
|
+
|
535
|
+
# 此功能是基于千亿级大规模互联网语料和LSTM、BERT等深度神经网络模型进行训练,并持续迭代更新,以保证效果不断提升,是搜索引擎、语音识别、内容审核等功能更好运行的基础之一。
|
536
|
+
|
537
|
+
# @param request: Request instance for TextCorrection.
|
538
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::TextCorrectionRequest`
|
539
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::TextCorrectionResponse`
|
540
|
+
def TextCorrection(request)
|
541
|
+
body = send_request('TextCorrection', request.serialize)
|
542
|
+
response = JSON.parse(body)
|
543
|
+
if response['Response'].key?('Error') == false
|
544
|
+
model = TextCorrectionResponse.new
|
545
|
+
model.deserialize(response['Response'])
|
546
|
+
model
|
547
|
+
else
|
548
|
+
code = response['Response']['Error']['Code']
|
549
|
+
message = response['Response']['Error']['Message']
|
550
|
+
reqid = response['Response']['RequestId']
|
551
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
552
|
+
end
|
553
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
554
|
+
raise e
|
555
|
+
rescue StandardError => e
|
556
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
557
|
+
end
|
558
|
+
|
559
|
+
# 句子相似度接口能够基于深度学习技术来计算一个源句子和多个目标句子的相似度,相似度分值越大的两个句子在语义上越相似。目前仅支持短文本(不超过500字符)的相似度计算,长文本的相似度计算也即将推出。
|
560
|
+
|
561
|
+
# 鉴于句子相似度是一个应用非常广泛的功能,腾讯云自然语言处理团队在Bert等领先的深度神经网络模型的基础上,专门针对文本相似任务进行了优化,并持续迭代更新。基于句子相似度,可以轻松实现诸如文本去重、相似推荐等功能。
|
562
|
+
|
563
|
+
# 接口将以句子数量为单位消耗资源包,而不是调用接口次数为单位。
|
564
|
+
|
565
|
+
# @param request: Request instance for TextSimilarity.
|
566
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::TextSimilarityRequest`
|
567
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::TextSimilarityResponse`
|
568
|
+
def TextSimilarity(request)
|
569
|
+
body = send_request('TextSimilarity', request.serialize)
|
570
|
+
response = JSON.parse(body)
|
571
|
+
if response['Response'].key?('Error') == false
|
572
|
+
model = TextSimilarityResponse.new
|
573
|
+
model.deserialize(response['Response'])
|
574
|
+
model
|
575
|
+
else
|
576
|
+
code = response['Response']['Error']['Code']
|
577
|
+
message = response['Response']['Error']['Message']
|
578
|
+
reqid = response['Response']['RequestId']
|
579
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
580
|
+
end
|
581
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
582
|
+
raise e
|
583
|
+
rescue StandardError => e
|
584
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
585
|
+
end
|
586
|
+
|
587
|
+
# 修改自定义词库元数据信息,包括名称、描述。
|
588
|
+
|
589
|
+
# @param request: Request instance for UpdateDict.
|
590
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::UpdateDictRequest`
|
591
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::UpdateDictResponse`
|
592
|
+
def UpdateDict(request)
|
593
|
+
body = send_request('UpdateDict', request.serialize)
|
594
|
+
response = JSON.parse(body)
|
595
|
+
if response['Response'].key?('Error') == false
|
596
|
+
model = UpdateDictResponse.new
|
597
|
+
model.deserialize(response['Response'])
|
598
|
+
model
|
599
|
+
else
|
600
|
+
code = response['Response']['Error']['Code']
|
601
|
+
message = response['Response']['Error']['Message']
|
602
|
+
reqid = response['Response']['RequestId']
|
603
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
604
|
+
end
|
605
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
606
|
+
raise e
|
607
|
+
rescue StandardError => e
|
608
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
609
|
+
end
|
610
|
+
|
611
|
+
# 词向量接口能够将输入的词语映射成一个固定维度的词向量,用来表示这个词语的语义特征。词向量是很多自然语言处理技术的基础,能够显著提高它们的效果。
|
612
|
+
|
613
|
+
# 该词向量服务由腾讯知文自然语言处理团队联合腾讯AI Lab共同打造。使用的词向量基于千亿级大规模互联网语料并采用AI Lab自研的DSG算法训练而成,开源的词向量包含800多万中文词汇,在覆盖率、新鲜度及准确性等三方面性能突出。
|
614
|
+
|
615
|
+
# 腾讯AI Lab词向量相关资料:
|
616
|
+
|
617
|
+
# https://ai.tencent.com/ailab/zh/news/detial?id=22
|
618
|
+
|
619
|
+
# https://ai.tencent.com/ailab/nlp/zh/embedding.html
|
620
|
+
|
621
|
+
# @param request: Request instance for WordEmbedding.
|
622
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::WordEmbeddingRequest`
|
623
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::WordEmbeddingResponse`
|
624
|
+
def WordEmbedding(request)
|
625
|
+
body = send_request('WordEmbedding', request.serialize)
|
626
|
+
response = JSON.parse(body)
|
627
|
+
if response['Response'].key?('Error') == false
|
628
|
+
model = WordEmbeddingResponse.new
|
629
|
+
model.deserialize(response['Response'])
|
630
|
+
model
|
631
|
+
else
|
632
|
+
code = response['Response']['Error']['Code']
|
633
|
+
message = response['Response']['Error']['Message']
|
634
|
+
reqid = response['Response']['RequestId']
|
635
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
636
|
+
end
|
637
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
638
|
+
raise e
|
639
|
+
rescue StandardError => e
|
640
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
641
|
+
end
|
642
|
+
|
643
|
+
# 词相似度接口能够基于词向量技术来计算两个输入词语的余弦相似度,相似度数值越大的两个词语在语义上越相似。
|
644
|
+
|
645
|
+
# @param request: Request instance for WordSimilarity.
|
646
|
+
# @type request: :class:`Tencentcloud::nlp::V20190408::WordSimilarityRequest`
|
647
|
+
# @rtype: :class:`Tencentcloud::nlp::V20190408::WordSimilarityResponse`
|
648
|
+
def WordSimilarity(request)
|
649
|
+
body = send_request('WordSimilarity', request.serialize)
|
650
|
+
response = JSON.parse(body)
|
651
|
+
if response['Response'].key?('Error') == false
|
652
|
+
model = WordSimilarityResponse.new
|
653
|
+
model.deserialize(response['Response'])
|
654
|
+
model
|
655
|
+
else
|
656
|
+
code = response['Response']['Error']['Code']
|
657
|
+
message = response['Response']['Error']['Message']
|
658
|
+
reqid = response['Response']['RequestId']
|
659
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
|
660
|
+
end
|
661
|
+
rescue TencentCloud::Common::TencentCloudSDKException => e
|
662
|
+
raise e
|
663
|
+
rescue StandardError => e
|
664
|
+
raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
|
665
|
+
end
|
666
|
+
|
667
|
+
|
668
|
+
end
|
669
|
+
end
|
670
|
+
end
|
671
|
+
end
|