Step By Step
step1:开通服务
参考地址
目前NLP提供了三个版本,可根据需要选择合适的,本次调用选用基础版本
step2:获取账号的AccessKey
参考文档:获取AccessKey
step3:Java SDK Code
package org.nlp;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.alinlp.model.v20200629.GetPosChEcomRequest;
import com.aliyuncs.alinlp.model.v20200629.GetPosChEcomResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
public class GetEcChGeneral {
public static void main(String[] args) throws ClientException {
DefaultProfile defaultProfile = DefaultProfile.getProfile(
"cn-hangzhou",
"ak",
"sk");
IAcsClient client = new DefaultAcsClient(defaultProfile);
GetPosChEcomRequest request = new GetPosChEcomRequest();
request.setSysEndpoint("alinlp.cn-hangzhou.aliyuncs.com");
request.setActionName("GetWsChGeneral");
request.setServiceCode("alinlp");
request.setText("1997年我学会了开汽车");
request.setTokenizerId("GENERAL_CHN");
long start = System.currentTimeMillis();
GetPosChEcomResponse response = client.getAcsResponse(request);
System.out.println(response.hashCode());
System.out.println(response.getRequestId() + "\n" + response.getData() + "\n" + "cost:" + (System.currentTimeMillis()- start));
}
}