/// <summary> /// 关键词提取 /// </summary> /// <returns></returns> public RES KeywordsExtraction(string input) { try { Credential cred = new Credential { SecretId = secretId, SecretKey = secretKey }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("nlp.ap-shanghai.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; NlpClient client = new NlpClient(cred, "ap-guangzhou", clientProfile); KeywordsExtractionRequest req = new KeywordsExtractionRequest(); string strParams = JSON.ToJson(new { Text = input }); req = KeywordsExtractionRequest.FromJsonString <KeywordsExtractionRequest>(strParams); KeywordsExtractionResponse resp = client.KeywordsExtraction(req). ConfigureAwait(false).GetAwaiter().GetResult(); return(RES.OK(resp.Keywords.ToList())); } catch (Exception ex) { return(RES.FAIL(ex.Message)); } }
/// <summary> /// 基于关键词提取平台,通过对文本内容进行深度分析,提取出文本内容中的关键信息,为用户实现诸如新闻内容关键词自动提取、评论关键词提取等提供基础服务。 /// </summary> /// <param name="req"><see cref="KeywordsExtractionRequest"/></param> /// <returns><see cref="KeywordsExtractionResponse"/></returns> public KeywordsExtractionResponse KeywordsExtractionSync(KeywordsExtractionRequest req) { JsonResponseModel <KeywordsExtractionResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "KeywordsExtraction"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <KeywordsExtractionResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }