Step By Step
step1:開通服務
參考位址目前NLP提供了三個版本,可根據需要選擇合适的,本次調用選用基礎版本

step2:擷取賬号的AccessKey
參考文檔:
擷取AccessKeystep3: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));
}
}