protected override void Execute(CodeActivityContext context)
        {
            string text   = Text.Get(context);
            string apiKey = APIKey.Get(context);
            string seKey  = SecretKey.Get(context);

            try
            {
                var client = new Baidu.Aip.Nlp.Nlp(apiKey, seKey);
                //修改超时时间
                client.Timeout = 60000;
                //设置可选参数
                var options = new Dictionary <string, object>
                {
                    { "type", type }
                };
                //带参数调用评论观点抽取
                string result = client.CommentTag(text, options).ToString();
                Result.Set(context, result);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, Localize.LocalizedResources.GetString("msgErrorOccurred"), e.Message);
            }
        }
Ejemplo n.º 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            //评论观点
            // 如果有可选参数
            var options = new Dictionary <string, object> {
                { "type", 13 }
            };
            // 带参数调用评论观点抽取
            JObject obj = client.CommentTag(richTextBox3.Text, options);

            richTextBox4.Text = Convert.ToString(obj);
            Console.WriteLine(obj);
        }