电销场景对话行业分类

电销场景对话行业分类服务适用于电话销售外呼场景,针对对话应用按照行业和场景进行分类,可应用于语音质检。使用示例如下。

Java代码示例

  1. class MsgDO{
  2. private String role;
  3. private String words;
  4. public MsgDO(String role,String words) {
  5. this.role = role;
  6. this.words = words;
  7. }
  8. public String getRole() {
  9. return role;
  10. }
  11. public void setRole(String role) {
  12. this.role = role;
  13. }
  14. public String getWords() {
  15. return words;
  16. }
  17. public void setWords(String words) {
  18. this.words = words;
  19. }
  20. }
  21. DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou","your-access-id-key","your-access-id-secret");
  22. IAcsClient client = new DefaultAcsClient(defaultProfile);
  23. Map<String, Object> obj = new HashMap<String, Object>();
  24. List<MsgDO> msgs = new ArrayList<MsgDO>();
  25. msgs.add(new MsgDO("客户","喂,你好。"));
  26. msgs.add(new MsgDO("客服","哎,你好,我们这边是加米艺术。"));
  27. msgs.add(new MsgDO("客服","近期我们有一场儿童的创意绘画体验课活动。邀请您和呃我们在崇川区的成山路城市嘉苑这边。"));
  28. msgs.add(new MsgDO("客服","邀请您和呃我们在崇川区的成山路城市嘉苑这边。"));
  29. msgs.add(new MsgDO("客户","在哪里?"));
  30. msgs.add(new MsgDO("客户","哦,不方便不方便。行,谢谢再见。。"));
  31. obj.put("msgs",msgs);
  32. obj.put("session_id",123);
  33. RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
  34. request.setServiceName("NLP-Dialog-Industry");
  35. request.setPredictContent(JSON.toJSONString(obj));
  36. RunPreTrainServiceResponse response = client.getAcsResponse(request);
  37. 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. "session_id": 123,
  15. "msgs":[
  16. {
  17. "role": "客户",
  18. "words": "喂,你好。"
  19. },
  20. {
  21. "role": "客服",
  22. "words": "哎,你好,我们这边是加米艺术。"
  23. },
  24. {
  25. "role": "客服",
  26. "words": "近期我们有一场儿童的创意绘画体验课活动。邀请您和呃我们在崇川区的成山路城市嘉苑这边。"
  27. },
  28. {
  29. "role": "客服",
  30. "words": "邀请您和呃我们在崇川区的成山路城市嘉苑这边。"
  31. },
  32. {
  33. "role": "客户",
  34. "words": "在哪里?"
  35. },
  36. {
  37. "role": "客户",
  38. "words": "哦,不方便不方便。行,谢谢再见。"
  39. }
  40. ]
  41. }
  42. # Initialize a request and set parameters
  43. request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
  44. request.set_ServiceName('NLP-Dialog-Industry')
  45. request.set_PredictContent(json.dumps(content))
  46. # Print response
  47. response = client.do_action_with_exception(request)
  48. resp_obj = json.loads(response)
  49. predict_result = json.loads(resp_obj['PredictResult'])
  50. print(predict_result)

PredictContent内容示例

  1. {
  2. "session_id": 123,
  3. "msgs": [
  4. {
  5. "role": "客户",
  6. "words": "喂,你好。"
  7. },
  8. {
  9. "role": "客服",
  10. "words": "哎,你好,我们这边是加米艺术。"
  11. },
  12. {
  13. "role": "客服",
  14. "words": "近期我们有一场儿童的创意绘画体验课活动。邀请您和呃我们在崇川区的成山路城市嘉苑这边。"
  15. },
  16. {
  17. "role": "客服",
  18. "words": "邀请您和呃我们在崇川区的成山路城市嘉苑这边。"
  19. },
  20. {
  21. "role": "客户",
  22. "words": "在哪里?"
  23. },
  24. {
  25. "role": "客户",
  26. "words": "哦,不方便不方便。行,谢谢再见。"
  27. }
  28. ]
  29. }

PredictResult内容示例

  1. {
  2. 'session_id': 123,
  3. 'result': [{'prob': 0.5665, 'industry': '商品推广', 'scene': '食品生鲜类'}],
  4. 'cost': '1268.513ms',
  5. 'code': 'SUCCESS'
  6. }

入参说明

参数 说明
session_id 当前请求唯一标识(字符串),为便于排查问题,请务必加上。可以是md5,或者随机数加时间戳。(必选字段)
msgs 对话内容(必选字段)
role 说话人的角色,当前仅客服、客户两种角色
words 说话人的说话内容

出参说明

参数 说明
session_id 唯一标识
result 行业单分类结果,包括行业industry,场景scene,概率prob
code 查询状态,SUCCESS为成功,INVALID_INPUT_FORMAT 为输入格式错误,FIELD_MISSING 为必选字段缺失,INVALID_TEXT_VALUE 为msgs字段无有效值
cost 查询耗时