shivmoha@utexas.edu commited on
Commit
e2013ac
1 Parent(s): 7622c97

add json files

Browse files
.gitignore ADDED
@@ -0,0 +1 @@
 
1
+ .idea
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="PyChainedComparisonsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
5
+ <option name="ignoreConstantInTheMiddle" value="true" />
6
+ </inspection_tool>
7
+ <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
8
+ <option name="ignoredPackages">
9
+ <value>
10
+ <list size="8">
11
+ <item index="0" class="java.lang.String" itemvalue="tensorboard" />
12
+ <item index="1" class="java.lang.String" itemvalue="future" />
13
+ <item index="2" class="java.lang.String" itemvalue="matplotlib" />
14
+ <item index="3" class="java.lang.String" itemvalue="torch" />
15
+ <item index="4" class="java.lang.String" itemvalue="numpy" />
16
+ <item index="5" class="java.lang.String" itemvalue="torchvision" />
17
+ <item index="6" class="java.lang.String" itemvalue="PySuperTuxKart" />
18
+ <item index="7" class="java.lang.String" itemvalue="Pillow" />
19
+ </list>
20
+ </value>
21
+ </option>
22
+ </inspection_tool>
23
+ <inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
24
+ <option name="ignoredErrors">
25
+ <list>
26
+ <option value="N806" />
27
+ </list>
28
+ </option>
29
+ </inspection_tool>
30
+ <inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
31
+ <option name="ignoredIdentifiers">
32
+ <list>
33
+ <option value="int.detach" />
34
+ </list>
35
+ </option>
36
+ </inspection_tool>
37
+ </profile>
38
+ </component>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/squad-unanswerable.iml" filepath="$PROJECT_DIR$/.idea/squad-unanswerable.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
squad-unanswerable.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """TODO(squad_v2): Add a description here."""
2
+
3
+
4
+ import json
5
+
6
+ import datasets
7
+ from datasets.tasks import QuestionAnsweringExtractive
8
+
9
+
10
+ # TODO(squad_v2): BibTeX citation
11
+ _CITATION = """\
12
+ @article{2016arXiv160605250R,
13
+ author = {{Rajpurkar}, Pranav and {Zhang}, Jian and {Lopyrev},
14
+ Konstantin and {Liang}, Percy},
15
+ title = "{SQuAD: 100,000+ Questions for Machine Comprehension of Text}",
16
+ journal = {arXiv e-prints},
17
+ year = 2016,
18
+ eid = {arXiv:1606.05250},
19
+ pages = {arXiv:1606.05250},
20
+ archivePrefix = {arXiv},
21
+ eprint = {1606.05250},
22
+ }
23
+ """
24
+
25
+ _DESCRIPTION = """\
26
+ combines the 100,000 questions in SQuAD1.1 with over 50,000 unanswerable questions written adversarially by crowdworkers
27
+ to look similar to answerable ones. To do well on SQuAD2.0, systems must not only answer questions when possible, but
28
+ also determine when no answer is supported by the paragraph and abstain from answering.
29
+ """
30
+
31
+ _URL = "https://rajpurkar.github.io/SQuAD-explorer/dataset/"
32
+ _URLS = {
33
+ "train": _URL + "train-v2.0.json",
34
+ "dev": _URL + "dev-v2.0.json",
35
+ }
36
+
37
+
38
+ class SquadV2Config(datasets.BuilderConfig):
39
+ """BuilderConfig for SQUAD."""
40
+
41
+ def __init__(self, **kwargs):
42
+ """BuilderConfig for SQUADV2.
43
+ Args:
44
+ **kwargs: keyword arguments forwarded to super.
45
+ """
46
+ super(SquadV2Config, self).__init__(**kwargs)
47
+
48
+
49
+ class SquadV2(datasets.GeneratorBasedBuilder):
50
+ """TODO(squad_v2): Short description of my dataset."""
51
+
52
+ # TODO(squad_v2): Set up version.
53
+ BUILDER_CONFIGS = [
54
+ SquadV2Config(name="squad_v2", version=datasets.Version("2.0.0"), description="SQuAD plaint text version 2"),
55
+ ]
56
+
57
+ def _info(self):
58
+ # TODO(squad_v2): Specifies the datasets.DatasetInfo object
59
+ return datasets.DatasetInfo(
60
+ # This is the description that will appear on the datasets page.
61
+ description=_DESCRIPTION,
62
+ # datasets.features.FeatureConnectors
63
+ features=datasets.Features(
64
+ {
65
+ "id": datasets.Value("string"),
66
+ "title": datasets.Value("string"),
67
+ "context": datasets.Value("string"),
68
+ "question": datasets.Value("string"),
69
+ "answers": datasets.features.Sequence(
70
+ {
71
+ "text": datasets.Value("string"),
72
+ "answer_start": datasets.Value("int32"),
73
+ }
74
+ ),
75
+ # These are the features of your dataset like images, labels ...
76
+ }
77
+ ),
78
+ # If there's a common (input, target) tuple from the features,
79
+ # specify them here. They'll be used if as_supervised=True in
80
+ # builder.as_dataset.
81
+ supervised_keys=None,
82
+ # Homepage of the dataset for documentation
83
+ homepage="https://rajpurkar.github.io/SQuAD-explorer/",
84
+ citation=_CITATION,
85
+ task_templates=[
86
+ QuestionAnsweringExtractive(
87
+ question_column="question", context_column="context", answers_column="answers"
88
+ )
89
+ ],
90
+ )
91
+
92
+ def _split_generators(self, dl_manager):
93
+ """Returns SplitGenerators."""
94
+ # TODO(squad_v2): Downloads the data and defines the splits
95
+ # dl_manager is a datasets.download.DownloadManager that can be used to
96
+ # download and extract URLs
97
+ urls_to_download = _URLS
98
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
99
+
100
+ return [
101
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
102
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
103
+ ]
104
+
105
+ def _generate_examples(self, filepath):
106
+ """Yields examples."""
107
+ # TODO(squad_v2): Yields (key, example) tuples from the dataset
108
+ with open(filepath, encoding="utf-8") as f:
109
+ squad = json.load(f)
110
+ for example in squad["data"]:
111
+ title = example.get("title", "")
112
+ for paragraph in example["paragraphs"]:
113
+ context = paragraph["context"] # do not strip leading blank spaces GH-2585
114
+ for qa in paragraph["qas"]:
115
+ question = qa["question"]
116
+ id_ = qa["id"]
117
+
118
+ answer_starts = [answer["answer_start"] for answer in qa["answers"]]
119
+ answers = [answer["text"] for answer in qa["answers"]]
120
+
121
+ # Features currently used are "context", "question", and "answers".
122
+ # Others are extracted here for the ease of future expansions.
123
+ if not answers:
124
+ yield id_, {
125
+ "title": title,
126
+ "context": context,
127
+ "question": question,
128
+ "id": id_,
129
+ "answers": {
130
+ "answer_start": answer_starts,
131
+ "text": answers,
132
+ },
133
+ }