Datasets:
GEM
/

Tasks:
Other
Modalities:
Text
Languages:
English
ArXiv:
Libraries:
Datasets
License:
Sebastian Gehrmann commited on
Commit
eaca996
1 Parent(s): 9563d4b
Files changed (1) hide show
  1. common_gen.py +13 -11
common_gen.py CHANGED
@@ -40,9 +40,7 @@ class CommonGen(datasets.GeneratorBasedBuilder):
40
  DEFAULT_CONFIG_NAME = "common_gen"
41
 
42
  def _info(self):
43
- return datasets.DatasetInfo(
44
- description=_DESCRIPTION,
45
- features=datasets.Features(
46
  {
47
  "gem_id": datasets.Value("string"),
48
  "gem_parent_id": datasets.Value("string"),
@@ -54,14 +52,18 @@ class CommonGen(datasets.GeneratorBasedBuilder):
54
  ], # multiple references for validation
55
  }
56
  ),
57
- supervised_keys=None,
 
 
 
 
58
  homepage="https://inklab.usc.edu/CommonGen/",
59
  citation=_CITATION,
60
  )
61
 
62
  def _split_generators(self, dl_manager):
63
  """Returns SplitGenerators."""
64
- dl_dir = dl_manager.download_and_extract(_URLs[self.config.name])
65
  challenge_sets = [
66
  ("challenge_train_sample", "train_common_gen_RandomSample500.json"),
67
  (
@@ -102,7 +104,7 @@ class CommonGen(datasets.GeneratorBasedBuilder):
102
  name=challenge_split,
103
  gen_kwargs={
104
  "filepath": os.path.join(
105
- dl_dir["challenge_set"], self.config.name, filename
106
  ),
107
  "split": challenge_split,
108
  },
@@ -121,7 +123,7 @@ class CommonGen(datasets.GeneratorBasedBuilder):
121
  if len(exple) == 0:
122
  continue
123
  exple["gem_parent_id"] = exple["gem_id"]
124
- exple["gem_id"] = f"{self.config.name}-{split}-{id_}"
125
  yield id_, exple
126
  else:
127
  with open(filepath, encoding="utf-8") as f:
@@ -136,8 +138,8 @@ class CommonGen(datasets.GeneratorBasedBuilder):
136
  for scene in data["scene"]:
137
  id_ += 1
138
  yield id_, {
139
- "gem_id": f"{self.config.name}-{split}-{id_}",
140
- "gem_parent_id": f"{self.config.name}-{split}-{id_}",
141
  "concept_set_id": i,
142
  "concepts": concepts,
143
  "target": scene,
@@ -146,8 +148,8 @@ class CommonGen(datasets.GeneratorBasedBuilder):
146
  else:
147
  id_ += 1
148
  yield id_, {
149
- "gem_id": f"{self.config.name}-{split}-{id_}",
150
- "gem_parent_id": f"{self.config.name}-{split}-{id_}",
151
  "concept_set_id": id_,
152
  "concepts": concepts,
153
  "target": "" if split == "test" else data["scene"][0],
 
40
  DEFAULT_CONFIG_NAME = "common_gen"
41
 
42
  def _info(self):
43
+ features = datasets.Features(
 
 
44
  {
45
  "gem_id": datasets.Value("string"),
46
  "gem_parent_id": datasets.Value("string"),
 
52
  ], # multiple references for validation
53
  }
54
  ),
55
+
56
+ return datasets.DatasetInfo(
57
+ description=_DESCRIPTION,
58
+ features=features,
59
+ supervised_keys=datasets.info.SupervisedKeysData(input="concepts", output="target"),
60
  homepage="https://inklab.usc.edu/CommonGen/",
61
  citation=_CITATION,
62
  )
63
 
64
  def _split_generators(self, dl_manager):
65
  """Returns SplitGenerators."""
66
+ dl_dir = dl_manager.download_and_extract(_URLs)
67
  challenge_sets = [
68
  ("challenge_train_sample", "train_common_gen_RandomSample500.json"),
69
  (
 
104
  name=challenge_split,
105
  gen_kwargs={
106
  "filepath": os.path.join(
107
+ dl_dir["challenge_set"], "common_gen", filename
108
  ),
109
  "split": challenge_split,
110
  },
 
123
  if len(exple) == 0:
124
  continue
125
  exple["gem_parent_id"] = exple["gem_id"]
126
+ exple["gem_id"] = f"common_gen-{split}-{id_}"
127
  yield id_, exple
128
  else:
129
  with open(filepath, encoding="utf-8") as f:
 
138
  for scene in data["scene"]:
139
  id_ += 1
140
  yield id_, {
141
+ "gem_id": f"common_gen-{split}-{id_}",
142
+ "gem_parent_id": f"common_gen-{split}-{id_}",
143
  "concept_set_id": i,
144
  "concepts": concepts,
145
  "target": scene,
 
148
  else:
149
  id_ += 1
150
  yield id_, {
151
+ "gem_id": f"common_gen-{split}-{id_}",
152
+ "gem_parent_id": f"common_gen-{split}-{id_}",
153
  "concept_set_id": id_,
154
  "concepts": concepts,
155
  "target": "" if split == "test" else data["scene"][0],