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

Method load

opencompass/datasets/multirc.py:15–42  ·  view source on GitHub ↗
(path: str)

Source from the content-addressed store, hash-verified

13
14 @staticmethod
15 def load(path: str):
16 path = get_data_path(path, local_mode=True)
17 with open(path, 'r', errors='ignore') as in_f:
18 rows = []
19 for line in in_f:
20 sample = json.loads(line.strip())
21 passage = sample['passage']
22 text = passage['text']
23 questions = passage['questions']
24 for question_dict in questions:
25 question = question_dict['question']
26 answers = question_dict['answers']
27 for answer_dict in answers:
28 answer = answer_dict['text']
29 label = answer_dict['label']
30 rows.append({
31 'text': text,
32 'question': question,
33 'answer': answer,
34 'label': label
35 })
36 dataset = Dataset.from_dict({
37 'text': [row['text'] for row in rows],
38 'question': [row['question'] for row in rows],
39 'answer': [row['answer'] for row in rows],
40 'label': [row['label'] for row in rows]
41 })
42 return dataset
43
44
45@LOAD_DATASET.register_module()

Callers

nothing calls this directly

Calls 2

get_data_pathFunction · 0.90
openFunction · 0.85

Tested by

no test coverage detected