必威体育Betway必威体育官网
当前位置:首页 > IT技术

百度UNIT 机器人多轮对话技能创建以及API调用

时间:2019-08-10 03:12:08来源:IT技术作者:seo实验室小编阅读:77次「手机版」
 

百度unit

百度UNIT 机器人多轮对话技能创建以及API调用

基于百度unit2.0 版本,实现简单的多轮人机对话功能

创建机器人必备条件

  1. 确定有哪些技能

    例如:查询天气、订票、讲故事等,以畅越冰激凌套餐营销话术为例

    创建技能

  2. 确定技能包含的意图

    分析是任务型、闲聊型还是问答型。

    任务型: 将用户意图的关键词参数化成词槽,完成任务。例如订票、退票、办理业务等

    问答型:有固定答案的对话,回答比较明确。例如业务咨询,套餐查询

    闲聊型: 没有明确的意图或者任务只是随意聊天

    分析营销话术属于任务型,以推销套餐为任务的意图。

    流程图

    流程

  3. 确定意图包含的词槽

    词槽:类似参数

  4. 为词槽添加词典

    注意如果词槽之间词典有重复的词语,会出现意图无法识别问题

  5. 为意图创建规则

    例如:对话中必须出现词槽中的词才会转到意图;一个意图可以匹配多个规则

  6. 创建对话模板

    不创建对话模板或者对话集,意图无法生效

  7. 训练模型

    通过技能训练将定义好的意图训练成模型,通过测试可以优化词槽或者修改规则优化模型

调用API

调用技能前提需要创建应用,获取API key 和Secret Key;使用两个key值获取调用api的token。

  1. 必备条件
    • token, 获取token需要API key 和Secret Key
    • 调用Api地址
    • 技能Id
  2. 调用实例

    参考代码地址

    部分代码。参考上述代码,实现多轮对话调用:

    获取token

/**
 * 获取token类
 */
public class AuthService {

    /**
     * 获取权限token
     * @return 返回示例:
     * {
     * "access_token": "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567",
     * "expires_in": 2592000
     * }
     */
    public static String getAuth() {
        // 官网获取的 API Key 更新为你注册的
        String clientid = "yRPuMmY6vbYVra0w8GhozQBF";
        // 官网获取的 Secret Key 更新为你注册的
        String clientSecret = "SNNVQ8ZqIob4XAQTEsVMkZ0uXKE9Amys";
        return getAuth(clientId, clientSecret);
    }

    /**
     * 获取API访问token
     * 该token有一定的有效期,需要自行管理,当失效时需重新获取.
     * @param ak - 百度云官网获取的 API Key
     * @param sk - 百度云官网获取的 Securet Key
     * @return assess_token 示例:
     * "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567"
     */
    public static String getAuth(String ak, String sk) {
        // 获取token地址
        String authHost = "https://aip.baidubce.com/oauth/2.0/token?";
        String getAccessTokenUrl = authHost
                // 1. grant_type为固定参数
                + "grant_type=client_credentials"
                // 2. 官网获取的 API Key
                + "&client_id=" + ak
                // 3. 官网获取的 Secret Key
                + "&client_secret=" + sk;
        try {
            URL realUrl = new URL(getAccessTokenUrl);
            // 打开和URL之间的连接
            HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();
            connection.setrequestMethod("GET");
            connection.connect();
            // 获取所有响应头字段
            Map<String, List<String>> map = connection.getHeaderfields();
            // 遍历所有的响应头字段
//            for (String key : map.keySet()) {
//                System.err.println(key + "--->" + map.get(key));
//            }
            // 定义 BufferedReader输入流来读取URL的响应
            BufferedReader in = new BufferedReader(new inputstreamreader(connection.getInputStream()));
            String result = "";
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
            /**
             * 返回结果示例
             */
//            System.err.println("result:" + result);
            jsonobject jsonObject = new JSONObject(result);
            String access_token = jsonObject.getString("access_token");
            return access_token;
        } catch (Exception e) {
            System.err.printf("获取token失败!");
            e.printstacktrace(System.err);
        }
        return null;
    }
}

调用技能:

/*
 * unit对话服务
 */
public class UnitService {
    /**
     * 重要提示代码中所需工具类
     * FileUtil,base64Util,HttpUtil,GsonUtils请从
     * https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72
     * https://ai.baidu.com/file/C8D81F3301E24D2892968F09AE1AD6E2
     * https://ai.baidu.com/file/544D677F5D4E4F17B4122FBD60DB82B3
     * https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
     * 下载
     */
    public static String utterance(String query, String botsession) {
        // 请求URL
        String talkUrl = "https://aip.baidubce.com/rpc/2.0/unit/bot/chat";
        //请求的参数用map封装
        Map<String , Object> map = new HashMap<>();
        Map<String , Object> mapRequest = new HashMap<>();
        Map<String , Object> mapQueryInfo = new HashMap<>();
        Map<String , Object> mapClientSession = new HashMap<>();
        List<String> asrCandidatesList = new ArrayList<>();
        List<String> candidateOptionsList = new ArrayList<>();
        ObjectMAPPer objectMapper = new ObjectMapper();

        map.put("bot_session",botSession);
        map.put("log_id",UUID.randomUUID().toString().replaceAll("-", ""));
        map.put("request",mapRequest);
        /*
         *  技能唯一标识,在『我的技能』的技能列表中第一列数字即为bot_id
         */
        map.put("bot_id",37819); // 技能id
        map.put("version","2.0");
        /**
         *  系统自动发现不置信意图/词槽,
         *  并据此主动发起澄清确认的敏感程度。
         *  取值范围:0(关闭)、1(中敏感度)、2(高敏感度)。
         *  取值越高BOT主动发起澄清的频率就越高,建议值为1
         */
        mapRequest.put("bernard_level",1);
        mapRequest.put("query",query);
        mapRequest.put("query_info",mapQueryInfo);
        mapRequest.put("updates","");
        mapRequest.put("user_id","UNIT_WEB_37819");
        mapQueryInfo.put("asr_candidates",asrCandidatesList);
        // 请求信息来源,可选值:"ASR","KEYBOARD"。ASR为语音输入,KEYBOARD为键盘文本输入。针对ASR输入,UNIT平台内置了纠错机制,会尝试解决语音输入中的一些常见错误
        mapQueryInfo.put("source","KEYBOARD");
        mapQueryInfo.put("type","TEXT");
        String clientSession = "";
        mapClientSession.put("client_results","");
        mapClientSession.put("candidate_options",candidateOptionsList);
        try {
            clientSession = objectMapper.writeValueAsString(mapClientSession).replace("\"", "\\\\\\\"");
        } catch (jsonprocessingException e) {
            e.printStackTrace();
        }
        mapRequest.put("client_session",clientSession);
//        System.out.println(clientSession);

        try {
            // 请求参数

            String params = objectMapper.writeValueAsString(map);
//            System.out.println(params);
            String accessToken = AuthService.getAuth();
            String result = HttpUtil.post(talkUrl, accessToken, "application/json", params);
//            System.out.println(" result: " + result);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    public static void main(String[] args) {
        // 实现多伦对话需要将上一轮中的bot-session 作为参数传入
//        String result = utterance("对我是");
//        String result = utterance("对我是");
//

        // while true: 如果返回结果中的 意向是: 结束意向 则将session 更改为空,否则继续下一段对话

// 获取到的bot_session 
//        String botSerssion = "{\"bot_id\":\"37819\",\"bot_views\":{\"bernard_res\":[{\"action_list\":[{\"action_id\":\"\",\"confidence\":0.0,\"custom_reply\":\"\",\"refine_detail\":{\"clarify_reason\":\"\",\"interact\":\"\",\"option_list\":[]},\"say\":\"\",\"type\":\"understood\"}],\"msg\":\"ok\",\"pre_nlu_outs\":[{\"otags_basic\":[{\"blength\":2,\"boffset\":0,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"user_hello\",\"etypes\":[\"[D:user_hello]\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\"],\"length\":1,\"method\":\"[D:user_hello] == [D:user_hello]\",\"name\":\"喂\",\"offset\":0,\"rstatus\":2,\"type_confidence\":10.50},{\"blength\":4,\"boffset\":4,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"user_hello\",\"etypes\":[\"[D:user_hello]\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\"],\"length\":1,\"method\":\"[D:user_hello] == [D:user_hello]\",\"name\":\"您好\",\"offset\":2,\"rstatus\":2,\"type_confidence\":10.50}],\"otags_wpcomp\":[],\"polarity\":{\"label\":\"1\",\"pval\":0.9970},\"tokens_basic\":[{\"buffer\":\"喂\",\"length\":2,\"norm_degree\":0.9479930996894836,\"offset\":0,\"type\":34,\"weight\":0.4515353739261627},{\"buffer\":\",\",\"length\":2,\"norm_degree\":0.0,\"offset\":2,\"type\":37,\"weight\":0.01189841516315937},{\"buffer\":\"您好\",\"length\":4,\"norm_degree\":0.0,\"offset\":4,\"type\":19,\"weight\":0.5365661978721619}],\"tokens_wpcomp\":[{\"buffer\":\"喂\",\"length\":2,\"norm_degree\":0.0,\"offset\":0,\"type\":34,\"weight\":0.4515353739261627},{\"buffer\":\",\",\"length\":2,\"norm_degree\":0.0,\"offset\":1,\"type\":37,\"weight\":0.2317169010639191},{\"buffer\":\"您好\",\"length\":4,\"norm_degree\":0.0,\"offset\":2,\"type\":19,\"weight\":0.2801815271377563}]}],\"qu_res\":{\"candidates\":[{\"confidence\":100.0,\"domain_confidence\":0.0,\"extra_info\":{\"group_id\":\"25\",\"real_threshold\":\"1\",\"threshold\":\"0.4\"},\"from_who\":\"pow-slu-lev1\",\"intent\":\"INTENTION_1\",\"intent_confidence\":100.0,\"intent_need_clarify\":false,\"match_info\":\"{\\\"group_id\\\":\\\"25\\\",\\\"id\\\":\\\"1958113\\\",\\\"informal_word\\\":\\\",\\\\t您好\\\",\\\"match_keywords\\\":\\\"  \\\",\\\"match_pattern\\\":\\\"喂\\\\t您好\\\",\\\"ori_pattern\\\":\\\"喂\\\\t您好\\\",\\\"ori_slots\\\":{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{},\\\"from_who\\\":\\\"smart_qu\\\",\\\"intent\\\":\\\"INTENTION_1\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"喂 \\\\t您好 \\\",\\\"slots\\\":[]},\\\"real_threshold\\\":1.0,\\\"threshold\\\":0.4000000059604645}\",\"slots\":[]}],\"lexical_analysis\":[{\"basic_word\":[\"喂\"],\"etypes\":[\"[D:user_hello]\"],\"term\":\"喂\",\"type\":\"user_hello\",\"weight\":0.4510},{\"basic_word\":[\",\"],\"etypes\":[],\"term\":\",\",\"type\":\"37\",\"weight\":0.0110},{\"basic_word\":[\"您好\"],\"etypes\":[\"[D:user_hello]\"],\"term\":\"您好\",\"type\":\"user_hello\",\"weight\":0.5360}],\"qu_res_chosen\":\"{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{\\\"group_id\\\":\\\"25\\\",\\\"real_threshold\\\":\\\"1\\\",\\\"threshold\\\":\\\"0.4\\\"},\\\"from_who\\\":\\\"pow-slu-lev1\\\",\\\"intent\\\":\\\"INTENTION_1\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"{\\\\\\\"group_id\\\\\\\":\\\\\\\"25\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"1958113\\\\\\\",\\\\\\\"informal_word\\\\\\\":\\\\\\\",\\\\\\\\t您好\\\\\\\",\\\\\\\"match_keywords\\\\\\\":\\\\\\\"  \\\\\\\",\\\\\\\"match_pattern\\\\\\\":\\\\\\\"喂\\\\\\\\t您好\\\\\\\",\\\\\\\"ori_pattern\\\\\\\":\\\\\\\"喂\\\\\\\\t您好\\\\\\\",\\\\\\\"ori_slots\\\\\\\":{\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"domain_confidence\\\\\\\":0.0,\\\\\\\"extra_info\\\\\\\":{},\\\\\\\"from_who\\\\\\\":\\\\\\\"smart_qu\\\\\\\",\\\\\\\"intent\\\\\\\":\\\\\\\"INTENTION_1\\\\\\\",\\\\\\\"intent_confidence\\\\\\\":100.0,\\\\\\\"intent_need_clarify\\\\\\\":false,\\\\\\\"match_info\\\\\\\":\\\\\\\"喂 \\\\\\\\t您好 \\\\\\\",\\\\\\\"slots\\\\\\\":[]},\\\\\\\"real_threshold\\\\\\\":1.0,\\\\\\\"threshold\\\\\\\":0.4000000059604645}\\\",\\\"slots\\\":[]}\\n\",\"raw_query\":\"喂,您好\",\"sentiment_analysis\":{\"label\":\"1\",\"pval\":0.9970},\"status\":0,\"timestamp\":0},\"schema\":{\"domain_confidence\":0.0,\"intent\":\"INTENTION_1\",\"intent_confidence\":100.0,\"slots\":[]},\"status\":0},{\"action_list\":[{\"action_id\":\"\",\"confidence\":0.0,\"custom_reply\":\"\",\"refine_detail\":{\"clarify_reason\":\"\",\"interact\":\"\",\"option_list\":[]},\"say\":\"\",\"type\":\"understood\"}],\"msg\":\"ok\",\"pre_nlu_outs\":[{\"otags_basic\":[{\"blength\":2,\"boffset\":0,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"user_answer1\",\"etypes\":[\"[D:user_answer1]\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\"],\"length\":1,\"method\":\"[D:user_answer1] == [D:user_answer1]\",\"name\":\"对\",\"offset\":0,\"rstatus\":2,\"type_confidence\":10.50},{\"blength\":4,\"boffset\":2,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"user_answer1\",\"etypes\":[\"[D:user_answer1]\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\"],\"length\":2,\"method\":\"[D:user_answer1] == [D:user_answer1]\",\"name\":\"我是\",\"offset\":1,\"rstatus\":2,\"type_confidence\":10.50}],\"otags_wpcomp\":[{\"blength\":2,\"boffset\":2,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"sys_coref_person\",\"etypes\":[\"[D:COREF_PERSON]\",\"sys_coref_person\",\"sys_coref_person\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\",\"\",\"\"],\"length\":1,\"method\":\"prime_nerl\",\"name\":\"我\",\"offset\":1,\"rstatus\":2,\"type_confidence\":5.0}],\"polarity\":{\"label\":\"1\",\"pval\":0.9040},\"tokens_basic\":[{\"buffer\":\"对\",\"length\":2,\"norm_degree\":0.9113681912422180,\"offset\":0,\"type\":28,\"weight\":0.1299898177385330},{\"buffer\":\"我\",\"length\":2,\"norm_degree\":0.0,\"offset\":2,\"type\":30,\"weight\":0.7122635245323181},{\"buffer\":\"是\",\"length\":2,\"norm_degree\":0.0,\"offset\":4,\"type\":34,\"weight\":0.1577466726303101}],\"tokens_wpcomp\":[{\"buffer\":\"对\",\"length\":2,\"norm_degree\":0.0,\"offset\":0,\"type\":28,\"weight\":0.1299898177385330},{\"buffer\":\"我\",\"length\":2,\"norm_degree\":0.0,\"offset\":1,\"type\":30,\"weight\":0.4211266636848450},{\"buffer\":\"是\",\"length\":2,\"norm_degree\":0.0,\"offset\":2,\"type\":34,\"weight\":0.7122635245323181}]}],\"qu_res\":{\"candidates\":[{\"confidence\":100.0,\"domain_confidence\":0.0,\"extra_info\":{\"group_id\":\"23\",\"real_threshold\":\"1\",\"threshold\":\"0.4\"},\"from_who\":\"pow-slu-lev1\",\"intent\":\"INTENTION_2\",\"intent_confidence\":100.0,\"intent_need_clarify\":false,\"match_info\":\"{\\\"group_id\\\":\\\"23\\\",\\\"id\\\":\\\"1958136\\\",\\\"informal_word\\\":\\\"我\\\\t是\\\",\\\"match_keywords\\\":\\\"  \\\",\\\"match_pattern\\\":\\\"[D:user_answer1]\\\\t[D:user_answer1]\\\",\\\"ori_pattern\\\":\\\"[D:user_answer1]\\\\t[D:user_answer1]\\\",\\\"ori_slots\\\":{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{},\\\"from_who\\\":\\\"smart_qu\\\",\\\"intent\\\":\\\"INTENTION_2\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"[D:user_answer1] \\\\t[D:user_answer1] \\\",\\\"slots\\\":[{\\\"begin\\\":0,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":2,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"\\\",\\\"original_word\\\":\\\"对\\\",\\\"word_type\\\":\\\"\\\"},{\\\"begin\\\":2,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":4,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"\\\",\\\"original_word\\\":\\\"我是\\\",\\\"word_type\\\":\\\"\\\"}]},\\\"real_threshold\\\":1.0,\\\"threshold\\\":0.4000000059604645}\",\"slots\":[{\"begin\":0,\"confidence\":100.0,\"father_idx\":-1,\"length\":2,\"name\":\"user_answer1\",\"need_clarify\":false,\"normalized_word\":\"对\",\"original_word\":\"对\",\"word_type\":\"\"},{\"begin\":2,\"confidence\":100.0,\"father_idx\":-1,\"length\":4,\"name\":\"user_answer1\",\"need_clarify\":false,\"normalized_word\":\"我是\",\"original_word\":\"我是\",\"word_type\":\"\"}]}],\"lexical_analysis\":[{\"basic_word\":[\"对\"],\"etypes\":[\"[D:user_answer1]\"],\"term\":\"对\",\"type\":\"user_answer1\",\"weight\":0.1290},{\"basic_word\":[\"我\",\"是\"],\"etypes\":[\"[D:user_answer1]\"],\"term\":\"我是\",\"type\":\"user_answer1\",\"weight\":0.870}],\"qu_res_chosen\":\"{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{\\\"group_id\\\":\\\"23\\\",\\\"real_threshold\\\":\\\"1\\\",\\\"threshold\\\":\\\"0.4\\\"},\\\"from_who\\\":\\\"pow-slu-lev1\\\",\\\"intent\\\":\\\"INTENTION_2\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"{\\\\\\\"group_id\\\\\\\":\\\\\\\"23\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"1958136\\\\\\\",\\\\\\\"informal_word\\\\\\\":\\\\\\\"我\\\\\\\\t是\\\\\\\",\\\\\\\"match_keywords\\\\\\\":\\\\\\\"  \\\\\\\",\\\\\\\"match_pattern\\\\\\\":\\\\\\\"[D:user_answer1]\\\\\\\\t[D:user_answer1]\\\\\\\",\\\\\\\"ori_pattern\\\\\\\":\\\\\\\"[D:user_answer1]\\\\\\\\t[D:user_answer1]\\\\\\\",\\\\\\\"ori_slots\\\\\\\":{\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"domain_confidence\\\\\\\":0.0,\\\\\\\"extra_info\\\\\\\":{},\\\\\\\"from_who\\\\\\\":\\\\\\\"smart_qu\\\\\\\",\\\\\\\"intent\\\\\\\":\\\\\\\"INTENTION_2\\\\\\\",\\\\\\\"intent_confidence\\\\\\\":100.0,\\\\\\\"intent_need_clarify\\\\\\\":false,\\\\\\\"match_info\\\\\\\":\\\\\\\"[D:user_answer1] \\\\\\\\t[D:user_answer1] \\\\\\\",\\\\\\\"slots\\\\\\\":[{\\\\\\\"begin\\\\\\\":0,\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"father_idx\\\\\\\":-1,\\\\\\\"length\\\\\\\":2,\\\\\\\"name\\\\\\\":\\\\\\\"user_answer1\\\\\\\",\\\\\\\"need_clarify\\\\\\\":false,\\\\\\\"normalized_word\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"original_word\\\\\\\":\\\\\\\"对\\\\\\\",\\\\\\\"word_type\\\\\\\":\\\\\\\"\\\\\\\"},{\\\\\\\"begin\\\\\\\":2,\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"father_idx\\\\\\\":-1,\\\\\\\"length\\\\\\\":4,\\\\\\\"name\\\\\\\":\\\\\\\"user_answer1\\\\\\\",\\\\\\\"need_clarify\\\\\\\":false,\\\\\\\"normalized_word\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"original_word\\\\\\\":\\\\\\\"我是\\\\\\\",\\\\\\\"word_type\\\\\\\":\\\\\\\"\\\\\\\"}]},\\\\\\\"real_threshold\\\\\\\":1.0,\\\\\\\"threshold\\\\\\\":0.4000000059604645}\\\",\\\"slots\\\":[{\\\"begin\\\":0,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":2,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"对\\\",\\\"original_word\\\":\\\"对\\\",\\\"word_type\\\":\\\"\\\"},{\\\"begin\\\":2,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":4,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"我是\\\",\\\"original_word\\\":\\\"我是\\\",\\\"word_type\\\":\\\"\\\"}]}\\n\",\"raw_query\":\"对我是\",\"sentiment_analysis\":{\"label\":\"1\",\"pval\":0.9040},\"status\":0,\"timestamp\":0},\"schema\":{\"domain_confidence\":0.0,\"intent\":\"INTENTION_2\",\"intent_confidence\":100.0,\"slots\":[{\"begin\":2,\"confidence\":100.0,\"length\":4,\"merge_method\":\"updated\",\"name\":\"user_answer1\",\"normalized_word\":\"我是\",\"original_word\":\"我是\",\"session_offset\":0,\"sub_slots\":[],\"word_type\":\"\"},{\"begin\":0,\"confidence\":100.0,\"length\":2,\"merge_method\":\"updated\",\"name\":\"user_answer1\",\"normalized_word\":\"对\",\"original_word\":\"对\",\"session_offset\":0,\"sub_slots\":[],\"word_type\":\"\"}]},\"status\":0}],\"bernard_status\":[{\"index\":0,\"step\":\"AFTER_DM_TRIGGER\"},{\"index\":1,\"step\":\"AFTER_DM_TRIGGER\"}],\"intervention\":{\"interv_qu_res\":\"\",\"interv_query\":\"\",\"qu_res_interved\":\"\",\"qu_res_original\":\"\",\"query_original\":\"\",\"type\":\"\",\"user_id\":\"\"},\"user_slots\":{\"user_answer1\":{\"state\":2,\"static_slot\":{\"default_state\":0,\"default_tag_name\":\"DEFAULT\",\"example_values\":[],\"extensible\":true,\"name\":\"user_answer1\",\"print\":[\"意图1用户肯定回答\"],\"type\":0,\"update_type\":\"single_turn\",\"weight\":1.0},\"tag_map\":{\"对\":{\"begin\":0,\"confidence\":100.0,\"length\":2,\"merge_method\":\"updated\",\"normalized_name\":\"对\",\"original_name\":\"对\",\"state\":2,\"turn\":0,\"word_type\":\"\"},\"我是\":{\"begin\":2,\"confidence\":100.0,\"length\":4,\"merge_method\":\"updated\",\"normalized_name\":\"我是\",\"original_name\":\"我是\",\"state\":2,\"turn\":0,\"word_type\":\"\"}}}}},\"dialog_state\":{\"contexts\":{},\"intents\":[{\"index\":0,\"name\":\"INTENTION_1\"},{\"index\":1,\"name\":\"INTENTION_2\"}],\"user_slots\":{\"user_answer1\":{\"attrs\":{\"default_state\":0,\"default_tag_name\":\"DEFAULT\",\"example_values\":[],\"extensible\":true,\"name\":\"user_answer1\",\"print\":[\"意图1用户肯定回答\"],\"type\":0,\"update_type\":\"single_turn\",\"weight\":1.0},\"state\":2,\"values\":{\"对\":{\"begin\":0,\"confidence\":100.0,\"length\":2,\"merge_method\":\"updated\",\"normalized_name\":\"对\",\"original_name\":\"对\",\"session_offest\":0,\"state\":2,\"word_type\":\"\"},\"我是\":{\"begin\":2,\"confidence\":100.0,\"length\":4,\"merge_method\":\"updated\",\"normalized_name\":\"我是\",\"original_name\":\"我是\",\"session_offest\":0,\"state\":2,\"word_type\":\"\"}}}}},\"interactions\":[{\"interaction_id\":\"interaction-1551324068880-707575714-8013-72\",\"request\":{\"bernard_level\":1,\"client_session\":\"{\\\\\\\\\\\\\\\"candidate_options\\\\\\\\\\\\\\\":[],\\\\\\\\\\\\\\\"client_results\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"}\",\"hyper_params\":{\"slu_tags\":[]},\"query\":\"喂,您好\",\"query_info\":{\"asr_candidates\":[],\"source\":\"KEYBOARD\",\"type\":\"TEXT\"},\"updates\":\"\",\"user_id\":\"UNIT_WEB_37819\"},\"response\":{\"action_list\":[{\"action_id\":\"intention_1_satisfy\",\"confidence\":100.0,\"custom_reply\":\"\",\"refine_detail\":{\"clarify_reason\":\"\",\"interact\":\"\",\"option_list\":[]},\"say\":\"**先生/女士,您好!我是联通公司客户经理,工号:****,请问您是尾号XXXX机主吗?\",\"type\":\"satisfy\"}],\"msg\":\"ok\",\"qu_res\":{\"candidates\":[{\"confidence\":100.0,\"domain_confidence\":0.0,\"extra_info\":{\"group_id\":\"25\",\"real_threshold\":\"1\",\"threshold\":\"0.4\"},\"from_who\":\"pow-slu-lev1\",\"intent\":\"INTENTION_1\",\"intent_confidence\":100.0,\"intent_need_clarify\":false,\"match_info\":\"{\\\"group_id\\\":\\\"25\\\",\\\"id\\\":\\\"1958113\\\",\\\"informal_word\\\":\\\",\\\\t您好\\\",\\\"match_keywords\\\":\\\"  \\\",\\\"match_pattern\\\":\\\"喂\\\\t您好\\\",\\\"ori_pattern\\\":\\\"喂\\\\t您好\\\",\\\"ori_slots\\\":{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{},\\\"from_who\\\":\\\"smart_qu\\\",\\\"intent\\\":\\\"INTENTION_1\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"喂 \\\\t您好 \\\",\\\"slots\\\":[]},\\\"real_threshold\\\":1.0,\\\"threshold\\\":0.4000000059604645}\",\"slots\":[]}],\"lexical_analysis\":[{\"basic_word\":[\"喂\"],\"etypes\":[\"[D:user_hello]\"],\"term\":\"喂\",\"type\":\"user_hello\",\"weight\":0.4510},{\"basic_word\":[\",\"],\"etypes\":[],\"term\":\",\",\"type\":\"37\",\"weight\":0.0110},{\"basic_word\":[\"您好\"],\"etypes\":[\"[D:user_hello]\"],\"term\":\"您好\",\"type\":\"user_hello\",\"weight\":0.5360}],\"qu_res_chosen\":\"{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{\\\"group_id\\\":\\\"25\\\",\\\"real_threshold\\\":\\\"1\\\",\\\"threshold\\\":\\\"0.4\\\"},\\\"from_who\\\":\\\"pow-slu-lev1\\\",\\\"intent\\\":\\\"INTENTION_1\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"{\\\\\\\"group_id\\\\\\\":\\\\\\\"25\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"1958113\\\\\\\",\\\\\\\"informal_word\\\\\\\":\\\\\\\",\\\\\\\\t您好\\\\\\\",\\\\\\\"match_keywords\\\\\\\":\\\\\\\"  \\\\\\\",\\\\\\\"match_pattern\\\\\\\":\\\\\\\"喂\\\\\\\\t您好\\\\\\\",\\\\\\\"ori_pattern\\\\\\\":\\\\\\\"喂\\\\\\\\t您好\\\\\\\",\\\\\\\"ori_slots\\\\\\\":{\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"domain_confidence\\\\\\\":0.0,\\\\\\\"extra_info\\\\\\\":{},\\\\\\\"from_who\\\\\\\":\\\\\\\"smart_qu\\\\\\\",\\\\\\\"intent\\\\\\\":\\\\\\\"INTENTION_1\\\\\\\",\\\\\\\"intent_confidence\\\\\\\":100.0,\\\\\\\"intent_need_clarify\\\\\\\":false,\\\\\\\"match_info\\\\\\\":\\\\\\\"喂 \\\\\\\\t您好 \\\\\\\",\\\\\\\"slots\\\\\\\":[]},\\\\\\\"real_threshold\\\\\\\":1.0,\\\\\\\"threshold\\\\\\\":0.4000000059604645}\\\",\\\"slots\\\":[]}\\n\",\"raw_query\":\"喂,您好\",\"sentiment_analysis\":{\"label\":\"1\",\"pval\":0.9970},\"status\":0,\"timestamp\":0},\"schema\":{\"domain_confidence\":0.0,\"intent\":\"INTENTION_1\",\"intent_confidence\":100.0,\"slots\":[]},\"status\":0},\"timestamp\":\"2019-02-28 11:21:08.880\"},{\"interaction_id\":\"interaction-1551324152506-707575714-8013-73\",\"request\":{\"bernard_level\":1,\"client_session\":\"{\\\\\\\\\\\\\\\"candidate_options\\\\\\\\\\\\\\\":[],\\\\\\\\\\\\\\\"client_results\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"}\",\"hyper_params\":{\"slu_tags\":[]},\"query\":\"对我是\",\"query_info\":{\"asr_candidates\":[],\"source\":\"KEYBOARD\",\"type\":\"TEXT\"},\"updates\":\"\",\"user_id\":\"UNIT_WEB_37819\"},\"response\":{\"action_list\":[{\"action_id\":\"intention_2_satisfy\",\"confidence\":100.0,\"custom_reply\":\"\",\"refine_detail\":{\"clarify_reason\":\"\",\"interact\":\"\",\"option_list\":[]},\"say\":\"现在联通公司为回馈老用户推出优惠活动给您推荐99元/月的畅越冰激凌优惠套餐为您介绍一下这项活动好么?\",\"type\":\"satisfy\"}],\"msg\":\"ok\",\"qu_res\":{\"candidates\":[{\"confidence\":100.0,\"domain_confidence\":0.0,\"extra_info\":{\"group_id\":\"23\",\"real_threshold\":\"1\",\"threshold\":\"0.4\"},\"from_who\":\"pow-slu-lev1\",\"intent\":\"INTENTION_2\",\"intent_confidence\":100.0,\"intent_need_clarify\":false,\"match_info\":\"{\\\"group_id\\\":\\\"23\\\",\\\"id\\\":\\\"1958136\\\",\\\"informal_word\\\":\\\"我\\\\t是\\\",\\\"match_keywords\\\":\\\"  \\\",\\\"match_pattern\\\":\\\"[D:user_answer1]\\\\t[D:user_answer1]\\\",\\\"ori_pattern\\\":\\\"[D:user_answer1]\\\\t[D:user_answer1]\\\",\\\"ori_slots\\\":{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{},\\\"from_who\\\":\\\"smart_qu\\\",\\\"intent\\\":\\\"INTENTION_2\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"[D:user_answer1] \\\\t[D:user_answer1] \\\",\\\"slots\\\":[{\\\"begin\\\":0,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":2,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"\\\",\\\"original_word\\\":\\\"对\\\",\\\"word_type\\\":\\\"\\\"},{\\\"begin\\\":2,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":4,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"\\\",\\\"original_word\\\":\\\"我是\\\",\\\"word_type\\\":\\\"\\\"}]},\\\"real_threshold\\\":1.0,\\\"threshold\\\":0.4000000059604645}\",\"slots\":[{\"begin\":0,\"confidence\":100.0,\"father_idx\":-1,\"length\":1,\"name\":\"user_answer1\",\"need_clarify\":false,\"normalized_word\":\"对\",\"original_word\":\"对\",\"word_type\":\"\"},{\"begin\":1,\"confidence\":100.0,\"father_idx\":-1,\"length\":2,\"name\":\"user_answer1\",\"need_clarify\":false,\"normalized_word\":\"我是\",\"original_word\":\"我是\",\"word_type\":\"\"}]}],\"lexical_analysis\":[{\"basic_word\":[\"对\"],\"etypes\":[\"[D:user_answer1]\"],\"term\":\"对\",\"type\":\"user_answer1\",\"weight\":0.1290},{\"basic_word\":[\"我\",\"是\"],\"etypes\":[\"[D:user_answer1]\"],\"term\":\"我是\",\"type\":\"user_answer1\",\"weight\":0.870}],\"qu_res_chosen\":\"{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{\\\"group_id\\\":\\\"23\\\",\\\"real_threshold\\\":\\\"1\\\",\\\"threshold\\\":\\\"0.4\\\"},\\\"from_who\\\":\\\"pow-slu-lev1\\\",\\\"intent\\\":\\\"INTENTION_2\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"{\\\\\\\"group_id\\\\\\\":\\\\\\\"23\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"1958136\\\\\\\",\\\\\\\"informal_word\\\\\\\":\\\\\\\"我\\\\\\\\t是\\\\\\\",\\\\\\\"match_keywords\\\\\\\":\\\\\\\"  \\\\\\\",\\\\\\\"match_pattern\\\\\\\":\\\\\\\"[D:user_answer1]\\\\\\\\t[D:user_answer1]\\\\\\\",\\\\\\\"ori_pattern\\\\\\\":\\\\\\\"[D:user_answer1]\\\\\\\\t[D:user_answer1]\\\\\\\",\\\\\\\"ori_slots\\\\\\\":{\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"domain_confidence\\\\\\\":0.0,\\\\\\\"extra_info\\\\\\\":{},\\\\\\\"from_who\\\\\\\":\\\\\\\"smart_qu\\\\\\\",\\\\\\\"intent\\\\\\\":\\\\\\\"INTENTION_2\\\\\\\",\\\\\\\"intent_confidence\\\\\\\":100.0,\\\\\\\"intent_need_clarify\\\\\\\":false,\\\\\\\"match_info\\\\\\\":\\\\\\\"[D:user_answer1] \\\\\\\\t[D:user_answer1] \\\\\\\",\\\\\\\"slots\\\\\\\":[{\\\\\\\"begin\\\\\\\":0,\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"father_idx\\\\\\\":-1,\\\\\\\"length\\\\\\\":2,\\\\\\\"name\\\\\\\":\\\\\\\"user_answer1\\\\\\\",\\\\\\\"need_clarify\\\\\\\":false,\\\\\\\"normalized_word\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"original_word\\\\\\\":\\\\\\\"对\\\\\\\",\\\\\\\"word_type\\\\\\\":\\\\\\\"\\\\\\\"},{\\\\\\\"begin\\\\\\\":2,\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"father_idx\\\\\\\":-1,\\\\\\\"length\\\\\\\":4,\\\\\\\"name\\\\\\\":\\\\\\\"user_answer1\\\\\\\",\\\\\\\"need_clarify\\\\\\\":false,\\\\\\\"normalized_word\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"original_word\\\\\\\":\\\\\\\"我是\\\\\\\",\\\\\\\"word_type\\\\\\\":\\\\\\\"\\\\\\\"}]},\\\\\\\"real_threshold\\\\\\\":1.0,\\\\\\\"threshold\\\\\\\":0.4000000059604645}\\\",\\\"slots\\\":[{\\\"begin\\\":0,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":2,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"对\\\",\\\"original_word\\\":\\\"对\\\",\\\"word_type\\\":\\\"\\\"},{\\\"begin\\\":2,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":4,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"我是\\\",\\\"original_word\\\":\\\"我是\\\",\\\"word_type\\\":\\\"\\\"}]}\\n\",\"raw_query\":\"对我是\",\"sentiment_analysis\":{\"label\":\"1\",\"pval\":0.9040},\"status\":0,\"timestamp\":0},\"schema\":{\"domain_confidence\":0.0,\"intent\":\"INTENTION_2\",\"intent_confidence\":100.0,\"slots\":[{\"begin\":0,\"confidence\":100.0,\"length\":1,\"merge_method\":\"updated\",\"name\":\"user_answer1\",\"normalized_word\":\"对\",\"original_word\":\"对\",\"session_offset\":0,\"sub_slots\":[],\"word_type\":\"\"},{\"begin\":1,\"confidence\":100.0,\"length\":2,\"merge_method\":\"updated\",\"name\":\"user_answer1\",\"normalized_word\":\"我是\",\"original_word\":\"我是\",\"session_offset\":0,\"sub_slots\":[],\"word_type\":\"\"}]},\"status\":0},\"timestamp\":\"2019-02-28 11:22:32.506\"}],\"session_id\":\"session-1551324068657-707575714-8013-22\"}";
        String botSession = "";

        String result = utterance("喂你好", botSession);
       // Result 返回结果json格式解析成java类.
        Result resultbean = JSONObject.parseObject(result, Result.class);
        // 当前处于那个意图
        String intention = resultbean.getResult().getResponse().getSchema().getIntent();
        // 答复文本内容
        String say = resultbean.getResult().getResponse().getAction_list().get(0).getSay();
        botSession = resultbean.getResult().getBot_session();
        String ERRORMsg = resultbean.getError_msg();
        int errorCode = resultbean.getError_code();

        while ("ok".equals(errorMsg) && errorCode==0) {
            // 如果意图部署结束语或者正常的结束就继续调用否则跳出或者挂断

            // 如果调用成功则进行下一步操作
            System.out.println(say);
            /**
             * 结束意图分别是:INTENTION_11
             */
            if ("INTENTION_11".equals(intention)) {

                System.out.println(" 本次对话结束, 如果进行再次话请继续!");
                botSession = "";
            }
            scanner scanner = new Scanner(System.in);
            String userAnswer = scanner.nextLine();
            result = utterance(userAnswer, botSession);
            resultbean = JSONObject.parseObject(result, Result.class);
            // 当前处于那个意图
            intention = resultbean.getResult().getResponse().getSchema().getIntent();
            // 答复文本内容
            say = resultbean.getResult().getResponse().getAction_list().get(0).getSay();
            botSession = resultbean.getResult().getBot_session();
            errorMsg = resultbean.getError_msg();
            errorCode = resultbean.getError_code();


        }

  1. 注意事项

    如果需要调用多轮对话,需要将每次获取到的结果中的bot_session 当做参数调用下一轮对话。

遇到的问题及解决方法

  1. {“error_code”:282004,“error_msg”:“parameter[bot_session] invalid or missing”}

    问题原因: bot_session 格式不正确,正确的格式应该是:

"{\"bot_id\":\"37819\",\"bot_views\":{\"bernard_res\":[{\"action_list\":[{\"action_id\":\"\",\"confidence\":0.0,\"custom_reply\":\"\",\"refine_detail\":{\"clarify_reason\":\"\",\"interact\":\"\",\"option_list\":[]},\"say\":\"\",\"type\":\"understood\"}],\"msg\":\"ok\",\"pre_nlu_outs\":[{\"otags_basic\":[{\"blength\":2,\"boffset\":0,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"user_hello\",\"etypes\":[\"[D:user_hello]\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\"],\"length\":1,\"method\":\"[D:user_hello] == [D:user_hello]\",\"name\":\"喂\",\"offset\":0,\"rstatus\":2,\"type_confidence\":10.50},{\"blength\":4,\"boffset\":4,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"user_hello\",\"etypes\":[\"[D:user_hello]\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\"],\"length\":1,\"method\":\"[D:user_hello] == [D:user_hello]\",\"name\":\"您好\",\"offset\":2,\"rstatus\":2,\"type_confidence\":10.50}],\"otags_wpcomp\":[],\"polarity\":{\"label\":\"1\",\"pval\":0.9970},\"tokens_basic\":[{\"buffer\":\"喂\",\"length\":2,\"norm_degree\":0.9479930996894836,\"offset\":0,\"type\":34,\"weight\":0.4515353739261627},{\"buffer\":\",\",\"length\":2,\"norm_degree\":0.0,\"offset\":2,\"type\":37,\"weight\":0.01189841516315937},{\"buffer\":\"您好\",\"length\":4,\"norm_degree\":0.0,\"offset\":4,\"type\":19,\"weight\":0.5365661978721619}],\"tokens_wpcomp\":[{\"buffer\":\"喂\",\"length\":2,\"norm_degree\":0.0,\"offset\":0,\"type\":34,\"weight\":0.4515353739261627},{\"buffer\":\",\",\"length\":2,\"norm_degree\":0.0,\"offset\":1,\"type\":37,\"weight\":0.2317169010639191},{\"buffer\":\"您好\",\"length\":4,\"norm_degree\":0.0,\"offset\":2,\"type\":19,\"weight\":0.2801815271377563}]}],\"qu_res\":{\"candidates\":[{\"confidence\":100.0,\"domain_confidence\":0.0,\"extra_info\":{\"group_id\":\"25\",\"real_threshold\":\"1\",\"threshold\":\"0.4\"},\"from_who\":\"pow-slu-lev1\",\"intent\":\"INTENTION_1\",\"intent_confidence\":100.0,\"intent_need_clarify\":false,\"match_info\":\"{\\\"group_id\\\":\\\"25\\\",\\\"id\\\":\\\"1958113\\\",\\\"informal_word\\\":\\\",\\\\t您好\\\",\\\"match_keywords\\\":\\\"  \\\",\\\"match_pattern\\\":\\\"喂\\\\t您好\\\",\\\"ori_pattern\\\":\\\"喂\\\\t您好\\\",\\\"ori_slots\\\":{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{},\\\"from_who\\\":\\\"smart_qu\\\",\\\"intent\\\":\\\"INTENTION_1\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"喂 \\\\t您好 \\\",\\\"slots\\\":[]},\\\"real_threshold\\\":1.0,\\\"threshold\\\":0.4000000059604645}\",\"slots\":[]}],\"lexical_analysis\":[{\"basic_word\":[\"喂\"],\"etypes\":[\"[D:user_hello]\"],\"term\":\"喂\",\"type\":\"user_hello\",\"weight\":0.4510},{\"basic_word\":[\",\"],\"etypes\":[],\"term\":\",\",\"type\":\"37\",\"weight\":0.0110},{\"basic_word\":[\"您好\"],\"etypes\":[\"[D:user_hello]\"],\"term\":\"您好\",\"type\":\"user_hello\",\"weight\":0.5360}],\"qu_res_chosen\":\"{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{\\\"group_id\\\":\\\"25\\\",\\\"real_threshold\\\":\\\"1\\\",\\\"threshold\\\":\\\"0.4\\\"},\\\"from_who\\\":\\\"pow-slu-lev1\\\",\\\"intent\\\":\\\"INTENTION_1\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"{\\\\\\\"group_id\\\\\\\":\\\\\\\"25\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"1958113\\\\\\\",\\\\\\\"informal_word\\\\\\\":\\\\\\\",\\\\\\\\t您好\\\\\\\",\\\\\\\"match_keywords\\\\\\\":\\\\\\\"  \\\\\\\",\\\\\\\"match_pattern\\\\\\\":\\\\\\\"喂\\\\\\\\t您好\\\\\\\",\\\\\\\"ori_pattern\\\\\\\":\\\\\\\"喂\\\\\\\\t您好\\\\\\\",\\\\\\\"ori_slots\\\\\\\":{\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"domain_confidence\\\\\\\":0.0,\\\\\\\"extra_info\\\\\\\":{},\\\\\\\"from_who\\\\\\\":\\\\\\\"smart_qu\\\\\\\",\\\\\\\"intent\\\\\\\":\\\\\\\"INTENTION_1\\\\\\\",\\\\\\\"intent_confidence\\\\\\\":100.0,\\\\\\\"intent_need_clarify\\\\\\\":false,\\\\\\\"match_info\\\\\\\":\\\\\\\"喂 \\\\\\\\t您好 \\\\\\\",\\\\\\\"slots\\\\\\\":[]},\\\\\\\"real_threshold\\\\\\\":1.0,\\\\\\\"threshold\\\\\\\":0.4000000059604645}\\\",\\\"slots\\\":[]}\\n\",\"raw_query\":\"喂,您好\",\"sentiment_analysis\":{\"label\":\"1\",\"pval\":0.9970},\"status\":0,\"timestamp\":0},\"schema\":{\"domain_confidence\":0.0,\"intent\":\"INTENTION_1\",\"intent_confidence\":100.0,\"slots\":[]},\"status\":0},{\"action_list\":[{\"action_id\":\"\",\"confidence\":0.0,\"custom_reply\":\"\",\"refine_detail\":{\"clarify_reason\":\"\",\"interact\":\"\",\"option_list\":[]},\"say\":\"\",\"type\":\"understood\"}],\"msg\":\"ok\",\"pre_nlu_outs\":[{\"otags_basic\":[{\"blength\":2,\"boffset\":0,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"user_answer1\",\"etypes\":[\"[D:user_answer1]\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\"],\"length\":1,\"method\":\"[D:user_answer1] == [D:user_answer1]\",\"name\":\"对\",\"offset\":0,\"rstatus\":2,\"type_confidence\":10.50},{\"blength\":4,\"boffset\":2,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"user_answer1\",\"etypes\":[\"[D:user_answer1]\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\"],\"length\":2,\"method\":\"[D:user_answer1] == [D:user_answer1]\",\"name\":\"我是\",\"offset\":1,\"rstatus\":2,\"type_confidence\":10.50}],\"otags_wpcomp\":[{\"blength\":2,\"boffset\":2,\"eid\":\"\",\"entity_confidence\":0.0,\"etype\":\"sys_coref_person\",\"etypes\":[\"[D:COREF_PERSON]\",\"sys_coref_person\",\"sys_coref_person\"],\"father_fully_covered\":false,\"father_index\":-1,\"features\":[],\"formal\":\"\",\"formals\":[\"\",\"\",\"\"],\"length\":1,\"method\":\"prime_nerl\",\"name\":\"我\",\"offset\":1,\"rstatus\":2,\"type_confidence\":5.0}],\"polarity\":{\"label\":\"1\",\"pval\":0.9040},\"tokens_basic\":[{\"buffer\":\"对\",\"length\":2,\"norm_degree\":0.9113681912422180,\"offset\":0,\"type\":28,\"weight\":0.1299898177385330},{\"buffer\":\"我\",\"length\":2,\"norm_degree\":0.0,\"offset\":2,\"type\":30,\"weight\":0.7122635245323181},{\"buffer\":\"是\",\"length\":2,\"norm_degree\":0.0,\"offset\":4,\"type\":34,\"weight\":0.1577466726303101}],\"tokens_wpcomp\":[{\"buffer\":\"对\",\"length\":2,\"norm_degree\":0.0,\"offset\":0,\"type\":28,\"weight\":0.1299898177385330},{\"buffer\":\"我\",\"length\":2,\"norm_degree\":0.0,\"offset\":1,\"type\":30,\"weight\":0.4211266636848450},{\"buffer\":\"是\",\"length\":2,\"norm_degree\":0.0,\"offset\":2,\"type\":34,\"weight\":0.7122635245323181}]}],\"qu_res\":{\"candidates\":[{\"confidence\":100.0,\"domain_confidence\":0.0,\"extra_info\":{\"group_id\":\"23\",\"real_threshold\":\"1\",\"threshold\":\"0.4\"},\"from_who\":\"pow-slu-lev1\",\"intent\":\"INTENTION_2\",\"intent_confidence\":100.0,\"intent_need_clarify\":false,\"match_info\":\"{\\\"group_id\\\":\\\"23\\\",\\\"id\\\":\\\"1958136\\\",\\\"informal_word\\\":\\\"我\\\\t是\\\",\\\"match_keywords\\\":\\\"  \\\",\\\"match_pattern\\\":\\\"[D:user_answer1]\\\\t[D:user_answer1]\\\",\\\"ori_pattern\\\":\\\"[D:user_answer1]\\\\t[D:user_answer1]\\\",\\\"ori_slots\\\":{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{},\\\"from_who\\\":\\\"smart_qu\\\",\\\"intent\\\":\\\"INTENTION_2\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"[D:user_answer1] \\\\t[D:user_answer1] \\\",\\\"slots\\\":[{\\\"begin\\\":0,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":2,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"\\\",\\\"original_word\\\":\\\"对\\\",\\\"word_type\\\":\\\"\\\"},{\\\"begin\\\":2,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":4,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"\\\",\\\"original_word\\\":\\\"我是\\\",\\\"word_type\\\":\\\"\\\"}]},\\\"real_threshold\\\":1.0,\\\"threshold\\\":0.4000000059604645}\",\"slots\":[{\"begin\":0,\"confidence\":100.0,\"father_idx\":-1,\"length\":2,\"name\":\"user_answer1\",\"need_clarify\":false,\"normalized_word\":\"对\",\"original_word\":\"对\",\"word_type\":\"\"},{\"begin\":2,\"confidence\":100.0,\"father_idx\":-1,\"length\":4,\"name\":\"user_answer1\",\"need_clarify\":false,\"normalized_word\":\"我是\",\"original_word\":\"我是\",\"word_type\":\"\"}]}],\"lexical_analysis\":[{\"basic_word\":[\"对\"],\"etypes\":[\"[D:user_answer1]\"],\"term\":\"对\",\"type\":\"user_answer1\",\"weight\":0.1290},{\"basic_word\":[\"我\",\"是\"],\"etypes\":[\"[D:user_answer1]\"],\"term\":\"我是\",\"type\":\"user_answer1\",\"weight\":0.870}],\"qu_res_chosen\":\"{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{\\\"group_id\\\":\\\"23\\\",\\\"real_threshold\\\":\\\"1\\\",\\\"threshold\\\":\\\"0.4\\\"},\\\"from_who\\\":\\\"pow-slu-lev1\\\",\\\"intent\\\":\\\"INTENTION_2\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"{\\\\\\\"group_id\\\\\\\":\\\\\\\"23\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"1958136\\\\\\\",\\\\\\\"informal_word\\\\\\\":\\\\\\\"我\\\\\\\\t是\\\\\\\",\\\\\\\"match_keywords\\\\\\\":\\\\\\\"  \\\\\\\",\\\\\\\"match_pattern\\\\\\\":\\\\\\\"[D:user_answer1]\\\\\\\\t[D:user_answer1]\\\\\\\",\\\\\\\"ori_pattern\\\\\\\":\\\\\\\"[D:user_answer1]\\\\\\\\t[D:user_answer1]\\\\\\\",\\\\\\\"ori_slots\\\\\\\":{\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"domain_confidence\\\\\\\":0.0,\\\\\\\"extra_info\\\\\\\":{},\\\\\\\"from_who\\\\\\\":\\\\\\\"smart_qu\\\\\\\",\\\\\\\"intent\\\\\\\":\\\\\\\"INTENTION_2\\\\\\\",\\\\\\\"intent_confidence\\\\\\\":100.0,\\\\\\\"intent_need_clarify\\\\\\\":false,\\\\\\\"match_info\\\\\\\":\\\\\\\"[D:user_answer1] \\\\\\\\t[D:user_answer1] \\\\\\\",\\\\\\\"slots\\\\\\\":[{\\\\\\\"begin\\\\\\\":0,\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"father_idx\\\\\\\":-1,\\\\\\\"length\\\\\\\":2,\\\\\\\"name\\\\\\\":\\\\\\\"user_answer1\\\\\\\",\\\\\\\"need_clarify\\\\\\\":false,\\\\\\\"normalized_word\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"original_word\\\\\\\":\\\\\\\"对\\\\\\\",\\\\\\\"word_type\\\\\\\":\\\\\\\"\\\\\\\"},{\\\\\\\"begin\\\\\\\":2,\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"father_idx\\\\\\\":-1,\\\\\\\"length\\\\\\\":4,\\\\\\\"name\\\\\\\":\\\\\\\"user_answer1\\\\\\\",\\\\\\\"need_clarify\\\\\\\":false,\\\\\\\"normalized_word\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"original_word\\\\\\\":\\\\\\\"我是\\\\\\\",\\\\\\\"word_type\\\\\\\":\\\\\\\"\\\\\\\"}]},\\\\\\\"real_threshold\\\\\\\":1.0,\\\\\\\"threshold\\\\\\\":0.4000000059604645}\\\",\\\"slots\\\":[{\\\"begin\\\":0,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":2,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"对\\\",\\\"original_word\\\":\\\"对\\\",\\\"word_type\\\":\\\"\\\"},{\\\"begin\\\":2,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":4,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"我是\\\",\\\"original_word\\\":\\\"我是\\\",\\\"word_type\\\":\\\"\\\"}]}\\n\",\"raw_query\":\"对我是\",\"sentiment_analysis\":{\"label\":\"1\",\"pval\":0.9040},\"status\":0,\"timestamp\":0},\"schema\":{\"domain_confidence\":0.0,\"intent\":\"INTENTION_2\",\"intent_confidence\":100.0,\"slots\":[{\"begin\":2,\"confidence\":100.0,\"length\":4,\"merge_method\":\"updated\",\"name\":\"user_answer1\",\"normalized_word\":\"我是\",\"original_word\":\"我是\",\"session_offset\":0,\"sub_slots\":[],\"word_type\":\"\"},{\"begin\":0,\"confidence\":100.0,\"length\":2,\"merge_method\":\"updated\",\"name\":\"user_answer1\",\"normalized_word\":\"对\",\"original_word\":\"对\",\"session_offset\":0,\"sub_slots\":[],\"word_type\":\"\"}]},\"status\":0}],\"bernard_status\":[{\"index\":0,\"step\":\"AFTER_DM_TRIGGER\"},{\"index\":1,\"step\":\"AFTER_DM_TRIGGER\"}],\"intervention\":{\"interv_qu_res\":\"\",\"interv_query\":\"\",\"qu_res_interved\":\"\",\"qu_res_original\":\"\",\"query_original\":\"\",\"type\":\"\",\"user_id\":\"\"},\"user_slots\":{\"user_answer1\":{\"state\":2,\"static_slot\":{\"default_state\":0,\"default_tag_name\":\"DEFAULT\",\"example_values\":[],\"extensible\":true,\"name\":\"user_answer1\",\"print\":[\"意图1用户肯定回答\"],\"type\":0,\"update_type\":\"single_turn\",\"weight\":1.0},\"tag_map\":{\"对\":{\"begin\":0,\"confidence\":100.0,\"length\":2,\"merge_method\":\"updated\",\"normalized_name\":\"对\",\"original_name\":\"对\",\"state\":2,\"turn\":0,\"word_type\":\"\"},\"我是\":{\"begin\":2,\"confidence\":100.0,\"length\":4,\"merge_method\":\"updated\",\"normalized_name\":\"我是\",\"original_name\":\"我是\",\"state\":2,\"turn\":0,\"word_type\":\"\"}}}}},\"dialog_state\":{\"contexts\":{},\"intents\":[{\"index\":0,\"name\":\"INTENTION_1\"},{\"index\":1,\"name\":\"INTENTION_2\"}],\"user_slots\":{\"user_answer1\":{\"attrs\":{\"default_state\":0,\"default_tag_name\":\"DEFAULT\",\"example_values\":[],\"extensible\":true,\"name\":\"user_answer1\",\"print\":[\"意图1用户肯定回答\"],\"type\":0,\"update_type\":\"single_turn\",\"weight\":1.0},\"state\":2,\"values\":{\"对\":{\"begin\":0,\"confidence\":100.0,\"length\":2,\"merge_method\":\"updated\",\"normalized_name\":\"对\",\"original_name\":\"对\",\"session_offest\":0,\"state\":2,\"word_type\":\"\"},\"我是\":{\"begin\":2,\"confidence\":100.0,\"length\":4,\"merge_method\":\"updated\",\"normalized_name\":\"我是\",\"original_name\":\"我是\",\"session_offest\":0,\"state\":2,\"word_type\":\"\"}}}}},\"interactions\":[{\"interaction_id\":\"interaction-1551324068880-707575714-8013-72\",\"request\":{\"bernard_level\":1,\"client_session\":\"{\\\\\\\\\\\\\\\"candidate_options\\\\\\\\\\\\\\\":[],\\\\\\\\\\\\\\\"client_results\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"}\",\"hyper_params\":{\"slu_tags\":[]},\"query\":\"喂,您好\",\"query_info\":{\"asr_candidates\":[],\"source\":\"KEYBOARD\",\"type\":\"TEXT\"},\"updates\":\"\",\"user_id\":\"UNIT_WEB_37819\"},\"response\":{\"action_list\":[{\"action_id\":\"intention_1_satisfy\",\"confidence\":100.0,\"custom_reply\":\"\",\"refine_detail\":{\"clarify_reason\":\"\",\"interact\":\"\",\"option_list\":[]},\"say\":\"**先生/女士,您好!我是联通公司客户经理,工号:****,请问您是尾号XXXX机主吗?\",\"type\":\"satisfy\"}],\"msg\":\"ok\",\"qu_res\":{\"candidates\":[{\"confidence\":100.0,\"domain_confidence\":0.0,\"extra_info\":{\"group_id\":\"25\",\"real_threshold\":\"1\",\"threshold\":\"0.4\"},\"from_who\":\"pow-slu-lev1\",\"intent\":\"INTENTION_1\",\"intent_confidence\":100.0,\"intent_need_clarify\":false,\"match_info\":\"{\\\"group_id\\\":\\\"25\\\",\\\"id\\\":\\\"1958113\\\",\\\"informal_word\\\":\\\",\\\\t您好\\\",\\\"match_keywords\\\":\\\"  \\\",\\\"match_pattern\\\":\\\"喂\\\\t您好\\\",\\\"ori_pattern\\\":\\\"喂\\\\t您好\\\",\\\"ori_slots\\\":{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{},\\\"from_who\\\":\\\"smart_qu\\\",\\\"intent\\\":\\\"INTENTION_1\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"喂 \\\\t您好 \\\",\\\"slots\\\":[]},\\\"real_threshold\\\":1.0,\\\"threshold\\\":0.4000000059604645}\",\"slots\":[]}],\"lexical_analysis\":[{\"basic_word\":[\"喂\"],\"etypes\":[\"[D:user_hello]\"],\"term\":\"喂\",\"type\":\"user_hello\",\"weight\":0.4510},{\"basic_word\":[\",\"],\"etypes\":[],\"term\":\",\",\"type\":\"37\",\"weight\":0.0110},{\"basic_word\":[\"您好\"],\"etypes\":[\"[D:user_hello]\"],\"term\":\"您好\",\"type\":\"user_hello\",\"weight\":0.5360}],\"qu_res_chosen\":\"{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{\\\"group_id\\\":\\\"25\\\",\\\"real_threshold\\\":\\\"1\\\",\\\"threshold\\\":\\\"0.4\\\"},\\\"from_who\\\":\\\"pow-slu-lev1\\\",\\\"intent\\\":\\\"INTENTION_1\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"{\\\\\\\"group_id\\\\\\\":\\\\\\\"25\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"1958113\\\\\\\",\\\\\\\"informal_word\\\\\\\":\\\\\\\",\\\\\\\\t您好\\\\\\\",\\\\\\\"match_keywords\\\\\\\":\\\\\\\"  \\\\\\\",\\\\\\\"match_pattern\\\\\\\":\\\\\\\"喂\\\\\\\\t您好\\\\\\\",\\\\\\\"ori_pattern\\\\\\\":\\\\\\\"喂\\\\\\\\t您好\\\\\\\",\\\\\\\"ori_slots\\\\\\\":{\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"domain_confidence\\\\\\\":0.0,\\\\\\\"extra_info\\\\\\\":{},\\\\\\\"from_who\\\\\\\":\\\\\\\"smart_qu\\\\\\\",\\\\\\\"intent\\\\\\\":\\\\\\\"INTENTION_1\\\\\\\",\\\\\\\"intent_confidence\\\\\\\":100.0,\\\\\\\"intent_need_clarify\\\\\\\":false,\\\\\\\"match_info\\\\\\\":\\\\\\\"喂 \\\\\\\\t您好 \\\\\\\",\\\\\\\"slots\\\\\\\":[]},\\\\\\\"real_threshold\\\\\\\":1.0,\\\\\\\"threshold\\\\\\\":0.4000000059604645}\\\",\\\"slots\\\":[]}\\n\",\"raw_query\":\"喂,您好\",\"sentiment_analysis\":{\"label\":\"1\",\"pval\":0.9970},\"status\":0,\"timestamp\":0},\"schema\":{\"domain_confidence\":0.0,\"intent\":\"INTENTION_1\",\"intent_confidence\":100.0,\"slots\":[]},\"status\":0},\"timestamp\":\"2019-02-28 11:21:08.880\"},{\"interaction_id\":\"interaction-1551324152506-707575714-8013-73\",\"request\":{\"bernard_level\":1,\"client_session\":\"{\\\\\\\\\\\\\\\"candidate_options\\\\\\\\\\\\\\\":[],\\\\\\\\\\\\\\\"client_results\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\"}\",\"hyper_params\":{\"slu_tags\":[]},\"query\":\"对我是\",\"query_info\":{\"asr_candidates\":[],\"source\":\"KEYBOARD\",\"type\":\"TEXT\"},\"updates\":\"\",\"user_id\":\"UNIT_WEB_37819\"},\"response\":{\"action_list\":[{\"action_id\":\"intention_2_satisfy\",\"confidence\":100.0,\"custom_reply\":\"\",\"refine_detail\":{\"clarify_reason\":\"\",\"interact\":\"\",\"option_list\":[]},\"say\":\"现在联通公司为回馈老用户推出优惠活动给您推荐99元/月的畅越冰激凌优惠套餐为您介绍一下这项活动好么?\",\"type\":\"satisfy\"}],\"msg\":\"ok\",\"qu_res\":{\"candidates\":[{\"confidence\":100.0,\"domain_confidence\":0.0,\"extra_info\":{\"group_id\":\"23\",\"real_threshold\":\"1\",\"threshold\":\"0.4\"},\"from_who\":\"pow-slu-lev1\",\"intent\":\"INTENTION_2\",\"intent_confidence\":100.0,\"intent_need_clarify\":false,\"match_info\":\"{\\\"group_id\\\":\\\"23\\\",\\\"id\\\":\\\"1958136\\\",\\\"informal_word\\\":\\\"我\\\\t是\\\",\\\"match_keywords\\\":\\\"  \\\",\\\"match_pattern\\\":\\\"[D:user_answer1]\\\\t[D:user_answer1]\\\",\\\"ori_pattern\\\":\\\"[D:user_answer1]\\\\t[D:user_answer1]\\\",\\\"ori_slots\\\":{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{},\\\"from_who\\\":\\\"smart_qu\\\",\\\"intent\\\":\\\"INTENTION_2\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"[D:user_answer1] \\\\t[D:user_answer1] \\\",\\\"slots\\\":[{\\\"begin\\\":0,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":2,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"\\\",\\\"original_word\\\":\\\"对\\\",\\\"word_type\\\":\\\"\\\"},{\\\"begin\\\":2,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":4,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"\\\",\\\"original_word\\\":\\\"我是\\\",\\\"word_type\\\":\\\"\\\"}]},\\\"real_threshold\\\":1.0,\\\"threshold\\\":0.4000000059604645}\",\"slots\":[{\"begin\":0,\"confidence\":100.0,\"father_idx\":-1,\"length\":1,\"name\":\"user_answer1\",\"need_clarify\":false,\"normalized_word\":\"对\",\"original_word\":\"对\",\"word_type\":\"\"},{\"begin\":1,\"confidence\":100.0,\"father_idx\":-1,\"length\":2,\"name\":\"user_answer1\",\"need_clarify\":false,\"normalized_word\":\"我是\",\"original_word\":\"我是\",\"word_type\":\"\"}]}],\"lexical_analysis\":[{\"basic_word\":[\"对\"],\"etypes\":[\"[D:user_answer1]\"],\"term\":\"对\",\"type\":\"user_answer1\",\"weight\":0.1290},{\"basic_word\":[\"我\",\"是\"],\"etypes\":[\"[D:user_answer1]\"],\"term\":\"我是\",\"type\":\"user_answer1\",\"weight\":0.870}],\"qu_res_chosen\":\"{\\\"confidence\\\":100.0,\\\"domain_confidence\\\":0.0,\\\"extra_info\\\":{\\\"group_id\\\":\\\"23\\\",\\\"real_threshold\\\":\\\"1\\\",\\\"threshold\\\":\\\"0.4\\\"},\\\"from_who\\\":\\\"pow-slu-lev1\\\",\\\"intent\\\":\\\"INTENTION_2\\\",\\\"intent_confidence\\\":100.0,\\\"intent_need_clarify\\\":false,\\\"match_info\\\":\\\"{\\\\\\\"group_id\\\\\\\":\\\\\\\"23\\\\\\\",\\\\\\\"id\\\\\\\":\\\\\\\"1958136\\\\\\\",\\\\\\\"informal_word\\\\\\\":\\\\\\\"我\\\\\\\\t是\\\\\\\",\\\\\\\"match_keywords\\\\\\\":\\\\\\\"  \\\\\\\",\\\\\\\"match_pattern\\\\\\\":\\\\\\\"[D:user_answer1]\\\\\\\\t[D:user_answer1]\\\\\\\",\\\\\\\"ori_pattern\\\\\\\":\\\\\\\"[D:user_answer1]\\\\\\\\t[D:user_answer1]\\\\\\\",\\\\\\\"ori_slots\\\\\\\":{\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"domain_confidence\\\\\\\":0.0,\\\\\\\"extra_info\\\\\\\":{},\\\\\\\"from_who\\\\\\\":\\\\\\\"smart_qu\\\\\\\",\\\\\\\"intent\\\\\\\":\\\\\\\"INTENTION_2\\\\\\\",\\\\\\\"intent_confidence\\\\\\\":100.0,\\\\\\\"intent_need_clarify\\\\\\\":false,\\\\\\\"match_info\\\\\\\":\\\\\\\"[D:user_answer1] \\\\\\\\t[D:user_answer1] \\\\\\\",\\\\\\\"slots\\\\\\\":[{\\\\\\\"begin\\\\\\\":0,\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"father_idx\\\\\\\":-1,\\\\\\\"length\\\\\\\":2,\\\\\\\"name\\\\\\\":\\\\\\\"user_answer1\\\\\\\",\\\\\\\"need_clarify\\\\\\\":false,\\\\\\\"normalized_word\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"original_word\\\\\\\":\\\\\\\"对\\\\\\\",\\\\\\\"word_type\\\\\\\":\\\\\\\"\\\\\\\"},{\\\\\\\"begin\\\\\\\":2,\\\\\\\"confidence\\\\\\\":100.0,\\\\\\\"father_idx\\\\\\\":-1,\\\\\\\"length\\\\\\\":4,\\\\\\\"name\\\\\\\":\\\\\\\"user_answer1\\\\\\\",\\\\\\\"need_clarify\\\\\\\":false,\\\\\\\"normalized_word\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"original_word\\\\\\\":\\\\\\\"我是\\\\\\\",\\\\\\\"word_type\\\\\\\":\\\\\\\"\\\\\\\"}]},\\\\\\\"real_threshold\\\\\\\":1.0,\\\\\\\"threshold\\\\\\\":0.4000000059604645}\\\",\\\"slots\\\":[{\\\"begin\\\":0,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":2,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"对\\\",\\\"original_word\\\":\\\"对\\\",\\\"word_type\\\":\\\"\\\"},{\\\"begin\\\":2,\\\"confidence\\\":100.0,\\\"father_idx\\\":-1,\\\"length\\\":4,\\\"name\\\":\\\"user_answer1\\\",\\\"need_clarify\\\":false,\\\"normalized_word\\\":\\\"我是\\\",\\\"original_word\\\":\\\"我是\\\",\\\"word_type\\\":\\\"\\\"}]}\\n\",\"raw_query\":\"对我是\",\"sentiment_analysis\":{\"label\":\"1\",\"pval\":0.9040},\"status\":0,\"timestamp\":0},\"schema\":{\"domain_confidence\":0.0,\"intent\":\"INTENTION_2\",\"intent_confidence\":100.0,\"slots\":[{\"begin\":0,\"confidence\":100.0,\"length\":1,\"merge_method\":\"updated\",\"name\":\"user_answer1\",\"normalized_word\":\"对\",\"original_word\":\"对\",\"session_offset\":0,\"sub_slots\":[],\"word_type\":\"\"},{\"begin\":1,\"confidence\":100.0,\"length\":2,\"merge_method\":\"updated\",\"name\":\"user_answer1\",\"normalized_word\":\"我是\",\"original_word\":\"我是\",\"session_offset\":0,\"sub_slots\":[],\"word_type\":\"\"}]},\"status\":0},\"timestamp\":\"2019-02-28 11:22:32.506\"}],\"session_id\":\"session-1551324068657-707575714-8013-22\"}";

部分交互结果:

在这里插入图片描述

  1. result: {“error_code”:110,“error_msg”:“Access token invalid or no longer valid”}

    问题原因: 获取token失败,检查API Key 和 Secret Key 是否正确

  2. result: {“error_msg”:“未找到相应的技能”,“error_code”:292001}

    问题原因: 第一是技能不存在;第二技能没有训练发布到沙盒环境;第三技能编号错误,修改为正确的技能编号。

参考资料

代码地址

[1]: https://github.com/langjianwei/futureBaby-Springboot/tree/86d28f5d59fc5f0d79662ffeec4c8610fbc53f2c

参考文档

[1]: 百度官方文档-技能对话API文档

[2]: 技能对话接口,API多轮对话的实现

相关阅读

Unity5.x 64位完整版详细安装图文教程

Unity 3D是一款非常强大的游戏开发引擎工具,在3D表现上非常出色,可以让我们创建自己的可视化游戏,另外在互联网上我们可以找到大量的

百度干净云 大神版 【真 破解限速】

使用说明: 正常运行软件,登录百度云账号,选择要下载的文件,然后下载。下载之后不久会出现一个红色按钮,上边赫然四个字,召唤大神!召唤大

谈谈百度贴吧、豆瓣小组以及BBS这个产品形态

毛委员在《微博商业化之难跟BBS一样》一文中提到:我一直在想,BBS上的某一个功能独立出来,就是一个成功的网站。比如说,二手版独立出来

使用百度地图api模拟实时定位页面 完整示例

使用百度地图api模拟实时定位页面 完整示例 效果:使用百度地图api在页面上显示车辆的实时位置,并有自动刷新和手动刷新两种方

百度地图比例尺与级别关系

百度地图级别范围:1~19级 级别 比例尺 19级 20m 18级 50m 17级 100m 16级 200m 15级 500m

分享到:

栏目导航

推荐阅读

热门阅读