Ejemplo n.º 1
0
        /// <summary>
        /// 自动摘要
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public RES AutoSummarization(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);
                AutoSummarizationRequest req = new AutoSummarizationRequest();
                string strParams             = JSON.ToJson(new { Text = input });
                req = AutoSummarizationRequest.FromJsonString <AutoSummarizationRequest>(strParams);
                AutoSummarizationResponse resp = client.AutoSummarization(req).
                                                 ConfigureAwait(false).GetAwaiter().GetResult();
                return(RES.OK(resp));
            }
            catch (Exception ex)
            {
                return(RES.FAIL(ex.Message));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 利用人工智能算法,自动抽取文本中的关键信息并生成指定长度的文本摘要。可用于新闻标题生成、科技文献摘要生成和商品评论摘要等。
        /// </summary>
        /// <param name="req"><see cref="AutoSummarizationRequest"/></param>
        /// <returns><see cref="AutoSummarizationResponse"/></returns>
        public AutoSummarizationResponse AutoSummarizationSync(AutoSummarizationRequest req)
        {
            JsonResponseModel <AutoSummarizationResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "AutoSummarization");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <AutoSummarizationResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }