百度UNIT 機器人多輪對話技能創建以及API調用

百度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多輪對話的實現

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章