我无法将两个列表转换为 json 格式。
我试图将两个列表转换为字典格式,然后转换为 json 格式,但是我想要的重复键不存在。
p = np.argmax(y[:416], axis=-1)
# print(p)
flat_list_te = padd_to_2d_senti[:416]
flat_list_test = [item for sublist in flat_list_te for item in sublist]
# print(flat_list_test)
# flat_list = [item for sublist in y_te[i] for item in sublist]
flat_list_pred = [item for sublist in p for item in sublist]
key = []
value = []
for w,pred in zip(flat_list_test,flat_list_pred):
predicted_tag = idx2tag[pred]
if predicted_tag !='O':
a.append(w)
b.append(idx2tag[pred])
test_pred = dict(zip(key,value))
expected output:
key = ["phone","age","class","class"]
value = [123,4,5,6]
dic = {"phone":123,"age":4,"class":5,"class":6}
狐的传说
相关分类