Datasets:

Modalities:
Text
Formats:
parquet
Languages:
English
ArXiv:
Libraries:
Datasets
pandas
License:
albertvillanova HF staff commited on
Commit
4c592de
1 Parent(s): 6bcab1c

Delete loading script

Browse files
Files changed (1) hide show
  1. common_gen.py +0 -109
common_gen.py DELETED
@@ -1,109 +0,0 @@
1
- import json
2
- import os
3
- import random
4
-
5
- import datasets
6
-
7
-
8
- random.seed(42) # This is important, to ensure the same order for concept sets as the official script.
9
-
10
- _CITATION = """\
11
- @inproceedings{lin-etal-2020-commongen,
12
- title = "{C}ommon{G}en: A Constrained Text Generation Challenge for Generative Commonsense Reasoning",
13
- author = "Lin, Bill Yuchen and
14
- Zhou, Wangchunshu and
15
- Shen, Ming and
16
- Zhou, Pei and
17
- Bhagavatula, Chandra and
18
- Choi, Yejin and
19
- Ren, Xiang",
20
- booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2020",
21
- month = nov,
22
- year = "2020",
23
- address = "Online",
24
- publisher = "Association for Computational Linguistics",
25
- url = "https://www.aclweb.org/anthology/2020.findings-emnlp.165",
26
- doi = "10.18653/v1/2020.findings-emnlp.165",
27
- pages = "1823--1840"
28
- }
29
- """
30
-
31
- _DESCRIPTION = """\
32
- CommonGen is a constrained text generation task, associated with a benchmark dataset,
33
- to explicitly test machines for the ability of generative commonsense reasoning. Given
34
- a set of common concepts; the task is to generate a coherent sentence describing an
35
- everyday scenario using these concepts.
36
-
37
- CommonGen is challenging because it inherently requires 1) relational reasoning using
38
- background commonsense knowledge, and 2) compositional generalization ability to work
39
- on unseen concept combinations. Our dataset, constructed through a combination of
40
- crowd-sourcing from AMT and existing caption corpora, consists of 30k concept-sets and
41
- 50k sentences in total.
42
- """
43
- _URL = "https://storage.googleapis.com/huggingface-nlp/datasets/common_gen/commongen_data.zip"
44
-
45
-
46
- class CommonGen(datasets.GeneratorBasedBuilder):
47
- VERSION = datasets.Version("2020.5.30")
48
-
49
- def _info(self):
50
- features = datasets.Features(
51
- {
52
- "concept_set_idx": datasets.Value("int32"),
53
- "concepts": datasets.Sequence(datasets.Value("string")),
54
- "target": datasets.Value("string"),
55
- }
56
- )
57
- return datasets.DatasetInfo(
58
- description=_DESCRIPTION,
59
- features=features,
60
- supervised_keys=datasets.info.SupervisedKeysData(input="concepts", output="target"),
61
- homepage="https://inklab.usc.edu/CommonGen/index.html",
62
- citation=_CITATION,
63
- )
64
-
65
- def _split_generators(self, dl_manager):
66
- """Returns SplitGenerators."""
67
-
68
- dl_dir = dl_manager.download_and_extract(_URL)
69
-
70
- return [
71
- datasets.SplitGenerator(
72
- name=datasets.Split.TRAIN,
73
- gen_kwargs={"filepath": os.path.join(dl_dir, "commongen.train.jsonl"), "split": "train"},
74
- ),
75
- datasets.SplitGenerator(
76
- name=datasets.Split.VALIDATION,
77
- gen_kwargs={"filepath": os.path.join(dl_dir, "commongen.dev.jsonl"), "split": "dev"},
78
- ),
79
- datasets.SplitGenerator(
80
- name=datasets.Split.TEST,
81
- gen_kwargs={"filepath": os.path.join(dl_dir, "commongen.test_noref.jsonl"), "split": "test"},
82
- ),
83
- ]
84
-
85
- def _generate_examples(self, filepath, split):
86
- """Yields examples."""
87
- with open(filepath, encoding="utf-8") as f:
88
- id_ = 0
89
- for idx, row in enumerate(f):
90
- row = row.replace(", }", "}") # Fix possible JSON format error
91
- data = json.loads(row)
92
-
93
- rand_order = [word for word in data["concept_set"].split("#")]
94
- random.shuffle(rand_order)
95
-
96
- if split == "test":
97
- yield idx, {
98
- "concept_set_idx": idx,
99
- "concepts": rand_order,
100
- "target": "",
101
- }
102
- else:
103
- for scene in data["scene"]:
104
- yield id_, {
105
- "concept_set_idx": idx,
106
- "concepts": rand_order,
107
- "target": scene,
108
- }
109
- id_ += 1