概述
阿里云自然语言处理(Natural Language Processing)是为各类企业及开发者提供的用于文本分析及挖掘的核心工具,旨在帮助用户高效的处理文本,已经广泛应用在电商、文化娱乐、金融、物流等行业客户的多项业务中,取得了良好的效果。这里主要针对目前官方文档中参考Demo使用SDK较老且本身中文打印输出异常的问题,提供包括SDK安装步骤+正常可用示例.NET Demo。
操作步骤
1、Nuget 安装aliyun-net-sdk-core
Install-Package aliyun-net-sdk-core -Version 1.5.3
2、测试Demo
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Http;
using Aliyun.Acs.Core.Profile;
using System;
namespace NLPDemo
{
class Program
{
static void Main(string[] args)
{
// ak,sk 获取参考链接:https://yq.aliyun.com/articles/693979
string accessKeyId = "******";
string accessKeySecret = "******";
IClientProfile profile = DefaultProfile.GetProfile("cn-shanghai", accessKeyId, accessKeySecret);
IAcsClient client = new DefaultAcsClient(profile);
string postBody = "{\"text\": \"China真丝韩都衣舍连衣裙\"}";
CommonRequest request = new CommonRequest();
request.Domain = "nlp.cn-shanghai.aliyuncs.com";
request.UriPattern = "/nlp/api/wordpos/general";
request.Method = MethodType.POST;
request.SetContent(System.Text.Encoding.UTF8.GetBytes(postBody), "utf-8", FormatType.JSON);
request.AddHeadParameters("x-acs-signature-method", "HMAC-SHA1");
request.AddHeadParameters("x-acs-signature-nonce", System.Guid.NewGuid().ToString());
request.Action = "None";
request.Version = "2018-04-08";
CommonResponse response = client.GetCommonResponse(request);
Console.WriteLine(response.Data);
Console.ReadKey();
}
}
}
3、测试结果
4、控制台功能快速测试
a、测试地址进入
b、功能快速测试