MCPcopy Create free account
hub / github.com/InternScience/SciReason / _parse

Function _parse

opencompass/datasets/Medbullets.py:13–33  ·  view source on GitHub ↗
(item: dict, prompt_mode: str)

Source from the content-addressed store, hash-verified

11
12
13def _parse(item: dict, prompt_mode: str) -> dict:
14 # 构建选项列表,忽略空字符串的 ope
15 options_keys = ['opa', 'opb', 'opc', 'opd']
16 if item.get('ope', '') != '':
17 options_keys.append('ope')
18 options_list = [item.get(k, '') for k in options_keys]
19 item['options'] = options_list
20
21 # 构建带标号的选项字符串
22 options_str = '\n'.join(
23 [f'{chr(65 + i)}. {opt}' for i, opt in enumerate(options_list)])
24
25 # 将选项附加到问题末尾
26 item['question'] = f"{item.get('question', '')}\n{options_str}"
27
28 # 标签及其他字段
29 item['label'] = item.get('answer_idx')
30 item['prompt_mode'] = prompt_mode
31 item['start'] = chr(65)
32 item['end'] = chr(65 + len(options_list) - 1)
33 return item
34
35
36@LOAD_DATASET.register_module()

Callers 1

loadMethod · 0.70

Calls 1

getMethod · 0.80

Tested by

no test coverage detected