全部产品

简历抽取(中文)服务

更新时间:2020-08-26 14:23

简历抽取服务使用示例。

Java代码示例

  1. DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou","your-access-key-id","your-access-key-secret");
  2. IAcsClient client = new DefaultAcsClient(defaultProfile);
  3. String content = "简历文本";
  4. RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
  5. request.setServiceName("ResumeExtractorZH");
  6. request.setPredictContent(content);
  7. RunPreTrainServiceResponse response = client.getAcsResponse(request);
  8. System.out.println(response.getPredictResult());

Python代码示例

  1. # 安装依赖
  2. pip install aliyun-python-sdk-core
  3. pip install aliyun-python-sdk-nlp-automl
  1. # -*- coding: utf8 -*-
  2. import json
  3. from aliyunsdkcore.client import AcsClient
  4. from aliyunsdkcore.acs_exception.exceptions import ClientException
  5. from aliyunsdkcore.acs_exception.exceptions import ServerException
  6. from aliyunsdknlp_automl.request.v20191111 import RunPreTrainServiceRequest
  7. # Initialize AcsClient instance
  8. client = AcsClient(
  9. "<your-access-key-id>",
  10. "<your-access-key-secret>",
  11. "cn-hangzhou"
  12. );
  13. content = '简历文本'
  14. # Initialize a request and set parameters
  15. request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
  16. request.set_ServiceName('ResumeExtractorZH')
  17. request.set_PredictContent(content)
  18. # Print response
  19. response = client.do_action_with_exception(request)
  20. resp_obj = json.loads(response)
  21. predict_result = json.loads(resp_obj['PredictResult'])
  22. print(predict_result['result'])
说明 调用简历抽取(中文)服务,ServiceName需要传入:ResumeExtractorZH

PredictContent内容示例

说明 PredictContent参数为简历文本参数。

PredictResult内容示例

说明 PredictResult是JSON字符串,需要反序列化之后进行解析,具体结构如下示例。
  1. {
  2. "ret_code": 0,
  3. "result": [{
  4. "id": 0,
  5. "tags": [{
  6. "class": "姓名",
  7. "source": "rule",
  8. "span": "张维"
  9. }],
  10. "sentence": "张维 ID:61969461",
  11. "sent_offsets": 0
  12. }, {
  13. "id": 0,
  14. "tags": [{
  15. "conf": 0,
  16. "class": "手机号",
  17. "span": "186xxxx329",
  18. "start": 0,
  19. "source": "model",
  20. "end": 11
  21. }],
  22. "sentence": "18664347329",
  23. "sent_offsets": 2
  24. }, {
  25. "id": 0,
  26. "tags": [{
  27. "class": "电子邮箱",
  28. "source": "rule",
  29. "span": "wwt5150@126.com"
  30. }],
  31. "sentence": "wwt5150@126.com",
  32. "sent_offsets": 3
  33. }, {
  34. "id": 0,
  35. "tags": [{
  36. "conf": 0,
  37. "class": "出生日期",
  38. "span": "1990/07/27",
  39. "start": 8,
  40. "source": "model",
  41. "end": 18
  42. }, {
  43. "class": "性别",
  44. "source": "rule",
  45. "span": "男"
  46. }],
  47. "sentence": "男|29 岁 (1990/07/27)|现居住南京-玄武区|8年工作经验",
  48. "sent_offsets": 4
  49. }, {
  50. "id": 0,
  51. "tags": [{
  52. "conf": 0,
  53. "class": "岗位名称",
  54. "span": "软件测试工程师",
  55. "start": 4,
  56. "source": "model",
  57. "end": 11
  58. }],
  59. "sentence": "职位: 软件测试工程师",
  60. "sent_offsets": 6
  61. }],
  62. "message": "",
  63. "time": 143
  64. }

出参result是一个JSON字符串,是一个JsonArray结构。