MCPcopy Create free account
hub / github.com/codefuse-ai/codefuse-devops-eval / preprocess_question

Function preprocess_question

src/data/data_preprocess.py:35–68  ·  view source on GitHub ↗

Preprocess df and generate final dict

(df: pd.DataFrame, prefix: str = '')

Source from the content-addressed store, hash-verified

33 return res
34
35def preprocess_question(df: pd.DataFrame, prefix: str = ''):
36 '''
37 Preprocess df and generate final dict
38 '''
39 res = []
40
41 # uppercase to lowercase
42 df.rename(columns={
43 'Question': 'question',
44 'Answer': 'answer'
45 }, inplace=True)
46
47 for idx in range(df.shape[0]):
48 to_append = {
49 'question': df['question'].iloc[idx],
50 'options': [],
51 'answer': df['answer'].iloc[idx].strip().upper()
52 }
53 question = df['question'].iloc[idx]
54
55 query = prefix + '''问题:{question}\n'''.format(question=question)
56
57 for option in ['A', 'B', 'C', 'D']:
58 if df[option].iloc[idx]:
59 to_append['options'].append(option)
60 to_append[option] = df[option].iloc[idx]
61 to_add = '{}. {}\n'.format(option, df[option].iloc[idx])
62 query += to_add
63
64 to_add = '答案:'
65 query += to_add
66 to_append['query'] = query
67 res.append(to_append)
68 return res

Callers 1

preprocessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected