Datasets:

Languages:
Indonesian
ArXiv:
holylovenia commited on
Commit
993a88b
1 Parent(s): 10e6e92

Upload idk_mrc.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. idk_mrc.py +17 -16
idk_mrc.py CHANGED
@@ -21,9 +21,9 @@ from typing import Dict, List, Tuple
21
 
22
  import datasets
23
 
24
- from nusacrowd.utils import schemas
25
- from nusacrowd.utils.configs import NusantaraConfig
26
- from nusacrowd.utils.constants import Tasks
27
 
28
  _CITATION = """\
29
  @misc{putri2022idk,
@@ -78,23 +78,23 @@ _SUPPORTED_TASKS = [Tasks.QUESTION_ANSWERING]
78
 
79
  _SOURCE_VERSION = "1.0.0"
80
 
81
- _NUSANTARA_VERSION = "1.0.0"
82
 
83
 
84
- def nusantara_config_constructor(name, schema, version):
85
  """
86
- Construct NusantaraConfig with idk_mrc_{schema} format for the main dataset &
87
  idk_mrc_baseline_{name}_{schema} format for the baseline datasets.
88
  Suported dataset names: see _ALL_DATASETS
89
  """
90
- if schema != "source" and schema != "nusantara_qa":
91
  raise ValueError(f"Invalid schema: {schema}")
92
 
93
  if name not in _ALL_DATASETS:
94
  raise ValueError(f"Invalid dataset name: {name}")
95
 
96
  if name == "idk_mrc":
97
- return NusantaraConfig(
98
  name="idk_mrc_{schema}".format(schema=schema),
99
  version=datasets.Version(version),
100
  description="IDK-MRC with {schema} schema".format(schema=schema),
@@ -102,7 +102,7 @@ def nusantara_config_constructor(name, schema, version):
102
  subset_id="idk_mrc",
103
  )
104
  else:
105
- return NusantaraConfig(
106
  name="idk_mrc_baseline_{name}_{schema}".format(name=name, schema=schema),
107
  version=datasets.Version(version),
108
  description="IDK-MRC baseline ({name}) with {schema} schema".format(name=name, schema=schema),
@@ -115,11 +115,11 @@ class IdkMrc(datasets.GeneratorBasedBuilder):
115
  """IDK-MRC is an Indonesian MRC dataset that covers answerable and unanswerable questions"""
116
 
117
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
118
- NUSANTARA_VERSION = datasets.Version(_NUSANTARA_VERSION)
119
 
120
  BUILDER_CONFIGS = [
121
- nusantara_config_constructor(name, schema, version)
122
- for name in _ALL_DATASETS for schema, version in zip(["source", "nusantara_qa"], [_SOURCE_VERSION, _NUSANTARA_VERSION])
123
  ]
124
 
125
  DEFAULT_CONFIG_NAME = "idk_mrc_source"
@@ -145,7 +145,7 @@ class IdkMrc(datasets.GeneratorBasedBuilder):
145
  }
146
  )
147
 
148
- elif self.config.schema == "nusantara_qa":
149
  features = schemas.qa_features
150
 
151
  return datasets.DatasetInfo(
@@ -158,14 +158,14 @@ class IdkMrc(datasets.GeneratorBasedBuilder):
158
 
159
  def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
160
  """Returns SplitGenerators."""
161
- if self.config.name == "idk_mrc_source" or self.config.name == "idk_mrc_nusantara_qa":
162
  data_name = "idk_mrc"
163
  train_data_path = dl_manager.download_and_extract(_URLS[_DATASETNAME]["train"])
164
  validation_data_path = dl_manager.download_and_extract(_URLS[_DATASETNAME]["validation"])
165
  test_data_path = dl_manager.download_and_extract(_URLS[_DATASETNAME]["test"])
166
  else:
167
  try:
168
- data_name = re.search("baseline_(.+?)_(source|nusantara_qa)", self.config.name).group(1)
169
  except AttributeError:
170
  raise ValueError(f"Invalid config name: {self.config.name}")
171
 
@@ -215,7 +215,7 @@ class IdkMrc(datasets.GeneratorBasedBuilder):
215
  for key, example in enumerate(examples):
216
  yield key, example
217
 
218
- elif self.config.schema == "nusantara_qa":
219
  for key, example in enumerate(examples):
220
  for qa in example["qas"]:
221
  # Use question ID as key
@@ -228,4 +228,5 @@ class IdkMrc(datasets.GeneratorBasedBuilder):
228
  "choices": [],
229
  "context": example["context"],
230
  "answer": [ans["text"] for ans in qa["answers"]],
 
231
  }
 
21
 
22
  import datasets
23
 
24
+ from seacrowd.utils import schemas
25
+ from seacrowd.utils.configs import SEACrowdConfig
26
+ from seacrowd.utils.constants import Tasks
27
 
28
  _CITATION = """\
29
  @misc{putri2022idk,
 
78
 
79
  _SOURCE_VERSION = "1.0.0"
80
 
81
+ _SEACROWD_VERSION = "2024.06.20"
82
 
83
 
84
+ def seacrowd_config_constructor(name, schema, version):
85
  """
86
+ Construct SEACrowdConfig with idk_mrc_{schema} format for the main dataset &
87
  idk_mrc_baseline_{name}_{schema} format for the baseline datasets.
88
  Suported dataset names: see _ALL_DATASETS
89
  """
90
+ if schema != "source" and schema != "seacrowd_qa":
91
  raise ValueError(f"Invalid schema: {schema}")
92
 
93
  if name not in _ALL_DATASETS:
94
  raise ValueError(f"Invalid dataset name: {name}")
95
 
96
  if name == "idk_mrc":
97
+ return SEACrowdConfig(
98
  name="idk_mrc_{schema}".format(schema=schema),
99
  version=datasets.Version(version),
100
  description="IDK-MRC with {schema} schema".format(schema=schema),
 
102
  subset_id="idk_mrc",
103
  )
104
  else:
105
+ return SEACrowdConfig(
106
  name="idk_mrc_baseline_{name}_{schema}".format(name=name, schema=schema),
107
  version=datasets.Version(version),
108
  description="IDK-MRC baseline ({name}) with {schema} schema".format(name=name, schema=schema),
 
115
  """IDK-MRC is an Indonesian MRC dataset that covers answerable and unanswerable questions"""
116
 
117
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
118
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
119
 
120
  BUILDER_CONFIGS = [
121
+ seacrowd_config_constructor(name, schema, version)
122
+ for name in _ALL_DATASETS for schema, version in zip(["source", "seacrowd_qa"], [_SOURCE_VERSION, _SEACROWD_VERSION])
123
  ]
124
 
125
  DEFAULT_CONFIG_NAME = "idk_mrc_source"
 
145
  }
146
  )
147
 
148
+ elif self.config.schema == "seacrowd_qa":
149
  features = schemas.qa_features
150
 
151
  return datasets.DatasetInfo(
 
158
 
159
  def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
160
  """Returns SplitGenerators."""
161
+ if self.config.name == "idk_mrc_source" or self.config.name == "idk_mrc_seacrowd_qa":
162
  data_name = "idk_mrc"
163
  train_data_path = dl_manager.download_and_extract(_URLS[_DATASETNAME]["train"])
164
  validation_data_path = dl_manager.download_and_extract(_URLS[_DATASETNAME]["validation"])
165
  test_data_path = dl_manager.download_and_extract(_URLS[_DATASETNAME]["test"])
166
  else:
167
  try:
168
+ data_name = re.search("baseline_(.+?)_(source|seacrowd_qa)", self.config.name).group(1)
169
  except AttributeError:
170
  raise ValueError(f"Invalid config name: {self.config.name}")
171
 
 
215
  for key, example in enumerate(examples):
216
  yield key, example
217
 
218
+ elif self.config.schema == "seacrowd_qa":
219
  for key, example in enumerate(examples):
220
  for qa in example["qas"]:
221
  # Use question ID as key
 
228
  "choices": [],
229
  "context": example["context"],
230
  "answer": [ans["text"] for ans in qa["answers"]],
231
+ "meta": {}
232
  }