全部产品
云市场
云游戏

JAVA SDK

更新时间:2020-08-27 11:38:33

JAVA SDK简介

JAVA 依赖

  1. <dependency>
  2. <groupId>com.aliyun</groupId>
  3. <artifactId>aliyun-java-sdk-alinlp</artifactId>
  4. <version>1.0.15</version>
  5. </dependency>

DEMO

  1. package mit.alinlp;
  2. import com.aliyuncs.DefaultAcsClient;
  3. import com.aliyuncs.IAcsClient;
  4. // 这里以词性标注为例,其它算法的API名称和参数请参考文档
  5. import com.aliyuncs.alinlp.model.v20200629.GetPosChEcomRequest;
  6. import com.aliyuncs.alinlp.model.v20200629.GetPosChEcomResponse;
  7. import com.aliyuncs.exceptions.ClientException;
  8. import com.aliyuncs.profile.DefaultProfile;
  9. public class TestCloud {
  10. public static void main(String[] args) throws ClientException {
  11. DefaultProfile defaultProfile = DefaultProfile.getProfile(
  12. "cn-hangzhou",
  13. "XXXX",
  14. "XXXX");
  15. IAcsClient client = new DefaultAcsClient(defaultProfile);
  16. GetPosChEcomRequest request = new GetPosChEcomRequest();
  17. request.setSysEndpoint("alinlp.cn-hangzhou.aliyuncs.com");
  18. request.setServiceCode("alinlp");
  19. request.setText("这是一条文本");
  20. request.setTokenizerId("MAINSE");
  21. long start = System.currentTimeMillis();
  22. GetPosChEcomResponse response = client.getAcsResponse(request);
  23. System.out.println(response.hashCode());
  24. System.out.println(response.getRequestId() + "\n" + response.getData() + "\n" + "cost:" + (System.currentTimeMillis()- start));
  25. }
  26. }