# yuliao1=yuliao1%foodname # # yuliao2 = yuliao2 % foodname # data1["currentUtterance"]=yuliao1 # result1=Request().requests(url,data1,'POST') # print(result1) # if result1["intent"]["intentType"]=="questionWhichRoomStore": # print("pass") for i in range(len(foodname_data)): foodname = foodname_data[i][1] yuliao1 = yuliao1.format(foodname) yuliao2 = yuliao2.format(foodname) data1["currentUtterance"] = yuliao1 result1 = Request().requests(url, data1, 'POST') if result1["intent"]["intentType"] == "questionWhichRoomStore": print("食材【{}:{}】无冰箱语料测试结果:{}".format(i, foodname, "pass")) r.write_onlydata(new_book, i + 1, 3, "Pass") else: print("食材【{}:{}】无冰箱语料测试结果:{}".format(i, foodname, "fail")) r.write_onlydata(new_book, i + 1, 3, "Fail") data2["currentUtterance"] = yuliao2 result2 = Request().requests(url, data2, 'POST') # print(result) if result2["intent"]["intentType"] == "questionWhichRoomStore": print("食材【{}:{}】有冰箱语料测试结果:{}".format(i, foodname, "pass")) r.write_onlydata(new_book, i + 1, 2, "PASS") else: print("食材【{}:{}】有冰箱语料测试结果:{}".format(i, foodname, "pass")) r.write_onlydata(new_book, i + 1, 2, "Fail") r.save_write(new_book, result_path)
from common.read_xls_news import Read_xls from common.http_request_new import Request from common.conf import Conf from collections import Counter import json, Project_path http_conf_path = Project_path.conf_path + "http.ini" host = Conf(http_conf_path).get_value("HTTP", "sit") path = "E:\AITEST\\testdata\yb101远程控制-自动化案例_new3.xls" conf_path = "E:\AITEST\conf\defaultQueryReply.ini" r = Read_xls(path) w = r.copy_book() url = "%s/v1/auto_test/control/virtual" % host result_path = "E:\AITEST\\testdata\yb101远程控制-自动化案例_new4.xls" data_yb101_0 = json.loads(Conf(conf_path).get_value("AC", "yb101")) data_ac = r.read_data('yb101', start_line=2) for i in range(0, len(data_ac)): text = data_ac[i][4] if "空调" not in text: text = "空调" + text r.write_onlydata(w, i + 1, 4, text, sheetname='yb101') r.save_write(w, result_path)
def get_expectData(product_model, path, result_path, run_num=None): if run_num == None: run_num = 1 host = Conf(http_conf_path).get_value("HTTP", "sit") url = "%s/v1/auto_test/control/virtual" % host data = Default_data(product_model) queryinfo = data['query_reply'] r = Read_xls(path) data_list = r.read_data(product_model, start_line=2) w = r.copy_book() for i in range(len(data_list)): testid = data_list[i][0] tdata = data_list[i][3] try: tts_list = eval(data_list[i][7]) except: tts_list = [] try: testdata = json.loads(tdata) except: testdata = '{' + tdata.replace('&', ',') + '}' try: testdata = json.loads(testdata) except Exception as e: print(e) else: testdata = dict(queryinfo, **testdata) finally: print(testid) data['text'] = data_list[i][4] data["query_reply"] = testdata n = run_num while n > 0: Response = Request().requests(url, data, "POST").json() tts = str(Response['data']['tts']['data'][0]['text']) print(tts) tts_list.append(tts) nlu = Response['data']['nlu'] try: lua = jsonpath.jsonpath(Response, "$..luaData")[0] except Exception as e: lua = '' print(lua) if n == 1: tts_list.append(tts) tts_lists = list(set(tts_list)) print(tts_lists) r.write_onlydata(w, i + 1, 5, str(nlu), sheetname=product_model) r.write_onlydata(w, i + 1, 6, str(lua), sheetname=product_model) r.write_onlydata(w, i + 1, 7, str(tts_lists), sheetname=product_model) else: tts_list.append(tts) n -= 1 i += 1 r.save_write(w, result_path)
a = ws.runsingle(wav) txt = json.loads(a)['text'].replace(' ', "") r.write_onlydata(w, int(wav_id), 5, txt, sheetname='019M41_02_020M24_13_021F30_1') r.write_onlydata(w, int(wav_id), 6, wav_name, sheetname='019M41_02_020M24_13_021F30_1') print(wav_name, txt) if __name__ == '__main__': mprocess(tt, wav_list) r.save_write(w, xls_new) ws.close() # for each in wav_list: # wav_name=each.split('.')[0].split('\\')[-redis_case] # wav_id=wav_name.split('_')[-redis_case] # a=ws.runsingle(each) # txt=json.loads(a)['text'].replace(' ',"") # r.write_onlydata(w, int(wav_id), 5,txt,sheetname='019M41_02_020M24_13_021F30_1') # r.write_onlydata(w, int(wav_id), 6, wav_name,sheetname='019M41_02_020M24_13_021F30_1') # print(wav_name,txt) # r.save_write(w,xls_new) # ws.close()