You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.9 KiB
Python
83 lines
1.9 KiB
Python
|
|
|
|
import json
|
|
|
|
|
|
|
|
def create_answer_id(i):
|
|
return 'A_' + str(i)
|
|
|
|
def create_question_id(intent_code, j):
|
|
return intent_code + '@' + str(j)
|
|
|
|
|
|
def load_traing_data(file_path):
|
|
|
|
question_list = []
|
|
id_list = []
|
|
|
|
with open(file_path) as f:
|
|
data = json.load(f)
|
|
for i, item in enumerate(data):
|
|
intent_code = item['intentCode']
|
|
q_list = item['questionExample']
|
|
for j, q in enumerate(q_list):
|
|
q_id = create_question_id(intent_code, j)
|
|
question_list.append(q)
|
|
id_list.append(q_id)
|
|
|
|
return question_list, id_list
|
|
|
|
|
|
def load_testing_data(file_path):
|
|
|
|
test_data_list = []
|
|
question_list = []
|
|
id_list = []
|
|
|
|
with open(file_path, encoding='utf-8') as f:
|
|
data = json.load(f)
|
|
for i, item in enumerate(data):
|
|
test_question = item['testQuestion']
|
|
intent_code = item['expectIntentCode']
|
|
test_data_list.append((test_question, intent_code))
|
|
|
|
q_list = item['expectIntentQuestionExample']
|
|
for j, q in enumerate(q_list):
|
|
q_id = create_question_id(intent_code, j)
|
|
question_list.append(q)
|
|
id_list.append(q_id)
|
|
|
|
return test_data_list, question_list, id_list
|
|
|
|
|
|
|
|
|
|
def work():
|
|
# question_list, id_list = load_traing_data('test_data/training_data.json')
|
|
|
|
# print(question_list[0])
|
|
# print(id_list[0])
|
|
|
|
# print(question_list[21])
|
|
# print(id_list[21])
|
|
|
|
# intent_conde, idx = id_list[21].split('@')
|
|
# print(intent_conde)
|
|
# print(idx)
|
|
|
|
test_data_list, question_list, id_list = load_testing_data('test_data/testing_data.json')
|
|
q_len = len(question_list)
|
|
print(question_list[0])
|
|
print(id_list[0])
|
|
print(question_list[q_len-1])
|
|
print(id_list[q_len-1])
|
|
print('#########')
|
|
print(test_data_list[0][0])
|
|
print(test_data_list[0][1])
|
|
|
|
|
|
work()
|
|
|
|
|