For given example, generate four circular examples.
(entry, id)
| 19 | |
| 20 | |
| 21 | def get_circular_example(entry, id): |
| 22 | """For given example, generate four circular examples.""" |
| 23 | # Only 4 options is supported for current circular eval. |
| 24 | circular_patterns = ['ABCD', 'BCDA', 'CDAB', 'DABC'] |
| 25 | data = [] |
| 26 | for c in circular_patterns: |
| 27 | line = copy.deepcopy(entry) |
| 28 | options = [] |
| 29 | for i in range(4): |
| 30 | options.append(line['options'][ord(c[i]) - ord('A')]) |
| 31 | line['options'] = options |
| 32 | line['answer'] = { |
| 33 | c[0]: 'A', |
| 34 | c[1]: 'B', |
| 35 | c[2]: 'C', |
| 36 | c[3]: 'D' |
| 37 | }[line['answer']] |
| 38 | line['answer'] = str(id) + '--' + line['answer'] + '--' + c |
| 39 | line['question'] = line['question'].strip() + '\n' + get_number( |
| 40 | line['options']) |
| 41 | data.append(line) |
| 42 | |
| 43 | return data |
| 44 | |
| 45 | |
| 46 | @LOAD_DATASET.register_module() |
no test coverage detected