anand-s commited on
Commit
989b9c2
1 Parent(s): ce029e3

Update test_repo.py

Browse files
Files changed (1) hide show
  1. test_repo.py +28 -16
test_repo.py CHANGED
@@ -22,7 +22,10 @@ _LICENSE = "Apache License 2.0"
22
 
23
  # Define URLs for different parts of the dataset if applicable
24
  _URLS = {
25
- "mcq_domain": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/train_mcq.zip",
 
 
 
26
  }
27
 
28
  class TestRepo(datasets.GeneratorBasedBuilder):
@@ -31,10 +34,12 @@ class TestRepo(datasets.GeneratorBasedBuilder):
31
  VERSION = datasets.Version("1.0.0")
32
 
33
  BUILDER_CONFIGS = [
34
- datasets.BuilderConfig(name="mcq_domain", version=VERSION, description="This configuration covers multiple choice questions."),
 
 
35
  ]
36
 
37
- DEFAULT_CONFIG_NAME = "mcq_domain"
38
 
39
  def _info(self):
40
  return datasets.DatasetInfo(
@@ -44,7 +49,6 @@ class TestRepo(datasets.GeneratorBasedBuilder):
44
  "question": datasets.Value("string"),
45
  "options": datasets.Sequence(datasets.Value("string")),
46
  "answer": datasets.Value("string"),
47
- "context": datasets.Value("string"), # Assuming all data includes context
48
  "num_options": datasets.Value("string"),
49
  "question_type": datasets.Value("string"),
50
  "dataset_name": datasets.Value("string"),
@@ -60,9 +64,17 @@ class TestRepo(datasets.GeneratorBasedBuilder):
60
  print(data_dir)
61
  return [
62
  datasets.SplitGenerator(
63
- name=datasets.Split.TRAIN,
64
  gen_kwargs={"directory": data_dir, "split": "train"},
65
  ),
 
 
 
 
 
 
 
 
66
  ]
67
 
68
  def _generate_examples(self, directory, split):
@@ -74,14 +86,14 @@ class TestRepo(datasets.GeneratorBasedBuilder):
74
  with open(filepath, encoding="utf-8") as f:
75
  for key, row in enumerate(f):
76
  data = json.loads(row)
77
- yield key_idx, {
78
- "prompt": data.get("prompt", ""),
79
- "question": data["question"],
80
- "options": data["options"],
81
- "answer": data.get("answer", ""),
82
- "context": data.get("context", ""),
83
- "num_options": data.get("num_options", ""),
84
- "question_type": data.get("question_type", ""),
85
- "dataset_name": os.path.split(filepath)[-1].replace(".jsonl","")
86
- }
87
- key_idx +=1
 
22
 
23
  # Define URLs for different parts of the dataset if applicable
24
  _URLS = {
25
+ "train_normal_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/train_normal_mcqa.zip",
26
+ "val_normal_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/val_normal_mcqa.zip",
27
+ "test_normal_mcqa": "https://huggingface.co/datasets/anand-s/test_repo/resolve/main/test_normal_mcqa.zip",
28
+
29
  }
30
 
31
  class TestRepo(datasets.GeneratorBasedBuilder):
 
34
  VERSION = datasets.Version("1.0.0")
35
 
36
  BUILDER_CONFIGS = [
37
+ datasets.BuilderConfig(name="train_normal_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
38
+ datasets.BuilderConfig(name="val_normal_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
39
+ datasets.BuilderConfig(name="test_normal_mcqa", version=VERSION, description="This configuration covers multiple choice questions."),
40
  ]
41
 
42
+ # DEFAULT_CONFIG_NAME = "mcq_domain"
43
 
44
  def _info(self):
45
  return datasets.DatasetInfo(
 
49
  "question": datasets.Value("string"),
50
  "options": datasets.Sequence(datasets.Value("string")),
51
  "answer": datasets.Value("string"),
 
52
  "num_options": datasets.Value("string"),
53
  "question_type": datasets.Value("string"),
54
  "dataset_name": datasets.Value("string"),
 
64
  print(data_dir)
65
  return [
66
  datasets.SplitGenerator(
67
+ name="train_normal_mcqa",
68
  gen_kwargs={"directory": data_dir, "split": "train"},
69
  ),
70
+ datasets.SplitGenerator(
71
+ name="val_normal_mcqa",
72
+ gen_kwargs={"directory": data_dir, "split": "val"},
73
+ ),
74
+ datasets.SplitGenerator(
75
+ name="test_normal_mcqa",
76
+ gen_kwargs={"directory": data_dir, "split": "test"},
77
+ ),
78
  ]
79
 
80
  def _generate_examples(self, directory, split):
 
86
  with open(filepath, encoding="utf-8") as f:
87
  for key, row in enumerate(f):
88
  data = json.loads(row)
89
+ if split in ["train_normal_mcqa", "val_normal_mcqa", "test_normal_mcqa"]:
90
+ yield key_idx, {
91
+ "prompt": data.get("prompt", ""),
92
+ "question": data["question"],
93
+ "options": data["options"],
94
+ "answer": data.get("answer", ""),
95
+ "num_options": data.get("num_options", ""),
96
+ "question_type": data.get("question_type", ""),
97
+ "dataset_name": os.path.split(filepath)[-1].replace(".jsonl","")
98
+ }
99
+ key_idx +=1