system HF staff commited on
Commit
9c52d99
0 Parent(s):

Update files from the datasets library (from 1.7.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.7.0

.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - found
6
+ languages:
7
+ - en
8
+ licenses:
9
+ - unknown
10
+ multilinguality:
11
+ - monolingual
12
+ size_categories:
13
+ - 1K<n<10K
14
+ source_datasets:
15
+ - original
16
+ - extended|yelp_review_full
17
+ - extended|other-amazon_reviews_ucsd
18
+ - extended|other-tripadvisor_reviews
19
+ task_categories:
20
+ - question-answering
21
+ task_ids:
22
+ - extractive-qa
23
+ paperswithcode_id: subjqa
24
+ ---
25
+
26
+ # Dataset Card for subjqa
27
+
28
+ ## Table of Contents
29
+ - [Dataset Description](#dataset-description)
30
+ - [Dataset Summary](#dataset-summary)
31
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
32
+ - [Languages](#languages)
33
+ - [Dataset Structure](#dataset-structure)
34
+ - [Data Instances](#data-instances)
35
+ - [Data Fields](#data-fields)
36
+ - [Data Splits](#data-splits)
37
+ - [Dataset Creation](#dataset-creation)
38
+ - [Curation Rationale](#curation-rationale)
39
+ - [Source Data](#source-data)
40
+ - [Annotations](#annotations)
41
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
42
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
43
+ - [Social Impact of Dataset](#social-impact-of-dataset)
44
+ - [Discussion of Biases](#discussion-of-biases)
45
+ - [Other Known Limitations](#other-known-limitations)
46
+ - [Additional Information](#additional-information)
47
+ - [Dataset Curators](#dataset-curators)
48
+ - [Licensing Information](#licensing-information)
49
+ - [Citation Information](#citation-information)
50
+ - [Contributions](#contributions)
51
+
52
+ ## Dataset Description
53
+
54
+ - **Repository:** https://github.com/lewtun/SubjQA
55
+ - **Paper:** https://arxiv.org/abs/2004.14283
56
+ - **Point of Contact:** [Lewis Tunstall](mailto:lewis.c.tunstall@gmail.com)
57
+
58
+ ### Dataset Summary
59
+
60
+ SubjQA is a question answering dataset that focuses on subjective (as opposed to factual) questions and answers. The dataset consists of roughly **10,000** questions over reviews from 6 different domains: books, movies, grocery, electronics, TripAdvisor (i.e. hotels), and restaurants. Each question is paired with a review and a span is highlighted as the answer to the question (with some questions having no answer). Moreover, both questions and answer spans are assigned a _subjectivity_ label by annotators. Questions such as _"How much does this product weigh?"_ is a factual question (i.e., low subjectivity), while "Is this easy to use?" is a subjective question (i.e., high subjectivity).
61
+
62
+ In short, SubjQA provides a setting to study how well extractive QA systems perform on finding answer that are less factual and to what extent modeling subjectivity can improve the performance of QA systems.
63
+
64
+ _Note:_ Much of the information provided on this dataset card is taken from the README provided by the authors in their GitHub repository ([link](https://github.com/megagonlabs/SubjQA)).
65
+
66
+ To load a domain with `datasets` you can run the following:
67
+
68
+ ```python
69
+ from datasets import load_dataset
70
+
71
+ # other options include: electronics, grocery, movies, restaurants, tripadvisor
72
+ dataset = load_dataset("subjqa", "books")
73
+ ```
74
+
75
+ ### Supported Tasks and Leaderboards
76
+
77
+ * `question-answering`: The dataset can be used to train a model for extractive question answering, which involves questions whose answer can be identified as a span of text in a review. Success on this task is typically measured by achieving a high Exact Match or F1 score. The BERT model that is first fine-tuned on SQuAD 2.0 and then further fine-tuned on SubjQA achieves the scores shown in the figure below.
78
+
79
+ ![scores](https://user-images.githubusercontent.com/26859204/117199763-e02e1100-adea-11eb-9198-f3190329a588.png)
80
+
81
+
82
+ ### Languages
83
+
84
+ The text in the dataset is in English and the associated BCP-47 code is `en`.
85
+
86
+ ## Dataset Structure
87
+
88
+ ### Data Instances
89
+
90
+ An example from `books` domain is shown below:
91
+
92
+ ```json
93
+ {
94
+ "answers": {
95
+ "ans_subj_score": [1.0],
96
+ "answer_start": [324],
97
+ "answer_subj_level": [2],
98
+ "is_ans_subjective": [true],
99
+ "text": ["This is a wonderfully written book"],
100
+ },
101
+ "context": "While I would not recommend this book to a young reader due to a couple pretty explicate scenes I would recommend it to any adult who just loves a good book. Once I started reading it I could not put it down. I hesitated reading it because I didn't think that the subject matter would be interesting, but I was so wrong. This is a wonderfully written book.",
102
+ "domain": "books",
103
+ "id": "0255768496a256c5ed7caed9d4e47e4c",
104
+ "is_ques_subjective": false,
105
+ "nn_asp": "matter",
106
+ "nn_mod": "interesting",
107
+ "q_reviews_id": "a907837bafe847039c8da374a144bff9",
108
+ "query_asp": "part",
109
+ "query_mod": "fascinating",
110
+ "ques_subj_score": 0.0,
111
+ "question": "What are the parts like?",
112
+ "question_subj_level": 2,
113
+ "review_id": "a7f1a2503eac2580a0ebbc1d24fffca1",
114
+ "title": "0002007770",
115
+ }
116
+ ```
117
+
118
+ ### Data Fields
119
+
120
+ Each domain and split consists of the following columns:
121
+
122
+ * ```title```: The id of the item/business discussed in the review.
123
+ * ```question```: The question (written based on a query opinion).
124
+ * ```id```: A unique id assigned to the question-review pair.
125
+ * ```q_reviews_id```: A unique id assigned to all question-review pairs with a shared question.
126
+ * ```question_subj_level```: The subjectiviy level of the question (on a 1 to 5 scale with 1 being the most subjective).
127
+ * ```ques_subj_score```: The subjectivity score of the question computed using the [TextBlob](https://textblob.readthedocs.io/en/dev/) package.
128
+ * ```context```: The review (that mentions the neighboring opinion).
129
+ * ```review_id```: A unique id associated with the review.
130
+ * ```answers.text```: The span labeled by annotators as the answer.
131
+ * ```answers.answer_start```: The (character-level) start index of the answer span highlighted by annotators.
132
+ * ```is_ques_subjective```: A boolean subjectivity label derived from ```question_subj_level``` (i.e., scores below 4 are considered as subjective)
133
+ * ```answers.answer_subj_level```: The subjectiviy level of the answer span (on a 1 to 5 scale with 5 being the most subjective).
134
+ * ```answers.ans_subj_score```: The subjectivity score of the answer span computed usign the [TextBlob](https://textblob.readthedocs.io/en/dev/) package.
135
+ * ```answers.is_ans_subjective```: A boolean subjectivity label derived from ```answer_subj_level``` (i.e., scores below 4 are considered as subjective)
136
+ * ```domain```: The category/domain of the review (e.g., hotels, books, ...).
137
+ * ```nn_mod```: The modifier of the neighboring opinion (which appears in the review).
138
+ * ```nn_asp```: The aspect of the neighboring opinion (which appears in the review).
139
+ * ```query_mod```: The modifier of the query opinion (around which a question is manually written).
140
+ * ```query_asp```: The aspect of the query opinion (around which a question is manually written).
141
+
142
+ ### Data Splits
143
+
144
+ The question-review pairs from each domain are split into training, development, and test sets. The table below shows the size of the dataset per each domain and split.
145
+
146
+ | Domain | Train | Dev | Test | Total |
147
+ |-------------|-------|-----|------|-------|
148
+ | TripAdvisor | 1165 | 230 | 512 | 1686 |
149
+ | Restaurants | 1400 | 267 | 266 | 1683 |
150
+ | Movies | 1369 | 261 | 291 | 1677 |
151
+ | Books | 1314 | 256 | 345 | 1668 |
152
+ | Electronics | 1295 | 255 | 358 | 1659 |
153
+ | Grocery | 1124 | 218 | 591 | 1725 |
154
+
155
+ Based on the subjectivity labels provided by annotators, one observes that 73% of the questions and 74% of the answers in the dataset are subjective. This provides a substantial number of subjective QA pairs as well as a reasonable number of factual questions to compare and constrast the performance of QA systems on each type of QA pairs.
156
+
157
+ Finally, the next table summarizes the average length of the question, the review, and the highlighted answer span for each category.
158
+
159
+ | Domain | Review Len | Question Len | Answer Len | % answerable |
160
+ |-------------|------------|--------------|------------|--------------|
161
+ | TripAdvisor | 187.25 | 5.66 | 6.71 | 78.17 |
162
+ | Restaurants | 185.40 | 5.44 | 6.67 | 60.72 |
163
+ | Movies | 331.56 | 5.59 | 7.32 | 55.69 |
164
+ | Books | 285.47 | 5.78 | 7.78 | 52.99 |
165
+ | Electronics | 249.44 | 5.56 | 6.98 | 58.89 |
166
+ | Grocery | 164.75 | 5.44 | 7.25 | 64.69 |
167
+
168
+ ## Dataset Creation
169
+
170
+ ### Curation Rationale
171
+
172
+ Most question-answering datasets like SQuAD and Natural Questions focus on answering questions over factual data such as Wikipedia and news articles. However, in domains like e-commerce the questions and answers are often _subjective_, that is, they depend on the personal experience of the users. For example, a customer on Amazon may ask "Is the sound quality any good?", which is more difficult to answer than a factoid question like "What is the capital of Australia?" These considerations motivate the creation of SubjQA as a tool to investigate the relationship between subjectivity and question-answering.
173
+
174
+ ### Source Data
175
+
176
+ #### Initial Data Collection and Normalization
177
+
178
+ The SubjQA dataset is constructed based on publicly available review datasets. Specifically, the _movies_, _books_, _electronics_, and _grocery_ categories are constructed using reviews from the [Amazon Review dataset](http://jmcauley.ucsd.edu/data/amazon/links.html). The _TripAdvisor_ category, as the name suggests, is constructed using reviews from TripAdvisor which can be found [here](http://times.cs.uiuc.edu/~wang296/Data/). Finally, the _restaurants_ category is constructed using the [Yelp Dataset](https://www.yelp.com/dataset) which is also publicly available.
179
+
180
+ The process of constructing SubjQA is discussed in detail in the [paper](https://arxiv.org/abs/2004.14283). In a nutshell, the dataset construction consists of the following steps:
181
+
182
+ 1. First, all _opinions_ expressed in reviews are extracted. In the pipeline, each opinion is modeled as a (_modifier_, _aspect_) pair which is a pair of spans where the former describes the latter. (good, hotel), and (terrible, acting) are a few examples of extracted opinions.
183
+ 2. Using Matrix Factorization techniques, implication relationships between different expressed opinions are mined. For instance, the system mines that "responsive keys" implies "good keyboard". In our pipeline, we refer to the conclusion of an implication (i.e., "good keyboard" in this examples) as the _query_ opinion, and we refer to the premise (i.e., "responsive keys") as its _neighboring_ opinion.
184
+ 3. Annotators are then asked to write a question based on _query_ opinions. For instance given "good keyboard" as the query opinion, they might write "Is this keyboard any good?"
185
+ 4. Each question written based on a _query_ opinion is then paired with a review that mentions its _neighboring_ opinion. In our example, that would be a review that mentions "responsive keys".
186
+ 5. The question and review pairs are presented to annotators to select the correct answer span, and rate the subjectivity level of the question as well as the subjectivity level of the highlighted answer span.
187
+
188
+ A visualisation of the data collection pipeline is shown in the image below.
189
+
190
+ ![preview](https://user-images.githubusercontent.com/26859204/117258393-3764cd80-ae4d-11eb-955d-aa971dbb282e.jpg)
191
+
192
+ #### Who are the source language producers?
193
+
194
+ As described above, the source data for SubjQA is customer reviews of products and services on e-commerce websites like Amazon and TripAdvisor.
195
+
196
+ ### Annotations
197
+
198
+ #### Annotation process
199
+
200
+ The generation of questions and answer span labels were obtained through the [Appen](https://appen.com/) platform. From the SubjQA paper:
201
+
202
+ > The platform provides quality control by showing the workers 5 questions at a time, out of which one is labeled by the experts. A worker who fails to maintain 70% accuracy is kicked out by the platform and his judgements are ignored ... To ensure good quality labels, we paid each worker 5 cents per annotation.
203
+
204
+ The instructions for generating a question are shown in the following figure:
205
+
206
+ <img width="874" alt="ques_gen" src="https://user-images.githubusercontent.com/26859204/117259092-03d67300-ae4e-11eb-81f2-9077fee1085f.png">
207
+
208
+ Similarly, the interface for the answer span and subjectivity labelling tasks is shown below:
209
+
210
+ ![span_collection](https://user-images.githubusercontent.com/26859204/117259223-1fda1480-ae4e-11eb-9305-658ee6e3971d.png)
211
+
212
+ As described in the SubjQA paper, the workers assign subjectivity scores (1-5) to each question and the selected answer span. They can also indicate if a question cannot be answered from the given review.
213
+
214
+
215
+ #### Who are the annotators?
216
+
217
+ Workers on the Appen platform.
218
+
219
+ ### Personal and Sensitive Information
220
+
221
+ [Needs More Information]
222
+
223
+ ## Considerations for Using the Data
224
+
225
+ ### Social Impact of Dataset
226
+
227
+ The SubjQA dataset can be used to develop question-answering systems that can provide better on-demand answers to e-commerce customers who are interested in subjective questions about products and services.
228
+
229
+ ### Discussion of Biases
230
+
231
+ [Needs More Information]
232
+
233
+ ### Other Known Limitations
234
+
235
+ [Needs More Information]
236
+
237
+ ## Additional Information
238
+
239
+ ### Dataset Curators
240
+
241
+ The people involved in creating the SubjQA dataset are the authors of the accompanying paper:
242
+
243
+ * Johannes Bjerva1, Department of Computer Science, University of Copenhagen, Department of Computer Science, Aalborg University
244
+ * Nikita Bhutani, Megagon Labs, Mountain View
245
+ * Behzad Golshan, Megagon Labs, Mountain View
246
+ * Wang-Chiew Tan, Megagon Labs, Mountain View
247
+ * Isabelle Augenstein, Department of Computer Science, University of Copenhagen
248
+
249
+ ### Licensing Information
250
+
251
+ The SubjQA dataset is provided "as-is", and its creators make no representation as to its accuracy.
252
+
253
+ The SubjQA dataset is constructed based on the following datasets and thus contains subsets of their data:
254
+ * [Amazon Review Dataset](http://jmcauley.ucsd.edu/data/amazon/links.html) from UCSD
255
+ * Used for _books_, _movies_, _grocery_, and _electronics_ domains
256
+ * [The TripAdvisor Dataset](http://times.cs.uiuc.edu/~wang296/Data/) from UIUC's Database and Information Systems Laboratory
257
+ * Used for the _TripAdvisor_ domain
258
+ * [The Yelp Dataset](https://www.yelp.com/dataset)
259
+ * Used for the _restaurants_ domain
260
+
261
+ Consequently, the data within each domain of the SubjQA dataset should be considered under the same license as the dataset it was built upon.
262
+
263
+ ### Citation Information
264
+
265
+ If you are using the dataset, please cite the following in your work:
266
+ ```
267
+ @inproceedings{bjerva20subjqa,
268
+ title = "SubjQA: A Dataset for Subjectivity and Review Comprehension",
269
+ author = "Bjerva, Johannes and
270
+ Bhutani, Nikita and
271
+ Golahn, Behzad and
272
+ Tan, Wang-Chiew and
273
+ Augenstein, Isabelle",
274
+ booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing",
275
+ month = November,
276
+ year = "2020",
277
+ publisher = "Association for Computational Linguistics",
278
+ }
279
+ ```
280
+
281
+ ### Contributions
282
+
283
+ Thanks to [@lewtun](https://github.com/lewtun) for adding this dataset.
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
1
+ {"books": {"description": "SubjQA is a question answering dataset that focuses on subjective questions and answers.\nThe dataset consists of roughly 10,000 questions over reviews from 6 different domains: books, movies, grocery,\nelectronics, TripAdvisor (i.e. hotels), and restaurants.", "citation": "@inproceedings{bjerva20subjqa,\n title = \"SubjQA: A Dataset for Subjectivity and Review Comprehension\",\n author = \"Bjerva, Johannes and\n Bhutani, Nikita and\n Golahn, Behzad and\n Tan, Wang-Chiew and\n Augenstein, Isabelle\",\n booktitle = \"Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing\",\n month = November,\n year = \"2020\",\n publisher = \"Association for Computational Linguistics\",\n}\n", "homepage": "", "license": "", "features": {"domain": {"dtype": "string", "id": null, "_type": "Value"}, "nn_mod": {"dtype": "string", "id": null, "_type": "Value"}, "nn_asp": {"dtype": "string", "id": null, "_type": "Value"}, "query_mod": {"dtype": "string", "id": null, "_type": "Value"}, "query_asp": {"dtype": "string", "id": null, "_type": "Value"}, "q_reviews_id": {"dtype": "string", "id": null, "_type": "Value"}, "question_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ques_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ques_subjective": {"dtype": "bool", "id": null, "_type": "Value"}, "review_id": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "context": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answers": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "answer_start": {"dtype": "int32", "id": null, "_type": "Value"}, "answer_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ans_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ans_subjective": {"dtype": "bool", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "subjqa", "config_name": "books", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2473128, "num_examples": 1314, "dataset_name": "subjqa"}, "test": {"name": "test", "num_bytes": 649413, "num_examples": 345, "dataset_name": "subjqa"}, "validation": {"name": "validation", "num_bytes": 460214, "num_examples": 256, "dataset_name": "subjqa"}}, "download_checksums": {"https://github.com/lewtun/SubjQA/archive/refs/heads/master.zip": {"num_bytes": 11384657, "checksum": "f3d58fd04c698fccb326b7ea4ea93098cc2186a3925f4bbad9b538ed7acc72db"}}, "download_size": 11384657, "post_processing_size": null, "dataset_size": 3582755, "size_in_bytes": 14967412}, "electronics": {"description": "SubjQA is a question answering dataset that focuses on subjective questions and answers.\nThe dataset consists of roughly 10,000 questions over reviews from 6 different domains: books, movies, grocery,\nelectronics, TripAdvisor (i.e. hotels), and restaurants.", "citation": "@inproceedings{bjerva20subjqa,\n title = \"SubjQA: A Dataset for Subjectivity and Review Comprehension\",\n author = \"Bjerva, Johannes and\n Bhutani, Nikita and\n Golahn, Behzad and\n Tan, Wang-Chiew and\n Augenstein, Isabelle\",\n booktitle = \"Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing\",\n month = November,\n year = \"2020\",\n publisher = \"Association for Computational Linguistics\",\n}\n", "homepage": "", "license": "", "features": {"domain": {"dtype": "string", "id": null, "_type": "Value"}, "nn_mod": {"dtype": "string", "id": null, "_type": "Value"}, "nn_asp": {"dtype": "string", "id": null, "_type": "Value"}, "query_mod": {"dtype": "string", "id": null, "_type": "Value"}, "query_asp": {"dtype": "string", "id": null, "_type": "Value"}, "q_reviews_id": {"dtype": "string", "id": null, "_type": "Value"}, "question_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ques_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ques_subjective": {"dtype": "bool", "id": null, "_type": "Value"}, "review_id": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "context": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answers": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "answer_start": {"dtype": "int32", "id": null, "_type": "Value"}, "answer_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ans_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ans_subjective": {"dtype": "bool", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "subjqa", "config_name": "electronics", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2123648, "num_examples": 1295, "dataset_name": "subjqa"}, "test": {"name": "test", "num_bytes": 608899, "num_examples": 358, "dataset_name": "subjqa"}, "validation": {"name": "validation", "num_bytes": 419042, "num_examples": 255, "dataset_name": "subjqa"}}, "download_checksums": {"https://github.com/lewtun/SubjQA/archive/refs/heads/master.zip": {"num_bytes": 11384657, "checksum": "f3d58fd04c698fccb326b7ea4ea93098cc2186a3925f4bbad9b538ed7acc72db"}}, "download_size": 11384657, "post_processing_size": null, "dataset_size": 3151589, "size_in_bytes": 14536246}, "grocery": {"description": "SubjQA is a question answering dataset that focuses on subjective questions and answers.\nThe dataset consists of roughly 10,000 questions over reviews from 6 different domains: books, movies, grocery,\nelectronics, TripAdvisor (i.e. hotels), and restaurants.", "citation": "@inproceedings{bjerva20subjqa,\n title = \"SubjQA: A Dataset for Subjectivity and Review Comprehension\",\n author = \"Bjerva, Johannes and\n Bhutani, Nikita and\n Golahn, Behzad and\n Tan, Wang-Chiew and\n Augenstein, Isabelle\",\n booktitle = \"Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing\",\n month = November,\n year = \"2020\",\n publisher = \"Association for Computational Linguistics\",\n}\n", "homepage": "", "license": "", "features": {"domain": {"dtype": "string", "id": null, "_type": "Value"}, "nn_mod": {"dtype": "string", "id": null, "_type": "Value"}, "nn_asp": {"dtype": "string", "id": null, "_type": "Value"}, "query_mod": {"dtype": "string", "id": null, "_type": "Value"}, "query_asp": {"dtype": "string", "id": null, "_type": "Value"}, "q_reviews_id": {"dtype": "string", "id": null, "_type": "Value"}, "question_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ques_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ques_subjective": {"dtype": "bool", "id": null, "_type": "Value"}, "review_id": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "context": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answers": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "answer_start": {"dtype": "int32", "id": null, "_type": "Value"}, "answer_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ans_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ans_subjective": {"dtype": "bool", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "subjqa", "config_name": "grocery", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1317488, "num_examples": 1124, "dataset_name": "subjqa"}, "test": {"name": "test", "num_bytes": 721827, "num_examples": 591, "dataset_name": "subjqa"}, "validation": {"name": "validation", "num_bytes": 254432, "num_examples": 218, "dataset_name": "subjqa"}}, "download_checksums": {"https://github.com/lewtun/SubjQA/archive/refs/heads/master.zip": {"num_bytes": 11384657, "checksum": "f3d58fd04c698fccb326b7ea4ea93098cc2186a3925f4bbad9b538ed7acc72db"}}, "download_size": 11384657, "post_processing_size": null, "dataset_size": 2293747, "size_in_bytes": 13678404}, "movies": {"description": "SubjQA is a question answering dataset that focuses on subjective questions and answers.\nThe dataset consists of roughly 10,000 questions over reviews from 6 different domains: books, movies, grocery,\nelectronics, TripAdvisor (i.e. hotels), and restaurants.", "citation": "@inproceedings{bjerva20subjqa,\n title = \"SubjQA: A Dataset for Subjectivity and Review Comprehension\",\n author = \"Bjerva, Johannes and\n Bhutani, Nikita and\n Golahn, Behzad and\n Tan, Wang-Chiew and\n Augenstein, Isabelle\",\n booktitle = \"Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing\",\n month = November,\n year = \"2020\",\n publisher = \"Association for Computational Linguistics\",\n}\n", "homepage": "", "license": "", "features": {"domain": {"dtype": "string", "id": null, "_type": "Value"}, "nn_mod": {"dtype": "string", "id": null, "_type": "Value"}, "nn_asp": {"dtype": "string", "id": null, "_type": "Value"}, "query_mod": {"dtype": "string", "id": null, "_type": "Value"}, "query_asp": {"dtype": "string", "id": null, "_type": "Value"}, "q_reviews_id": {"dtype": "string", "id": null, "_type": "Value"}, "question_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ques_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ques_subjective": {"dtype": "bool", "id": null, "_type": "Value"}, "review_id": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "context": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answers": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "answer_start": {"dtype": "int32", "id": null, "_type": "Value"}, "answer_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ans_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ans_subjective": {"dtype": "bool", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "subjqa", "config_name": "movies", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2986348, "num_examples": 1369, "dataset_name": "subjqa"}, "test": {"name": "test", "num_bytes": 620513, "num_examples": 291, "dataset_name": "subjqa"}, "validation": {"name": "validation", "num_bytes": 589663, "num_examples": 261, "dataset_name": "subjqa"}}, "download_checksums": {"https://github.com/lewtun/SubjQA/archive/refs/heads/master.zip": {"num_bytes": 11384657, "checksum": "f3d58fd04c698fccb326b7ea4ea93098cc2186a3925f4bbad9b538ed7acc72db"}}, "download_size": 11384657, "post_processing_size": null, "dataset_size": 4196524, "size_in_bytes": 15581181}, "restaurants": {"description": "SubjQA is a question answering dataset that focuses on subjective questions and answers.\nThe dataset consists of roughly 10,000 questions over reviews from 6 different domains: books, movies, grocery,\nelectronics, TripAdvisor (i.e. hotels), and restaurants.", "citation": "@inproceedings{bjerva20subjqa,\n title = \"SubjQA: A Dataset for Subjectivity and Review Comprehension\",\n author = \"Bjerva, Johannes and\n Bhutani, Nikita and\n Golahn, Behzad and\n Tan, Wang-Chiew and\n Augenstein, Isabelle\",\n booktitle = \"Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing\",\n month = November,\n year = \"2020\",\n publisher = \"Association for Computational Linguistics\",\n}\n", "homepage": "", "license": "", "features": {"domain": {"dtype": "string", "id": null, "_type": "Value"}, "nn_mod": {"dtype": "string", "id": null, "_type": "Value"}, "nn_asp": {"dtype": "string", "id": null, "_type": "Value"}, "query_mod": {"dtype": "string", "id": null, "_type": "Value"}, "query_asp": {"dtype": "string", "id": null, "_type": "Value"}, "q_reviews_id": {"dtype": "string", "id": null, "_type": "Value"}, "question_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ques_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ques_subjective": {"dtype": "bool", "id": null, "_type": "Value"}, "review_id": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "context": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answers": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "answer_start": {"dtype": "int32", "id": null, "_type": "Value"}, "answer_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ans_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ans_subjective": {"dtype": "bool", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "subjqa", "config_name": "restaurants", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1823331, "num_examples": 1400, "dataset_name": "subjqa"}, "test": {"name": "test", "num_bytes": 335453, "num_examples": 266, "dataset_name": "subjqa"}, "validation": {"name": "validation", "num_bytes": 349354, "num_examples": 267, "dataset_name": "subjqa"}}, "download_checksums": {"https://github.com/lewtun/SubjQA/archive/refs/heads/master.zip": {"num_bytes": 11384657, "checksum": "f3d58fd04c698fccb326b7ea4ea93098cc2186a3925f4bbad9b538ed7acc72db"}}, "download_size": 11384657, "post_processing_size": null, "dataset_size": 2508138, "size_in_bytes": 13892795}, "tripadvisor": {"description": "SubjQA is a question answering dataset that focuses on subjective questions and answers.\nThe dataset consists of roughly 10,000 questions over reviews from 6 different domains: books, movies, grocery,\nelectronics, TripAdvisor (i.e. hotels), and restaurants.", "citation": "@inproceedings{bjerva20subjqa,\n title = \"SubjQA: A Dataset for Subjectivity and Review Comprehension\",\n author = \"Bjerva, Johannes and\n Bhutani, Nikita and\n Golahn, Behzad and\n Tan, Wang-Chiew and\n Augenstein, Isabelle\",\n booktitle = \"Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing\",\n month = November,\n year = \"2020\",\n publisher = \"Association for Computational Linguistics\",\n}\n", "homepage": "", "license": "", "features": {"domain": {"dtype": "string", "id": null, "_type": "Value"}, "nn_mod": {"dtype": "string", "id": null, "_type": "Value"}, "nn_asp": {"dtype": "string", "id": null, "_type": "Value"}, "query_mod": {"dtype": "string", "id": null, "_type": "Value"}, "query_asp": {"dtype": "string", "id": null, "_type": "Value"}, "q_reviews_id": {"dtype": "string", "id": null, "_type": "Value"}, "question_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ques_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ques_subjective": {"dtype": "bool", "id": null, "_type": "Value"}, "review_id": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "context": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answers": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "answer_start": {"dtype": "int32", "id": null, "_type": "Value"}, "answer_subj_level": {"dtype": "int64", "id": null, "_type": "Value"}, "ans_subj_score": {"dtype": "float32", "id": null, "_type": "Value"}, "is_ans_subjective": {"dtype": "bool", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "subjqa", "config_name": "tripadvisor", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1575021, "num_examples": 1165, "dataset_name": "subjqa"}, "test": {"name": "test", "num_bytes": 689508, "num_examples": 512, "dataset_name": "subjqa"}, "validation": {"name": "validation", "num_bytes": 312645, "num_examples": 230, "dataset_name": "subjqa"}}, "download_checksums": {"https://github.com/lewtun/SubjQA/archive/refs/heads/master.zip": {"num_bytes": 11384657, "checksum": "f3d58fd04c698fccb326b7ea4ea93098cc2186a3925f4bbad9b538ed7acc72db"}}, "download_size": 11384657, "post_processing_size": null, "dataset_size": 2577174, "size_in_bytes": 13961831}}
dummy/books/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:baf0f946146c6767b0c9e956b942f139420c2f6ae37c98e3f68904ca5f85358f
3
+ size 12042
dummy/electronics/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad3f3379cade5b7a4d7372986ce2dc435243a1731e314a0053e35790534a3bae
3
+ size 12189
dummy/grocery/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc06b6f8ecd67751cc8ba8c8a4e3faaacfb772100abe74c1863376d92cc473ec
3
+ size 7371
dummy/movies/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48f31198fac13d9505f767a2128190c5a6755cb260b422817ac63b25fca40ffa
3
+ size 11486
dummy/restaurants/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b3d219dde556e0fc7f092d2f480e429553286dcd7ec6d7ab00afa1d84f5461d
3
+ size 9349
dummy/tripadvisor/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f10f82eb3f98824de4a1ccd6258be4f8ee2aba1a6920d04ca6faadd50dc3273
3
+ size 10747
subjqa.py ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """SubjQA is a question answering dataset that focuses on subjective questions and answers.
16
+ The dataset consists of roughly 10,000 questions over reviews from 6 different domains: books, movies, grocery,
17
+ electronics, TripAdvisor (i.e. hotels), and restaurants."""
18
+
19
+
20
+ import ast
21
+ import os
22
+
23
+ import pandas as pd
24
+
25
+ import datasets
26
+
27
+
28
+ _CITATION = """\
29
+ @inproceedings{bjerva20subjqa,
30
+ title = "SubjQA: A Dataset for Subjectivity and Review Comprehension",
31
+ author = "Bjerva, Johannes and
32
+ Bhutani, Nikita and
33
+ Golahn, Behzad and
34
+ Tan, Wang-Chiew and
35
+ Augenstein, Isabelle",
36
+ booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing",
37
+ month = November,
38
+ year = "2020",
39
+ publisher = "Association for Computational Linguistics",
40
+ }
41
+ """
42
+
43
+ _DESCRIPTION = """SubjQA is a question answering dataset that focuses on subjective questions and answers.
44
+ The dataset consists of roughly 10,000 questions over reviews from 6 different domains: books, movies, grocery,
45
+ electronics, TripAdvisor (i.e. hotels), and restaurants."""
46
+
47
+ _HOMEPAGE = ""
48
+
49
+ _LICENSE = ""
50
+
51
+ _URLs = {"default": "https://github.com/lewtun/SubjQA/archive/refs/heads/master.zip"}
52
+
53
+
54
+ class Subjqa(datasets.GeneratorBasedBuilder):
55
+ """SubjQA is a question answering dataset that focuses on subjective questions and answers."""
56
+
57
+ VERSION = datasets.Version("1.1.0")
58
+
59
+ BUILDER_CONFIGS = [
60
+ datasets.BuilderConfig(name="books", version=VERSION, description="Amazon book reviews"),
61
+ datasets.BuilderConfig(name="electronics", version=VERSION, description="Amazon electronics reviews"),
62
+ datasets.BuilderConfig(name="grocery", version=VERSION, description="Amazon grocery reviews"),
63
+ datasets.BuilderConfig(name="movies", version=VERSION, description="Amazon movie reviews"),
64
+ datasets.BuilderConfig(name="restaurants", version=VERSION, description="Yelp restaurant reviews"),
65
+ datasets.BuilderConfig(name="tripadvisor", version=VERSION, description="TripAdvisor hotel reviews"),
66
+ ]
67
+
68
+ def _info(self):
69
+ features = datasets.Features(
70
+ {
71
+ "domain": datasets.Value("string"),
72
+ "nn_mod": datasets.Value("string"),
73
+ "nn_asp": datasets.Value("string"),
74
+ "query_mod": datasets.Value("string"),
75
+ "query_asp": datasets.Value("string"),
76
+ "q_reviews_id": datasets.Value("string"),
77
+ "question_subj_level": datasets.Value("int64"),
78
+ "ques_subj_score": datasets.Value("float"),
79
+ "is_ques_subjective": datasets.Value("bool"),
80
+ "review_id": datasets.Value("string"),
81
+ "id": datasets.Value("string"),
82
+ "title": datasets.Value("string"),
83
+ "context": datasets.Value("string"),
84
+ "question": datasets.Value("string"),
85
+ "answers": datasets.features.Sequence(
86
+ {
87
+ "text": datasets.Value("string"),
88
+ "answer_start": datasets.Value("int32"),
89
+ "answer_subj_level": datasets.Value("int64"),
90
+ "ans_subj_score": datasets.Value("float"),
91
+ "is_ans_subjective": datasets.Value("bool"),
92
+ }
93
+ ),
94
+ }
95
+ )
96
+ return datasets.DatasetInfo(
97
+ description=_DESCRIPTION,
98
+ features=features,
99
+ supervised_keys=None,
100
+ homepage=_HOMEPAGE,
101
+ license=_LICENSE,
102
+ citation=_CITATION,
103
+ )
104
+
105
+ def _split_generators(self, dl_manager):
106
+ data_dir = dl_manager.download_and_extract(_URLs["default"])
107
+ return [
108
+ datasets.SplitGenerator(
109
+ name=datasets.Split.TRAIN,
110
+ gen_kwargs={
111
+ "filepath": os.path.join(data_dir, f"SubjQA-master/SubjQA/{self.config.name}/splits/train.csv")
112
+ },
113
+ ),
114
+ datasets.SplitGenerator(
115
+ name=datasets.Split.TEST,
116
+ gen_kwargs={
117
+ "filepath": os.path.join(data_dir, f"SubjQA-master/SubjQA/{self.config.name}/splits/test.csv")
118
+ },
119
+ ),
120
+ datasets.SplitGenerator(
121
+ name=datasets.Split.VALIDATION,
122
+ gen_kwargs={
123
+ "filepath": os.path.join(data_dir, f"SubjQA-master/SubjQA/{self.config.name}/splits/dev.csv")
124
+ },
125
+ ),
126
+ ]
127
+
128
+ def _generate_examples(self, filepath):
129
+ df = pd.read_csv(filepath)
130
+ squad_format = self._convert_to_squad(df)
131
+ for example in squad_format["data"]:
132
+ title = example.get("title", "").strip()
133
+ for paragraph in example["paragraphs"]:
134
+ context = paragraph["context"].strip()
135
+ for qa in paragraph["qas"]:
136
+ question = qa["question"].strip()
137
+ question_meta = {k: v for k, v in qa.items() if k in self.question_meta_columns}
138
+ id_ = qa["id"]
139
+ answer_starts = [answer["answer_start"] for answer in qa["answers"]]
140
+ answers = [answer["text"].strip() for answer in qa["answers"]]
141
+ answer_meta = pd.DataFrame(qa["answers"], columns=self.answer_meta_columns).to_dict("list")
142
+ yield id_, {
143
+ **{
144
+ "title": title,
145
+ "context": context,
146
+ "question": question,
147
+ "id": id_,
148
+ "answers": {
149
+ **{
150
+ "answer_start": answer_starts,
151
+ "text": answers,
152
+ },
153
+ **answer_meta,
154
+ },
155
+ },
156
+ **question_meta,
157
+ }
158
+
159
+ def _create_paragraphs(self, df):
160
+ "A helper function to convert a pandas.DataFrame of (question, context, answer) rows to SQuAD paragraphs."
161
+ self.question_meta_columns = [
162
+ "domain",
163
+ "nn_mod",
164
+ "nn_asp",
165
+ "query_mod",
166
+ "query_asp",
167
+ "q_reviews_id",
168
+ "question_subj_level",
169
+ "ques_subj_score",
170
+ "is_ques_subjective",
171
+ "review_id",
172
+ ]
173
+ self.answer_meta_columns = ["answer_subj_level", "ans_subj_score", "is_ans_subjective"]
174
+ id2review = dict(zip(df["review_id"], df["review"]))
175
+ pars = []
176
+ for review_id, review in id2review.items():
177
+ qas = []
178
+ review_df = df.query(f"review_id == '{review_id}'")
179
+ id2question = dict(zip(review_df["q_review_id"], review_df["question"]))
180
+
181
+ for k, v in id2question.items():
182
+ d = df.query(f"q_review_id == '{k}'").to_dict(orient="list")
183
+ answer_starts = [ast.literal_eval(a)[0] for a in d["human_ans_indices"]]
184
+ answer_meta = {k: v[0] for k, v in d.items() if k in self.answer_meta_columns}
185
+ question_meta = {k: v[0] for k, v in d.items() if k in self.question_meta_columns}
186
+ # Only fill answerable questions
187
+ if pd.unique(d["human_ans_spans"])[0] != "ANSWERNOTFOUND":
188
+ answers = [
189
+ {**{"text": text, "answer_start": answer_start}, **answer_meta}
190
+ for text, answer_start in zip(d["human_ans_spans"], answer_starts)
191
+ if text != "ANSWERNOTFOUND"
192
+ ]
193
+ else:
194
+ answers = []
195
+ qas.append({**{"question": v, "id": k, "answers": answers}, **question_meta})
196
+ # Slice off ANSWERNOTFOUND from context
197
+ pars.append({"qas": qas, "context": review[: -len(" ANSWERNOTFOUND")]})
198
+ return pars
199
+
200
+ def _convert_to_squad(self, df):
201
+ "A helper function to convert a pandas.DataFrame of product-based QA dataset into SQuAD format"
202
+ groups = (
203
+ df.groupby("item_id")
204
+ .apply(self._create_paragraphs)
205
+ .to_frame(name="paragraphs")
206
+ .reset_index()
207
+ .rename(columns={"item_id": "title"})
208
+ )
209
+ squad_data = {}
210
+ squad_data["data"] = groups.to_dict(orient="records")
211
+ return squad_data