| 3 | |
| 4 | |
| 5 | def prepare_dataset_for_eval(dataset_name, output_file): |
| 6 | if dataset_name == 'cwq': |
| 7 | with open('../data/cwq.json',encoding='utf-8') as f: |
| 8 | datas = json.load(f) |
| 9 | question_string = 'question' |
| 10 | elif dataset_name == 'webqsp': |
| 11 | with open('../data/WebQSP.json',encoding='utf-8') as f: |
| 12 | datas = json.load(f) |
| 13 | question_string = 'RawQuestion' |
| 14 | elif dataset_name == 'grailqa': |
| 15 | with open('../data/grailqa.json',encoding='utf-8') as f: |
| 16 | datas = json.load(f) |
| 17 | question_string = 'question' |
| 18 | elif dataset_name == 'simpleqa': |
| 19 | with open('../data/SimpleQA.json',encoding='utf-8') as f: |
| 20 | datas = json.load(f) |
| 21 | question_string = 'question' |
| 22 | elif dataset_name == 'qald': |
| 23 | with open('../data/qald_10-en.json',encoding='utf-8') as f: |
| 24 | datas = json.load(f) |
| 25 | question_string = 'question' |
| 26 | elif dataset_name == 'webquestions': |
| 27 | with open('../data/WebQuestions.json',encoding='utf-8') as f: |
| 28 | datas = json.load(f) |
| 29 | question_string = 'question' |
| 30 | elif dataset_name == 'trex': |
| 31 | with open('../data/T-REX.json',encoding='utf-8') as f: |
| 32 | datas = json.load(f) |
| 33 | question_string = 'input' |
| 34 | elif dataset_name == 'zeroshotre': |
| 35 | with open('../data/Zero_Shot_RE.json',encoding='utf-8') as f: |
| 36 | datas = json.load(f) |
| 37 | question_string = 'input' |
| 38 | elif dataset_name == 'creak': |
| 39 | with open('../data/creak.json',encoding='utf-8') as f: |
| 40 | datas = json.load(f) |
| 41 | question_string = 'sentence' |
| 42 | else: |
| 43 | print("dataset not found, you should pick from {cwq, webqsp, grailqa, simpleqa, qald, webquestions, trex, zeroshotre, creak}.") |
| 44 | exit(-1) |
| 45 | with open(output_file, encoding='utf-8') as f: |
| 46 | output_datas = json.load(f) |
| 47 | return datas, question_string, output_datas |
| 48 | |
| 49 | |
| 50 | def align(dataset_name, question_string, data, ground_truth_datas): |