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);
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            string path       = FileName.Get(context);
            string API_KEY    = APIKey.Get(context);
            string SECRET_KEY = SecretKey.Get(context);

            img = image.Get(context);
            try
            {
                if (path != null)
                {
                    by = SaveImage(path);
                }
                else
                {
                    by = ConvertImageToByte(img);
                }
                var client = new Ocr(API_KEY, SECRET_KEY);
                //修改超时时间
                client.Timeout = 60000;
                //参数设置
                var options = new Dictionary <string, object>
                {
                    { "detect_direction", detect_direction.ToString().ToLower() },
                    { "probability", probability.ToString().ToLower() }
                };
                //带参数调用通用文字识别(高精度版)
                string result = client.AccurateBasic(by, options).ToString();
                Result.Set(context, result);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, Localize.LocalizedResources.GetString("msgErrorOccurred"), e.Message);
            }
        }
示例#3
0
        protected override void Execute(CodeActivityContext context)
        {
            string text1  = Text1.Get(context);
            string text2  = Text2.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>
                {
                    { "model", model }
                };
                //带参数调用短文本相似度
                string result = client.Simnet(text1, text2, options).ToString();
                Result.Set(context, result);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message);
            }
        }
示例#4
0
        protected override void Execute(CodeActivityContext context)
        {
            string path       = FileName.Get(context);
            string API_KEY    = APIKey.Get(context);
            string SECRET_KEY = SecretKey.Get(context);

            img = image.Get(context);
            try
            {
                if (path != null)
                {
                    by = SaveImage(path);
                }
                else
                {
                    by = ConvertImageToByte(img);
                }
                var client = new Ocr(API_KEY, SECRET_KEY);
                //修改超时时间
                client.Timeout = 60000;
                //参数设置
                var options = new Dictionary <string, object>
                {
                    { "detect_direction", detect_direction.ToString().ToLower() },
                    { "detect_language", detect_language.ToString().ToLower() }
                };
                //带参数调用网络图片文字识别
                string result = client.WebImage(by, options).ToString();
                Result.Set(context, result);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message);
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            string content = Content.Get(context);
            string apiKey  = APIKey.Get(context);
            string seKey   = SecretKey.Get(context);
            string title   = Title.Get(context);
            int    maxlen  = MaxLen.Get(context);

            try
            {
                var client = new Baidu.Aip.Nlp.Nlp(apiKey, seKey);
                // 修改超时时间
                client.Timeout = 60000;
                //设置可选参数
                var options = new Dictionary <string, object>
                {
                    { "title", title }
                };
                //带参数调用新闻摘要接口
                string result = client.NewsSummary(content, maxlen, options).ToString();
                Result.Set(context, result);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message);
            }
        }
示例#6
0
        protected override IOcrClient GetOcrClient(AsyncCodeActivityContext context)
        {
            var secretId  = SecretId.Get(context);
            var secretKey = SecretKey.Get(context);
            var region    = Region.Get(context);

            return(new TencentOcrClient(secretId, secretKey, region));
        }
示例#7
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                var cmd = new EC2Connector(AccessKey.Get(context), SecretKey.Get(context), Region.Get(context));

                cmd.CreateInstance(AmiID.Get(context), KeyPairName.Get(context), InstanceType.Get(context));
                Response.Set(context, "Complete");
            }
            catch (Exception e)
            {
                Error.Set(context, e.Message);
            }
        }
示例#8
0
        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;
                //调用词向量表示
                string result = client.WordEmbedding(text).ToString();
                Result.Set(context, result);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message);
            }
        }
示例#9
0
        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;
                //调用词法分析
                string result = client.Lexer(text).ToString();
                Result.Set(context, result);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, Localize.LocalizedResources.GetString("msgErrorOccurred"), e.Message);
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            string path       = FileName.Get(context);
            string API_KEY    = APIKey.Get(context);
            string SECRET_KEY = SecretKey.Get(context);

            img = image.Get(context);
            try
            {
                if (path != null)
                {
                    by = SaveImage(path);
                }
                else
                {
                    by = ConvertImageToByte(img);
                }
                var client = new Ocr(API_KEY, SECRET_KEY);
                //修改超时时间
                client.Timeout = 60000;
                //参数设置
                var options = new Dictionary <string, object>
                {
                    { "detect_direction", detect_direction.ToString().ToLower() },
                    { "probability", probability.ToString().ToLower() }
                };
                //带参数调用通用文字识别(高精度版)
                var json = client.AccurateBasic(by, options).ToString();
                Console.WriteLine(json);
                var result = JsonConvert.DeserializeObject <BaiDuOCRHighPrecisionResult>(json);
                Result.Set(context, result);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message);
            }
        }
示例#11
0
        protected override void Execute(CodeActivityContext context)
        {
            try {
                var mUniversalDataHandler = new AwsS3DataHandler(AccessKey.Get(context), SecretKey.Get(context), Region.Get(context));

                mUniversalDataHandler.CreateDir(Generate(SourcePath.Get(context), BucketName.Get(context)));
                Response.Set(context, "Complete");
            }
            catch (Exception e) {
                Error.Set(context, e.Message);
            }
        }
示例#12
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                var cmd = new CloudComputeConnector(Email.Get(context), AccessKey.Get(context), SecretKey.Get(context));

                cmd.InsertInstance(Region.Get(context), VmName.Get(context), AmiID.Get(context), ImgProject.Get(context));
                Response.Set(context, "Complete");
            }
            catch (Exception e)
            {
                Error.Set(context, e.Message);
            }
        }