albertvillanova HF staff commited on
Commit
f3f9b0d
1 Parent(s): 06f9b3f

Delete loading script

Browse files
Files changed (1) hide show
  1. indic_glue.py +0 -979
indic_glue.py DELETED
@@ -1,979 +0,0 @@
1
- """The IndicGLUE benchmark."""
2
-
3
-
4
- import csv
5
- import json
6
- import textwrap
7
-
8
- import pandas as pd
9
-
10
- import datasets
11
-
12
-
13
- _INDIC_GLUE_CITATION = """\
14
- @inproceedings{kakwani2020indicnlpsuite,
15
- title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Language Models for Indian Languages}},
16
- author={Divyanshu Kakwani and Anoop Kunchukuttan and Satish Golla and Gokul N.C. and Avik Bhattacharyya and Mitesh M. Khapra and Pratyush Kumar},
17
- year={2020},
18
- booktitle={Findings of EMNLP},
19
- }
20
- """
21
-
22
- _INDIC_GLUE_DESCRIPTION = """\
23
- IndicGLUE is a natural language understanding benchmark for Indian languages. It contains a wide
24
- variety of tasks and covers 11 major Indian languages - as, bn, gu, hi, kn, ml, mr, or, pa, ta, te.
25
- """
26
-
27
- _DESCRIPTIONS = {
28
- "wnli": textwrap.dedent(
29
- """
30
- The Winograd Schema Challenge (Levesque et al., 2011) is a reading comprehension task
31
- in which a system must read a sentence with a pronoun and select the referent of that pronoun from
32
- a list of choices. The examples are manually constructed to foil simple statistical methods: Each
33
- one is contingent on contextual information provided by a single word or phrase in the sentence.
34
- To convert the problem into sentence pair classification, we construct sentence pairs by replacing
35
- the ambiguous pronoun with each possible referent. The task is to predict if the sentence with the
36
- pronoun substituted is entailed by the original sentence. We use a small evaluation set consisting of
37
- new examples derived from fiction books that was shared privately by the authors of the original
38
- corpus. While the included training set is balanced between two classes, the test set is imbalanced
39
- between them (65% not entailment). Also, due to a data quirk, the development set is adversarial:
40
- hypotheses are sometimes shared between training and development examples, so if a model memorizes the
41
- training examples, they will predict the wrong label on corresponding development set
42
- example. As with QNLI, each example is evaluated separately, so there is not a systematic correspondence
43
- between a model's score on this task and its score on the unconverted original task. We
44
- call converted dataset WNLI (Winograd NLI). This dataset is translated and publicly released for 3
45
- Indian languages by AI4Bharat.
46
- """
47
- ),
48
- "copa": textwrap.dedent(
49
- """
50
- The Choice Of Plausible Alternatives (COPA) evaluation provides researchers with a tool for assessing
51
- progress in open-domain commonsense causal reasoning. COPA consists of 1000 questions, split equally
52
- into development and test sets of 500 questions each. Each question is composed of a premise and two
53
- alternatives, where the task is to select the alternative that more plausibly has a causal relation
54
- with the premise. The correct alternative is randomized so that the expected performance of randomly
55
- guessing is 50%. This dataset is translated and publicly released for 3 languages by AI4Bharat.
56
- """
57
- ),
58
- "sna": textwrap.dedent(
59
- """
60
- This dataset is a collection of Bengali News articles. The dataset is used for classifying articles into
61
- 6 different classes namely national, international, state, kolkata, entertainment and sports.
62
- """
63
- ),
64
- "csqa": textwrap.dedent(
65
- """
66
- Given a text with an entity randomly masked, the task is to predict that masked entity from a list of 4
67
- candidate entities. The dataset contains around 239k examples across 11 languages.
68
- """
69
- ),
70
- "wstp": textwrap.dedent(
71
- """
72
- Predict the correct title for a Wikipedia section from a given list of four candidate titles.
73
- The dataset has 400k examples across 11 Indian languages.
74
- """
75
- ),
76
- "inltkh": textwrap.dedent(
77
- """
78
- Obtained from inltk project. The corpus is a collection of headlines tagged with their news category.
79
- Available for langauges: gu, ml, mr and ta.
80
- """
81
- ),
82
- "bbca": textwrap.dedent(
83
- """
84
- This release consists of 4335 Hindi documents with tags from the BBC Hindi News website.
85
- """
86
- ),
87
- "cvit-mkb-clsr": textwrap.dedent(
88
- """
89
- CVIT Maan ki Baat Dataset - Given a sentence in language $L_1$ the task is to retrieve its translation
90
- from a set of candidate sentences in language $L_2$.
91
- The dataset contains around 39k parallel sentence pairs across 8 Indian languages.
92
- """
93
- ),
94
- "iitp-mr": textwrap.dedent(
95
- """
96
- IIT Patna Product Reviews: Sentiment analysis corpus for product reviews posted in Hindi.
97
- """
98
- ),
99
- "iitp-pr": textwrap.dedent(
100
- """
101
- IIT Patna Product Reviews: Sentiment analysis corpus for product reviews posted in Hindi.
102
- """
103
- ),
104
- "actsa-sc": textwrap.dedent(
105
- """
106
- ACTSA Corpus: Sentiment analysis corpus for Telugu sentences.
107
- """
108
- ),
109
- "md": textwrap.dedent(
110
- """
111
- The Hindi Discourse Analysis dataset is a corpus for analyzing discourse modes present in its sentences.
112
- It contains sentences from stories written by 11 famous authors from the 20th Century. 4-5 stories by
113
- each author have been selected which were available in the public domain resulting in a collection of 53 stories.
114
- Most of these short stories were originally written in Hindi but some of them were written in other Indian languages
115
- and later translated to Hindi.
116
- """
117
- ),
118
- "wiki-ner": textwrap.dedent(
119
- """
120
- The WikiANN dataset (Pan et al. 2017) is a dataset with NER annotations for PER, ORG and LOC. It has been constructed using
121
- the linked entities in Wikipedia pages for 282 different languages including Danish.
122
- """
123
- ),
124
- }
125
-
126
- _CITATIONS = {
127
- "wnli": textwrap.dedent(
128
- """
129
- @inproceedings{kakwani2020indicnlpsuite,
130
- title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Language Models for Indian Languages}},
131
- author={Divyanshu Kakwani and Anoop Kunchukuttan and Satish Golla and Gokul N.C. and Avik Bhattacharyya and Mitesh M. Khapra and Pratyush Kumar},
132
- year={2020},
133
- booktitle={Findings of EMNLP},
134
- }
135
- @inproceedings{Levesque2011TheWS,
136
- title={The Winograd Schema Challenge},
137
- author={H. Levesque and E. Davis and L. Morgenstern},
138
- booktitle={KR},
139
- year={2011}
140
- }
141
- """
142
- ),
143
- "copa": textwrap.dedent(
144
- """
145
- @inproceedings{kakwani2020indicnlpsuite,
146
- title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Language Models for Indian Languages}},
147
- author={Divyanshu Kakwani and Anoop Kunchukuttan and Satish Golla and Gokul N.C. and Avik Bhattacharyya and Mitesh M. Khapra and Pratyush Kumar},
148
- year={2020},
149
- booktitle={Findings of EMNLP},
150
- }
151
- @inproceedings{Gordon2011SemEval2012T7,
152
- title={SemEval-2012 Task 7: Choice of Plausible Alternatives: An Evaluation of Commonsense Causal Reasoning},
153
- author={Andrew S. Gordon and Zornitsa Kozareva and Melissa Roemmele},
154
- booktitle={SemEval@NAACL-HLT},
155
- year={2011}
156
- }
157
- """
158
- ),
159
- "sna": textwrap.dedent(
160
- """
161
- https://www.kaggle.com/csoham/classification-bengali-news-articles-indicnlp
162
- """
163
- ),
164
- "csqa": textwrap.dedent(
165
- """
166
- @inproceedings{kakwani2020indicnlpsuite,
167
- title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Language Models for Indian Languages}},
168
- author={Divyanshu Kakwani and Anoop Kunchukuttan and Satish Golla and Gokul N.C. and Avik Bhattacharyya and Mitesh M. Khapra and Pratyush Kumar},
169
- year={2020},
170
- booktitle={Findings of EMNLP},
171
- }
172
- """
173
- ),
174
- "wstp": textwrap.dedent(
175
- """
176
- @inproceedings{kakwani2020indicnlpsuite,
177
- title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Language Models for Indian Languages}},
178
- author={Divyanshu Kakwani and Anoop Kunchukuttan and Satish Golla and Gokul N.C. and Avik Bhattacharyya and Mitesh M. Khapra and Pratyush Kumar},
179
- year={2020},
180
- booktitle={Findings of EMNLP},
181
- }
182
- """
183
- ),
184
- "inltkh": textwrap.dedent(
185
- """
186
- https://github.com/goru001/inltk
187
- """
188
- ),
189
- "bbca": textwrap.dedent(
190
- """
191
- https://github.com/NirantK/hindi2vec/releases/tag/bbc-hindi-v0.1
192
- """
193
- ),
194
- "cvit-mkb-clsr": textwrap.dedent(
195
- """
196
- @inproceedings{siripragada-etal-2020-multilingual,
197
- title = "A Multilingual Parallel Corpora Collection Effort for {I}ndian Languages",
198
- author = "Siripragada, Shashank and
199
- Philip, Jerin and
200
- Namboodiri, Vinay P. and
201
- Jawahar, C V",
202
- booktitle = "Proceedings of the 12th Language Resources and Evaluation Conference",
203
- month = may,
204
- year = "2020",
205
- address = "Marseille, France",
206
- publisher = "European Language Resources Association",
207
- url = "https://www.aclweb.org/anthology/2020.lrec-1.462",
208
- pages = "3743--3751",
209
- abstract = "We present sentence aligned parallel corpora across 10 Indian Languages - Hindi, Telugu, Tamil, Malayalam, Gujarati, Urdu, Bengali, Oriya, Marathi, Punjabi, and English - many of which are categorized as low resource. The corpora are compiled from online sources which have content shared across languages. The corpora presented significantly extends present resources that are either not large enough or are restricted to a specific domain (such as health). We also provide a separate test corpus compiled from an independent online source that can be independently used for validating the performance in 10 Indian languages. Alongside, we report on the methods of constructing such corpora using tools enabled by recent advances in machine translation and cross-lingual retrieval using deep neural network based methods.",
210
- language = "English",
211
- ISBN = "979-10-95546-34-4",
212
- }
213
- """
214
- ),
215
- "iitp-mr": textwrap.dedent(
216
- """
217
- @inproceedings{akhtar-etal-2016-hybrid,
218
- title = "A Hybrid Deep Learning Architecture for Sentiment Analysis",
219
- author = "Akhtar, Md Shad and
220
- Kumar, Ayush and
221
- Ekbal, Asif and
222
- Bhattacharyya, Pushpak",
223
- booktitle = "Proceedings of {COLING} 2016, the 26th International Conference on Computational Linguistics: Technical Papers",
224
- month = dec,
225
- year = "2016",
226
- address = "Osaka, Japan",
227
- publisher = "The COLING 2016 Organizing Committee",
228
- url = "https://www.aclweb.org/anthology/C16-1047",
229
- pages = "482--493",
230
- abstract = "In this paper, we propose a novel hybrid deep learning archtecture which is highly efficient for sentiment analysis in resource-poor languages. We learn sentiment embedded vectors from the Convolutional Neural Network (CNN). These are augmented to a set of optimized features selected through a multi-objective optimization (MOO) framework. The sentiment augmented optimized vector obtained at the end is used for the training of SVM for sentiment classification. We evaluate our proposed approach for coarse-grained (i.e. sentence level) as well as fine-grained (i.e. aspect level) sentiment analysis on four Hindi datasets covering varying domains. In order to show that our proposed method is generic in nature we also evaluate it on two benchmark English datasets. Evaluation shows that the results of the proposed method are consistent across all the datasets and often outperforms the state-of-art systems. To the best of our knowledge, this is the very first attempt where such a deep learning model is used for less-resourced languages such as Hindi.",
231
- }
232
- """
233
- ),
234
- "iitp-pr": textwrap.dedent(
235
- """
236
- @inproceedings{akhtar-etal-2016-hybrid,
237
- title = "A Hybrid Deep Learning Architecture for Sentiment Analysis",
238
- author = "Akhtar, Md Shad and
239
- Kumar, Ayush and
240
- Ekbal, Asif and
241
- Bhattacharyya, Pushpak",
242
- booktitle = "Proceedings of {COLING} 2016, the 26th International Conference on Computational Linguistics: Technical Papers",
243
- month = dec,
244
- year = "2016",
245
- address = "Osaka, Japan",
246
- publisher = "The COLING 2016 Organizing Committee",
247
- url = "https://www.aclweb.org/anthology/C16-1047",
248
- pages = "482--493",
249
- abstract = "In this paper, we propose a novel hybrid deep learning archtecture which is highly efficient for sentiment analysis in resource-poor languages. We learn sentiment embedded vectors from the Convolutional Neural Network (CNN). These are augmented to a set of optimized features selected through a multi-objective optimization (MOO) framework. The sentiment augmented optimized vector obtained at the end is used for the training of SVM for sentiment classification. We evaluate our proposed approach for coarse-grained (i.e. sentence level) as well as fine-grained (i.e. aspect level) sentiment analysis on four Hindi datasets covering varying domains. In order to show that our proposed method is generic in nature we also evaluate it on two benchmark English datasets. Evaluation shows that the results of the proposed method are consistent across all the datasets and often outperforms the state-of-art systems. To the best of our knowledge, this is the very first attempt where such a deep learning model is used for less-resourced languages such as Hindi.",
250
- }
251
- """
252
- ),
253
- "actsa-sc": textwrap.dedent(
254
- """
255
- @inproceedings{mukku-mamidi-2017-actsa,
256
- title = "{ACTSA}: Annotated Corpus for {T}elugu Sentiment Analysis",
257
- author = "Mukku, Sandeep Sricharan and
258
- Mamidi, Radhika",
259
- booktitle = "Proceedings of the First Workshop on Building Linguistically Generalizable {NLP} Systems",
260
- month = sep,
261
- year = "2017",
262
- address = "Copenhagen, Denmark",
263
- publisher = "Association for Computational Linguistics",
264
- url = "https://www.aclweb.org/anthology/W17-5408",
265
- doi = "10.18653/v1/W17-5408",
266
- pages = "54--58",
267
- abstract = "Sentiment analysis deals with the task of determining the polarity of a document or sentence and has received a lot of attention in recent years for the English language. With the rapid growth of social media these days, a lot of data is available in regional languages besides English. Telugu is one such regional language with abundant data available in social media, but it{'}s hard to find a labelled data of sentences for Telugu Sentiment Analysis. In this paper, we describe an effort to build a gold-standard annotated corpus of Telugu sentences to support Telugu Sentiment Analysis. The corpus, named ACTSA (Annotated Corpus for Telugu Sentiment Analysis) has a collection of Telugu sentences taken from different sources which were then pre-processed and manually annotated by native Telugu speakers using our annotation guidelines. In total, we have annotated 5457 sentences, which makes our corpus the largest resource currently available. The corpus and the annotation guidelines are made publicly available.",
268
- }
269
- """
270
- ),
271
- "md": textwrap.dedent(
272
- """
273
- @inproceedings{Dhanwal2020AnAD,
274
- title={An Annotated Dataset of Discourse Modes in Hindi Stories},
275
- author={Swapnil Dhanwal and Hritwik Dutta and Hitesh Nankani and Nilay Shrivastava and Y. Kumar and Junyi Jessy Li and Debanjan Mahata and Rakesh Gosangi and Haimin Zhang and R. R. Shah and Amanda Stent},
276
- booktitle={LREC},
277
- year={2020}
278
- }
279
- """
280
- ),
281
- "wiki-ner": textwrap.dedent(
282
- """
283
- @inproceedings{pan-etal-2017-cross,
284
- title = "Cross-lingual Name Tagging and Linking for 282 Languages",
285
- author = "Pan, Xiaoman and
286
- Zhang, Boliang and
287
- May, Jonathan and
288
- Nothman, Joel and
289
- Knight, Kevin and
290
- Ji, Heng",
291
- booktitle = "Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
292
- month = jul,
293
- year = "2017",
294
- address = "Vancouver, Canada",
295
- publisher = "Association for Computational Linguistics",
296
- url = "https://www.aclweb.org/anthology/P17-1178",
297
- doi = "10.18653/v1/P17-1178",
298
- pages = "1946--1958",
299
- abstract = "The ambitious goal of this work is to develop a cross-lingual name tagging and linking framework for 282 languages that exist in Wikipedia. Given a document in any of these languages, our framework is able to identify name mentions, assign a coarse-grained or fine-grained type to each mention, and link it to an English Knowledge Base (KB) if it is linkable. We achieve this goal by performing a series of new KB mining methods: generating {``}silver-standard{''} annotations by transferring annotations from English to other languages through cross-lingual links and KB properties, refining annotations through self-training and topic selection, deriving language-specific morphology features from anchor links, and mining word translation pairs from cross-lingual links. Both name tagging and linking results for 282 languages are promising on Wikipedia data and on-Wikipedia data.",
300
- }
301
- """
302
- ),
303
- }
304
-
305
- _TEXT_FEATURES = {
306
- "wnli": {"hypothesis": "sentence1", "premise": "sentence2"},
307
- "copa": {"premise": "premise", "choice1": "choice1", "choice2": "choice2", "question": "question"},
308
- "sna": {"text": "text"},
309
- "csqa": {"question": "question", "answer": "answer", "category": "category", "title": "title"},
310
- "wstp": {
311
- "sectionText": "sectionText",
312
- "correctTitle": "correctTitle",
313
- "titleA": "titleA",
314
- "titleB": "titleB",
315
- "titleC": "titleC",
316
- "titleD": "titleD",
317
- "url": "url",
318
- },
319
- "inltkh": {"text": "text"},
320
- "bbca": {"label": "label", "text": "text"},
321
- "cvit-mkb-clsr": {"sentence1": "sentence1", "sentence2": "sentence2"},
322
- "iitp-mr": {"text": "text"},
323
- "iitp-pr": {"text": "text"},
324
- "actsa-sc": {"text": "text"},
325
- "md": {"sentence": "sentence", "discourse_mode": "discourse_mode"},
326
- "wiki-ner": {},
327
- }
328
-
329
- _DATA_URLS = {
330
- "wnli": "data/wnli-translated.zip",
331
- "copa": "data/copa-translated.zip",
332
- "sna": "data/soham-articles.zip",
333
- "csqa": "data/wiki-cloze.zip",
334
- "wstp": "data/wiki-section-titles.zip",
335
- "inltkh": "data/inltk-headlines.zip",
336
- "bbca": "data/bbc-articles.zip",
337
- "cvit-mkb-clsr": "data/cvit-mkb.zip",
338
- "iitp-mr": "data/iitp-movie-reviews.zip",
339
- "iitp-pr": "data/iitp-product-reviews.zip",
340
- "actsa-sc": "data/actsa.zip",
341
- "md": "data/midas-discourse.zip",
342
- "wiki-ner": "data/wikiann-ner.zip",
343
- }
344
-
345
- _URLS = {
346
- "wnli": "https://ai4bharat.iitm.ac.in/indic-glue",
347
- "copa": "https://ai4bharat.iitm.ac.in/indic-glue",
348
- "sna": "https://ai4bharat.iitm.ac.in/indic-glue",
349
- "csqa": "https://ai4bharat.iitm.ac.in/indic-glue",
350
- "wstp": "https://ai4bharat.iitm.ac.in/indic-glue",
351
- "inltkh": "https://ai4bharat.iitm.ac.in/indic-glue",
352
- "bbca": "https://ai4bharat.iitm.ac.in/indic-glue",
353
- "cvit-mkb-clsr": "https://ai4bharat.iitm.ac.in/indic-glue",
354
- "iitp-mr": "https://ai4bharat.iitm.ac.in/indic-glue",
355
- "iitp-pr": "https://ai4bharat.iitm.ac.in/indic-glue",
356
- "actsa-sc": "https://ai4bharat.iitm.ac.in/indic-glue",
357
- "md": "https://ai4bharat.iitm.ac.in/indic-glue",
358
- "wiki-ner": "https://ai4bharat.iitm.ac.in/indic-glue",
359
- }
360
-
361
- _INDIC_GLUE_URL = "https://ai4bharat.iitm.ac.in/indic-glue"
362
-
363
- _WNLI_LANGS = ["en", "hi", "gu", "mr"]
364
- _COPA_LANGS = ["en", "hi", "gu", "mr"]
365
- _SNA_LANGS = ["bn"]
366
- _CSQA_LANGS = ["as", "bn", "gu", "hi", "kn", "ml", "mr", "or", "pa", "ta", "te"]
367
- _WSTP_LANGS = ["as", "bn", "gu", "hi", "kn", "ml", "mr", "or", "pa", "ta", "te"]
368
- _iNLTKH_LANGS = ["gu", "ml", "mr", "ta", "te"]
369
- _BBCA_LANGS = ["hi"]
370
- _CVIT_MKB_CLSR = ["en-bn", "en-gu", "en-hi", "en-ml", "en-mr", "en-or", "en-ta", "en-te", "en-ur"]
371
- _IITP_MR_LANGS = ["hi"]
372
- _IITP_PR_LANGS = ["hi"]
373
- _ACTSA_LANGS = ["te"]
374
- _MD_LANGS = ["hi"]
375
- _WIKI_NER_LANGS = ["as", "bn", "gu", "hi", "kn", "ml", "mr", "or", "pa", "ta", "te"]
376
-
377
- _NAMES = []
378
-
379
- for lang in _WNLI_LANGS:
380
- _NAMES.append(f"wnli.{lang}")
381
-
382
- for lang in _COPA_LANGS:
383
- _NAMES.append(f"copa.{lang}")
384
-
385
- for lang in _SNA_LANGS:
386
- _NAMES.append(f"sna.{lang}")
387
-
388
- for lang in _CSQA_LANGS:
389
- _NAMES.append(f"csqa.{lang}")
390
-
391
- for lang in _WSTP_LANGS:
392
- _NAMES.append(f"wstp.{lang}")
393
-
394
- for lang in _iNLTKH_LANGS:
395
- _NAMES.append(f"inltkh.{lang}")
396
-
397
- for lang in _BBCA_LANGS:
398
- _NAMES.append(f"bbca.{lang}")
399
-
400
- for lang in _CVIT_MKB_CLSR:
401
- _NAMES.append(f"cvit-mkb-clsr.{lang}")
402
-
403
- for lang in _IITP_MR_LANGS:
404
- _NAMES.append(f"iitp-mr.{lang}")
405
-
406
- for lang in _IITP_PR_LANGS:
407
- _NAMES.append(f"iitp-pr.{lang}")
408
-
409
- for lang in _ACTSA_LANGS:
410
- _NAMES.append(f"actsa-sc.{lang}")
411
-
412
- for lang in _MD_LANGS:
413
- _NAMES.append(f"md.{lang}")
414
-
415
- for lang in _WIKI_NER_LANGS:
416
- _NAMES.append(f"wiki-ner.{lang}")
417
-
418
-
419
- class IndicGlueConfig(datasets.BuilderConfig):
420
- """BuilderConfig for IndicGLUE."""
421
-
422
- def __init__(self, data_url, citation, url, text_features, **kwargs):
423
- """
424
- Args:
425
-
426
- data_url: `string`, url to download the zip file from.
427
- citation: `string`, citation for the data set.
428
- url: `string`, url for information about the data set.
429
- text_features: `dict[string, string]`, map from the name of the feature
430
- dict for each text field to the name of the column in the csv/json file
431
- **kwargs: keyword arguments forwarded to super.
432
- """
433
- super(IndicGlueConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
434
- self.data_url = data_url
435
- self.citation = citation
436
- self.url = url
437
- self.text_features = text_features
438
-
439
-
440
- class IndicGlue(datasets.GeneratorBasedBuilder):
441
-
442
- BUILDER_CONFIGS = [
443
- IndicGlueConfig(
444
- name=name,
445
- description=_DESCRIPTIONS[name.split(".")[0]],
446
- text_features=_TEXT_FEATURES[name.split(".")[0]],
447
- data_url=_DATA_URLS[name.split(".")[0]],
448
- citation=_CITATIONS[name.split(".")[0]],
449
- url=_URLS[name.split(".")[0]],
450
- )
451
- for name in _NAMES
452
- ]
453
-
454
- def _info(self):
455
- features = {text_feature: datasets.Value("string") for text_feature in self.config.text_features.keys()}
456
-
457
- if self.config.name.startswith("copa"):
458
- features["label"] = datasets.Value("int32")
459
-
460
- if self.config.name.startswith("sna"):
461
- features["label"] = datasets.features.ClassLabel(
462
- names=["kolkata", "state", "national", "sports", "entertainment", "international"]
463
- )
464
-
465
- if self.config.name.startswith("inltkh"):
466
- features["label"] = datasets.features.ClassLabel(
467
- names=[
468
- "entertainment",
469
- "business",
470
- "tech",
471
- "sports",
472
- "state",
473
- "spirituality",
474
- "tamil-cinema",
475
- "positive",
476
- "negative",
477
- "neutral",
478
- ]
479
- )
480
-
481
- if self.config.name.startswith("iitp"):
482
- features["label"] = datasets.features.ClassLabel(names=["negative", "neutral", "positive"])
483
-
484
- if self.config.name.startswith("wnli"):
485
- features["label"] = datasets.features.ClassLabel(names=["not_entailment", "entailment", "None"])
486
-
487
- if self.config.name.startswith("actsa"):
488
- features["label"] = datasets.features.ClassLabel(names=["positive", "negative"])
489
-
490
- if self.config.name.startswith("csqa"):
491
- features["options"] = datasets.features.Sequence(datasets.Value("string"))
492
- features["out_of_context_options"] = datasets.features.Sequence(datasets.Value("string"))
493
-
494
- if self.config.name.startswith("md"):
495
- features["story_number"] = datasets.Value("int32")
496
- features["id"] = datasets.Value("int32")
497
-
498
- if self.config.name.startswith("wiki-ner"):
499
- features["tokens"] = datasets.features.Sequence(datasets.Value("string"))
500
- features["ner_tags"] = datasets.features.Sequence(
501
- datasets.features.ClassLabel(names=["B-LOC", "B-ORG", "B-PER", "I-LOC", "I-ORG", "I-PER", "O"])
502
- )
503
- features["additional_info"] = datasets.features.Sequence(
504
- datasets.features.Sequence(datasets.Value("string"))
505
- )
506
-
507
- return datasets.DatasetInfo(
508
- description=_INDIC_GLUE_DESCRIPTION + "\n" + self.config.description,
509
- features=datasets.Features(features),
510
- homepage=self.config.url,
511
- citation=_INDIC_GLUE_CITATION + "\n" + self.config.citation,
512
- )
513
-
514
- def _split_generators(self, dl_manager):
515
-
516
- if self.config.name.startswith("wnli"):
517
- archive = dl_manager.download(self.config.data_url)
518
- task_name = self._get_task_name_from_data_url(self.config.data_url)
519
- dl_dir = task_name + "/" + self.config.name.split(".")[1]
520
- return [
521
- datasets.SplitGenerator(
522
- name=datasets.Split.TRAIN,
523
- gen_kwargs={
524
- "datafile": dl_dir + "/" + "train.csv",
525
- "split": datasets.Split.TRAIN,
526
- "key": "train-split",
527
- "files": dl_manager.iter_archive(archive),
528
- },
529
- ),
530
- datasets.SplitGenerator(
531
- name=datasets.Split.VALIDATION,
532
- gen_kwargs={
533
- "datafile": dl_dir + "/" + "dev.csv",
534
- "split": datasets.Split.VALIDATION,
535
- "key": "val-split",
536
- "files": dl_manager.iter_archive(archive),
537
- },
538
- ),
539
- datasets.SplitGenerator(
540
- name=datasets.Split.TEST,
541
- gen_kwargs={
542
- "datafile": dl_dir + "/" + "test.csv",
543
- "split": datasets.Split.TEST,
544
- "key": "test-split",
545
- "files": dl_manager.iter_archive(archive),
546
- },
547
- ),
548
- ]
549
-
550
- if self.config.name.startswith("copa"):
551
- archive = dl_manager.download(self.config.data_url)
552
- task_name = self._get_task_name_from_data_url(self.config.data_url)
553
- dl_dir = task_name + "/" + self.config.name.split(".")[1]
554
-
555
- return [
556
- datasets.SplitGenerator(
557
- name=datasets.Split.TRAIN,
558
- gen_kwargs={
559
- "datafile": dl_dir + "/" + "train.jsonl",
560
- "split": datasets.Split.TRAIN,
561
- "key": "train-split",
562
- "files": dl_manager.iter_archive(archive),
563
- },
564
- ),
565
- datasets.SplitGenerator(
566
- name=datasets.Split.VALIDATION,
567
- gen_kwargs={
568
- "datafile": dl_dir + "/" + "val.jsonl",
569
- "split": datasets.Split.VALIDATION,
570
- "key": "val-split",
571
- "files": dl_manager.iter_archive(archive),
572
- },
573
- ),
574
- datasets.SplitGenerator(
575
- name=datasets.Split.TEST,
576
- gen_kwargs={
577
- "datafile": dl_dir + "/" + "test.jsonl",
578
- "split": datasets.Split.TEST,
579
- "key": "test-split",
580
- "files": dl_manager.iter_archive(archive),
581
- },
582
- ),
583
- ]
584
-
585
- if self.config.name.startswith("sna"):
586
- archive = dl_manager.download(self.config.data_url)
587
- task_name = self._get_task_name_from_data_url(self.config.data_url)
588
- dl_dir = task_name + "/" + self.config.name.split(".")[1]
589
-
590
- return [
591
- datasets.SplitGenerator(
592
- name=datasets.Split.TRAIN,
593
- gen_kwargs={
594
- "datafile": dl_dir + "/" + "bn-train.csv",
595
- "split": datasets.Split.TRAIN,
596
- "files": dl_manager.iter_archive(archive),
597
- },
598
- ),
599
- datasets.SplitGenerator(
600
- name=datasets.Split.VALIDATION,
601
- gen_kwargs={
602
- "datafile": dl_dir + "/" + "bn-valid.csv",
603
- "split": datasets.Split.VALIDATION,
604
- "files": dl_manager.iter_archive(archive),
605
- },
606
- ),
607
- datasets.SplitGenerator(
608
- name=datasets.Split.TEST,
609
- gen_kwargs={
610
- "datafile": dl_dir + "/" + "bn-test.csv",
611
- "split": datasets.Split.TEST,
612
- "files": dl_manager.iter_archive(archive),
613
- },
614
- ),
615
- ]
616
-
617
- if self.config.name.startswith("csqa"):
618
- archive = dl_manager.download(self.config.data_url)
619
- task_name = self._get_task_name_from_data_url(self.config.data_url)
620
- dl_dir = task_name
621
-
622
- return [
623
- datasets.SplitGenerator(
624
- name=datasets.Split.TEST,
625
- gen_kwargs={
626
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}.json",
627
- "split": datasets.Split.TEST,
628
- "files": dl_manager.iter_archive(archive),
629
- },
630
- )
631
- ]
632
-
633
- if self.config.name.startswith("wstp"):
634
- archive = dl_manager.download(self.config.data_url)
635
- task_name = self._get_task_name_from_data_url(self.config.data_url)
636
- dl_dir = task_name + "/" + self.config.name.split(".")[1]
637
-
638
- return [
639
- datasets.SplitGenerator(
640
- name=datasets.Split.TRAIN,
641
- gen_kwargs={
642
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-train.json",
643
- "split": datasets.Split.TRAIN,
644
- "files": dl_manager.iter_archive(archive),
645
- },
646
- ),
647
- datasets.SplitGenerator(
648
- name=datasets.Split.VALIDATION,
649
- gen_kwargs={
650
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-valid.json",
651
- "split": datasets.Split.VALIDATION,
652
- "files": dl_manager.iter_archive(archive),
653
- },
654
- ),
655
- datasets.SplitGenerator(
656
- name=datasets.Split.TEST,
657
- gen_kwargs={
658
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-test.json",
659
- "split": datasets.Split.TEST,
660
- "files": dl_manager.iter_archive(archive),
661
- },
662
- ),
663
- ]
664
-
665
- if (
666
- self.config.name.startswith("inltkh")
667
- or self.config.name.startswith("iitp")
668
- or self.config.name.startswith("actsa")
669
- ):
670
- archive = dl_manager.download(self.config.data_url)
671
- task_name = self._get_task_name_from_data_url(self.config.data_url)
672
- dl_dir = task_name + "/" + self.config.name.split(".")[1]
673
-
674
- return [
675
- datasets.SplitGenerator(
676
- name=datasets.Split.TRAIN,
677
- gen_kwargs={
678
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-train.csv",
679
- "split": datasets.Split.TRAIN,
680
- "files": dl_manager.iter_archive(archive),
681
- },
682
- ),
683
- datasets.SplitGenerator(
684
- name=datasets.Split.VALIDATION,
685
- gen_kwargs={
686
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-valid.csv",
687
- "split": datasets.Split.VALIDATION,
688
- "files": dl_manager.iter_archive(archive),
689
- },
690
- ),
691
- datasets.SplitGenerator(
692
- name=datasets.Split.TEST,
693
- gen_kwargs={
694
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-test.csv",
695
- "split": datasets.Split.TEST,
696
- "files": dl_manager.iter_archive(archive),
697
- },
698
- ),
699
- ]
700
-
701
- if self.config.name.startswith("bbca"):
702
- archive = dl_manager.download(self.config.data_url)
703
- task_name = self._get_task_name_from_data_url(self.config.data_url)
704
- dl_dir = task_name + "/" + self.config.name.split(".")[1]
705
-
706
- return [
707
- datasets.SplitGenerator(
708
- name=datasets.Split.TRAIN,
709
- gen_kwargs={
710
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-train.csv",
711
- "split": datasets.Split.TRAIN,
712
- "files": dl_manager.iter_archive(archive),
713
- },
714
- ),
715
- datasets.SplitGenerator(
716
- name=datasets.Split.TEST,
717
- gen_kwargs={
718
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-test.csv",
719
- "split": datasets.Split.TEST,
720
- "files": dl_manager.iter_archive(archive),
721
- },
722
- ),
723
- ]
724
-
725
- if self.config.name.startswith("cvit"):
726
- archive = dl_manager.download(self.config.data_url)
727
- task_name = self._get_task_name_from_data_url(self.config.data_url)
728
- dl_dir = task_name + "/" + self.config.name.split(".")[1]
729
-
730
- return [
731
- datasets.SplitGenerator(
732
- name=datasets.Split.TEST,
733
- gen_kwargs={
734
- "datafile": None,
735
- "src": dl_dir + "/" + f"mkb.{self.config.name.split('.')[1].split('-')[0]}",
736
- "tgt": dl_dir + "/" + f"mkb.{self.config.name.split('.')[1].split('-')[1]}",
737
- "split": datasets.Split.TEST,
738
- "files": dl_manager.iter_archive(archive),
739
- },
740
- )
741
- ]
742
-
743
- if self.config.name.startswith("md"):
744
- archive = dl_manager.download(self.config.data_url)
745
- task_name = self._get_task_name_from_data_url(self.config.data_url)
746
- dl_dir = task_name + "/" + self.config.name.split(".")[1]
747
-
748
- return [
749
- datasets.SplitGenerator(
750
- name=datasets.Split.TRAIN,
751
- gen_kwargs={
752
- "datafile": dl_dir + "/" + "train.json",
753
- "split": datasets.Split.TRAIN,
754
- "files": dl_manager.iter_archive(archive),
755
- },
756
- ),
757
- datasets.SplitGenerator(
758
- name=datasets.Split.VALIDATION,
759
- gen_kwargs={
760
- "datafile": dl_dir + "/" + "val.json",
761
- "split": datasets.Split.VALIDATION,
762
- "files": dl_manager.iter_archive(archive),
763
- },
764
- ),
765
- datasets.SplitGenerator(
766
- name=datasets.Split.TEST,
767
- gen_kwargs={
768
- "datafile": dl_dir + "/" + "test.json",
769
- "split": datasets.Split.TEST,
770
- "files": dl_manager.iter_archive(archive),
771
- },
772
- ),
773
- ]
774
-
775
- if self.config.name.startswith("wiki-ner"):
776
- archive = dl_manager.download(self.config.data_url)
777
- task_name = self._get_task_name_from_data_url(self.config.data_url)
778
- dl_dir = task_name + "/" + self.config.name.split(".")[1]
779
-
780
- return [
781
- datasets.SplitGenerator(
782
- name=datasets.Split.TRAIN,
783
- gen_kwargs={
784
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-train.txt",
785
- "split": datasets.Split.TRAIN,
786
- "files": dl_manager.iter_archive(archive),
787
- },
788
- ),
789
- datasets.SplitGenerator(
790
- name=datasets.Split.VALIDATION,
791
- gen_kwargs={
792
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-valid.txt",
793
- "split": datasets.Split.VALIDATION,
794
- "files": dl_manager.iter_archive(archive),
795
- },
796
- ),
797
- datasets.SplitGenerator(
798
- name=datasets.Split.TEST,
799
- gen_kwargs={
800
- "datafile": dl_dir + "/" + f"{self.config.name.split('.')[1]}-test.txt",
801
- "split": datasets.Split.TEST,
802
- "files": dl_manager.iter_archive(archive),
803
- },
804
- ),
805
- ]
806
-
807
- def _generate_examples(self, **args):
808
- """Yields examples."""
809
- filepath = args["datafile"]
810
- files = args["files"]
811
-
812
- if self.config.name.startswith("wnli"):
813
- if args["key"] == "test-split":
814
- for path, f in files:
815
- if path == filepath:
816
- data = csv.DictReader((line.decode("utf-8") for line in f))
817
- for id_, row in enumerate(data):
818
- yield id_, {"hypothesis": row["sentence1"], "premise": row["sentence2"], "label": "None"}
819
- break
820
- else:
821
- for path, f in files:
822
- if path == filepath:
823
- data = csv.DictReader((line.decode("utf-8") for line in f))
824
- for id_, row in enumerate(data):
825
- label = "entailment" if row["label"] else "not_entailment"
826
- yield id_, {
827
- "hypothesis": row["sentence1"],
828
- "premise": row["sentence2"],
829
- "label": label,
830
- }
831
- break
832
-
833
- if self.config.name.startswith("copa"):
834
- if args["key"] == "test-split":
835
- for path, f in files:
836
- if path == filepath:
837
- lines = f.readlines()
838
- data = map(lambda l: json.loads(l), lines)
839
- data = list(data)
840
- for id_, row in enumerate(data):
841
- yield id_, {
842
- "premise": row["premise"],
843
- "choice1": row["choice1"],
844
- "choice2": row["choice2"],
845
- "question": row["question"],
846
- "label": 0,
847
- }
848
- break
849
- else:
850
- for path, f in files:
851
- if path == filepath:
852
- lines = f.readlines()
853
- data = map(lambda l: json.loads(l), lines)
854
- data = list(data)
855
- for id_, row in enumerate(data):
856
- yield id_, {
857
- "premise": row["premise"],
858
- "choice1": row["choice1"],
859
- "choice2": row["choice2"],
860
- "question": row["question"],
861
- "label": row["label"],
862
- }
863
- break
864
-
865
- if self.config.name.startswith("sna"):
866
- for path, f in files:
867
- if path == filepath:
868
- df = pd.read_csv(f, names=["label", "text"])
869
- for id_, row in df.iterrows():
870
- yield id_, {"text": row["text"], "label": row["label"]}
871
- break
872
-
873
- if self.config.name.startswith("csqa"):
874
- for path, f in files:
875
- if path == filepath:
876
- data = json.load(f)
877
- df = pd.DataFrame(data["cloze_data"])
878
- df["out_of_context_options"].loc[df["out_of_context_options"].isnull()] = (
879
- df["out_of_context_options"].loc[df["out_of_context_options"].isnull()].apply(lambda x: [])
880
- )
881
- for id_, row in df.iterrows():
882
- yield id_, {
883
- "question": row["question"],
884
- "answer": row["answer"],
885
- "category": row["category"],
886
- "title": row["title"],
887
- "out_of_context_options": row["out_of_context_options"],
888
- "options": row["options"],
889
- }
890
- break
891
-
892
- if self.config.name.startswith("wstp"):
893
- for path, f in files:
894
- if path == filepath:
895
- df = pd.read_json(f)
896
- for id_, row in df.iterrows():
897
- yield id_, {
898
- "sectionText": row["sectionText"],
899
- "correctTitle": row["correctTitle"],
900
- "titleA": row["titleA"],
901
- "titleB": row["titleB"],
902
- "titleC": row["titleC"],
903
- "titleD": row["titleD"],
904
- "url": row["url"],
905
- }
906
- break
907
-
908
- if (
909
- self.config.name.startswith("inltkh")
910
- or self.config.name.startswith("bbca")
911
- or self.config.name.startswith("iitp")
912
- ):
913
- for path, f in files:
914
- if path == filepath:
915
- df = pd.read_csv(f, names=["label", "text"])
916
- for id_, row in df.iterrows():
917
- yield id_, {"text": row["text"], "label": row["label"]}
918
- break
919
-
920
- if self.config.name.startswith("actsa"):
921
- for path, f in files:
922
- if path == filepath:
923
- df = pd.read_csv(f, names=["label", "text"])
924
- for id_, row in df.iterrows():
925
- label = "positive" if row["label"] else "negative"
926
- yield id_, {"text": row["text"], "label": label}
927
- break
928
-
929
- if self.config.name.startswith("cvit"):
930
- source = args["src"]
931
- target = args["tgt"]
932
- src, tgt = None, None
933
- for path, f in files:
934
- if path == source:
935
- src = f.read().decode("utf-8").splitlines()
936
- elif path == target:
937
- tgt = f.read().decode("utf-8").splitlines()
938
- if src is not None and tgt is not None:
939
- for id_, row in enumerate(zip(src, tgt)):
940
- yield id_, {"sentence1": row[0], "sentence2": row[1]}
941
- break
942
-
943
- if self.config.name.startswith("md"):
944
- for path, f in files:
945
- if path == filepath:
946
- df = pd.read_json(f)
947
- for id_, row in df.iterrows():
948
- yield id_, {
949
- "story_number": row["Story_no"],
950
- "sentence": row["Sentence"],
951
- "discourse_mode": row["Discourse Mode"],
952
- "id": row["id"],
953
- }
954
- break
955
-
956
- if self.config.name.startswith("wiki-ner"):
957
- for path, f in files:
958
- if path == filepath:
959
- data = f.read().decode("utf-8").splitlines()
960
- tokens = []
961
- labels = []
962
- infos = []
963
- for id_, row in enumerate(data):
964
- row = row.split()
965
-
966
- if len(row) == 0:
967
- yield id_, {"tokens": tokens, "ner_tags": labels, "additional_info": infos}
968
- tokens = []
969
- labels = []
970
- infos = []
971
- continue
972
-
973
- tokens.append(row[0])
974
- labels.append(row[-1])
975
- infos.append(row[1:-1])
976
- break
977
-
978
- def _get_task_name_from_data_url(self, data_url):
979
- return data_url.split("/")[-1].split(".")[0]