概述
阿裡雲自然語言處理(Natural Language Processing)是為各類企業及開發者提供的用于文本分析及挖掘的核心工具,旨在幫助使用者高效的處理文本,已經廣泛應用在電商、文化娛樂、金融、物流等行業客戶的多項業務中,取得了良好的效果。這裡主要針對目前官方文檔中參考Demo使用SDK較老且本身中文列印輸出異常的問題,提供包括SDK安裝步驟+正常可用示例.NET Demo。
操作步驟
1、Nuget 安裝
aliyun-net-sdk-coreInstall-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、功能快速測試