File size: 32,642 Bytes
f9233bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
# Copyright 2023 The Touché23-ValueEval Datasets Authors and the current dataset script contributor.
#
# Licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://creativecommons.org/licenses/by/4.0/legalcode

"""The Touch\u00E923-ValueEval Dataset"""

import json
import pandas as pd
import os
import sys
import subprocess

import datasets


_DESCRIPTION = """\
Dataset for Touch\u00E9 / SemEval 2023 Task 4; ValueEval: Identification of Human Values behind Arguments:
https://www.overleaf.com/6679855346wrdckzkdccxg
Based on the original Webis-ArgValues-22 (https://doi.org/10.5281/zenodo.5657249) dataset accompanying the paper
Identifying the Human Values behind Arguments (Kiesel et al. 2022b; https://webis.de/publications.html#kiesel_2022b),
published at ACL'22.

"""

_CITATION = """\
@Article{mirzakhmedova:2023a,
  author    = {Nailia Mirzakhmedova and Johannes Kiesel and Milad Alshomary and Maximilian Heinrich and Nicolas Handke\
and Xiaoni Cai and Valentin Barriere and Doratossadat Dastgheib and Omid Ghahroodi and {Mohammad Ali} Sadraei\
and Ehsaneddin Asgari and Lea Kawaletz and Henning Wachsmuth and Benno Stein},
  doi       = {10.48550/arXiv.2301.13771},
  journal   = {CoRR},
  month     = jan,
  publisher = {arXiv},
  title     = {{The Touch{\'e}23-ValueEval Dataset for Identifying Human Values behind Arguments}},
  volume    = {abs/2301.13771},
  year      = 2023
}"""

_ARGUMENT_DATASET_DESCRIPTION = """\
Each row corresponds to an argument consisting of it's unique identifier (Argument ID) and the arguments content being
its Premise, Stance, and Conclusion.
"""

_LEVEL1_DESCRIPTION = _ARGUMENT_DATASET_DESCRIPTION + """\
The Labels for each example is an array of 1s (argument resorts to value) and 0s (argument does not resort to value).
The 54 human values from the level 1 of the value taxonomy (Kiesel et al. 2022b) are not used for the 2023 task
(except for the annotation), but are still listed here for some might find them useful for understanding the value
categories. Their order is the same as in the original files. For more details see the 'value-categories' configuration."""

_LEVEL2_DESCRIPTION = _ARGUMENT_DATASET_DESCRIPTION + """\
The Labels for each example is an array of 1s (argument resorts to value) and 0s (argument does not resort to value).
The order of the 20 value categories from the level 2 of the value taxonomy (Kiesel et al. 2022b)
is the same as in the original files. For more details see the 'value-categories' configuration."""

_IBM_DESCRIPTION = """\
The 7368 arguments from the IBM-ArgQ-Rank-30kArgs corpus (Gretz et al., 2020):
https://research.ibm.com/haifa/dept/vst/debating_data.shtml#Argument%20Quality"""

_IBM_META_DESCRIPTION = """\
Each entry corresponds to one argument (IDs starting with A) containing the data on argument quality for the respective
argument taken from the IBM-ArgQ-Rank-30kArgs corpus."""

_ZHIHU_DESCRIPTION = """\
Supplementary set of 100 arguments from the recommendation and hotlist section of the Chinese question-answering website Zhihu:
https://www.zhihu.com/explore
which teams can use for training or validating more robust approaches; these have been part of the original\
Webis-ArgValues-22 dataset."""

_ZHIHU_META_DESCRIPTION = """\
Each entry corresponds to one argument (IDs starting with C) reporting the original chinese conclusion and premise
as well as the link to the original statement the argument was taken from."""

_GROUP_DISCUSSION_IDEAS_DESCRIPTION = """\
A set of 399 arguments from the Group Discussion Ideas (GD IDEAS) web page:
https://www.groupdiscussionideas.com/"""

_GROUP_DISCUSSION_IDEAS_META_DESCRIPTION = """\
Each entry corresponds to one argument (IDs starting with D) reporting the link to the topic the argument was taken from."""

_COFE_DESCRIPTION = """\
A set of 1098 arguments from the Conference on the Future of Europe portal:
https://futureu.europa.eu/
The arguments were sampled from an existing dataset (Barriere et al., 2022)."""

_COFE_META_DESCRIPTION = """\
Each entry corresponds to one argument (IDs starting with E) reporting the link to the comment the argument was taken from."""

_NAHJALBALAGHA_DESCRIPTION = """\
Arguments from and based on the Nahj al-Balagha.
This data was contributed by the language.ml lab (Doratossadat, Omid, Mohammad, Ehsaneddin):
https://language.ml/"""

_NAHJALBALAGHA_META_DESCRIPTION = """\
Each entry corresponds to one argument (IDs starting with F) containing information on the 279 arguments in the dataset
(configuration: 'nahjalbalagha') and 1047 additional arguments that were not labeled so far."""

_NYT_DESCRIPTION = """\
Supplementary set of 80 arguments from 12 news articles of The New York Times
https://www.nytimes.com/
that were published between July 2020 and May 2021 and contain at least one of these keywords:
coronavirus (2019-ncov), vaccination and immunization, and epidemics."""

_NYT_META_DESCRIPTION = """\
Each entry corresponds to one argument (IDs starting with G) reporting the link to the article the argument was taken
from and the timestamp of the article's version in the Internet Archive that was used."""

_CATEGORIES_JSON_DESCRIPTION = """\
The single JSON entry in value-categories describes the 20 value categories (level 2 of the taxonomy) of this task
through examples. Each category maps to a dictionary of its contained level 1 values with a given list of exemplary phrases.
The level 1 values are not used for the 2023 task (except for the annotation), but are still listed here for some might
find them useful for understanding the value categories."""

_IBM_CITATION = """\
@inproceedings{gretz:2020,
  author    = {Shai Gretz and Roni Friedman and Edo Cohen{-}Karlik and Assaf Toledo and Dan Lahav and Ranit Aharonov and Noam Slonim},
  title     = {A Large-Scale Dataset for Argument Quality Ranking: Construction and Analysis},
  booktitle = {34th {AAAI} Conference on Artificial Intelligence ({AAAI} 2020)},
  pages     = {7805-7813},
  publisher = {{AAAI} Press},
  year      = {2020},
  doi       = {10.1609/aaai.v34i05.6285},
  url       = {https://aaai.org/ojs/index.php/AAAI/article/view/6285}
}"""

_COFE_CITATION = """\
@inproceedings{barriere-etal-2022-cofe,
  title = "{C}o{FE}: A New Dataset of Intra-Multilingual Multi-target Stance Classification from an Online {E}uropean Participatory Democracy Platform",
  author = "Barriere, Valentin and Jacquet, Guillaume Guillaume and Hemamou, Leo",
  booktitle = "Proceedings of the 2nd Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 12th International Joint Conference on Natural Language Processing (Volume 2: Short Papers)",
  month = nov,
  year = "2022",
  address = "Online only",
  publisher = "Association for Computational Linguistics",
  url = "https://aclanthology.org/2022.aacl-short.52",
  pages = "418--422"
}"""

_HOMEPAGE = "https://webis.de/data/touche23-valueeval.html"

_LICENSE = "https://creativecommons.org/licenses/by/4.0/legalcode"


######################################
# START OF: Additional variables #####
######################################

_SPLIT_META = datasets.Split('meta')

_CONFIG_NAME_MAIN, _CONFIG_NAME_NAHJALBALAGHA, _CONFIG_NAME_ZHIHU = "main", "nahjalbalagha", "zhihu"
_CONFIG_NAME_MAIN_LEVEL1, _CONFIG_NAME_NAHJALBALAGHA_LEVEL1, _CONFIG_NAME_ZHIHU_LEVEL1 = "main-level1", "nahjalbalagha-level1", "zhihu-level1"
_CONFIG_NAME_NYT, _CONFIG_NAME_NYT_LEVEL1 = "nyt", "nyt-level1"

_CONFIG_NAME_META_A, _CONFIG_NAME_META_D, _CONFIG_NAME_META_E = "ibm-meta", "gdi-meta", "cofe-meta"
_CONFIG_NAME_META_C, _CONFIG_NAME_META_F, _CONFIG_NAME_META_G = "zhihu-meta", "nahjalbalagha-meta", "nyt-meta"
_CONFIG_NAME_VALUE_CATEGORIES = "value-categories"

_SPLIT_TYPE_TRAIN, _SPLIT_TYPE_VAL, _SPLIT_TYPE_TEST = "training", "validation", "test"
_SPLIT_TYPE_META = "meta"
_FILE_TYPE_ARGUMENTS, _FILE_TYPE_LABELS = "arguments", "labels"
_FILE_TYPE_META, _FILE_TYPE_JSON = "meta", "json"

_FILE_TYPE_DOWNLOADER = "downloader"

####################################
# END OF: Additional variables #####
####################################


###########################
# START OF: Data URLs #####
###########################

_ZENODO_LINK = "https://zenodo.org/record/7879430/files/"
_URL = os.environ.get('TIRA_INPUT_DIRECTORY', _ZENODO_LINK)
_NYT_DOWNLOADER_URL = "https://raw.githubusercontent.com/touche-webis-de/touche-code/main/semeval23/human-value-detection/nyt-downloader/"

_NYT_ARGUMENTS_FILE_LOCAL = "webis_touche23-valueeval_arguments-test-nyt.tsv"
_NYT_ARGUMENTS_FILE_ON_TIRA = "arguments-test-nyt.tsv"

_URLS = {
    _CONFIG_NAME_MAIN: {
        _SPLIT_TYPE_TRAIN: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-training.tsv",
            _FILE_TYPE_LABELS: _URL + "labels-training.tsv"
        },
        _SPLIT_TYPE_VAL: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-validation.tsv",
            _FILE_TYPE_LABELS: _URL + "labels-validation.tsv"
        },
        _SPLIT_TYPE_TEST: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-test.tsv",
            _FILE_TYPE_LABELS: _URL + "labels-test.tsv"
        }
    },
    _CONFIG_NAME_MAIN_LEVEL1: {
        _SPLIT_TYPE_TRAIN: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-training.tsv",
            _FILE_TYPE_LABELS: _URL + "level1-labels-training.tsv"
        },
        _SPLIT_TYPE_VAL: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-validation.tsv",
            _FILE_TYPE_LABELS: _URL + "level1-labels-validation.tsv"
        },
        _SPLIT_TYPE_TEST: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-test.tsv",
            _FILE_TYPE_LABELS: _URL + "level1-labels-test.tsv"
        }
    },
    _CONFIG_NAME_NAHJALBALAGHA: {
        _SPLIT_TYPE_TEST: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-test-nahjalbalagha.tsv",
            _FILE_TYPE_LABELS: _URL + "labels-test-nahjalbalagha.tsv"
        }
    },
    _CONFIG_NAME_NAHJALBALAGHA_LEVEL1: {
        _SPLIT_TYPE_TEST: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-test-nahjalbalagha.tsv",
            _FILE_TYPE_LABELS: _URL + "level1-labels-test-nahjalbalagha.tsv"
        }
    },
    _CONFIG_NAME_NYT: {
        _SPLIT_TYPE_TEST: {
            _FILE_TYPE_LABELS: _URL + "labels-test-nyt.tsv"
        }
    },
    _CONFIG_NAME_NYT_LEVEL1: {
        _SPLIT_TYPE_TEST: {
            _FILE_TYPE_LABELS: _URL + "level1-labels-test-nyt.tsv"
        }
    },
    _CONFIG_NAME_ZHIHU: {
        _SPLIT_TYPE_VAL: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-validation-zhihu.tsv",
            _FILE_TYPE_LABELS: _URL + "labels-validation-zhihu.tsv"
        }
    },
    _CONFIG_NAME_ZHIHU_LEVEL1: {
        _SPLIT_TYPE_VAL: {
            _FILE_TYPE_ARGUMENTS: _URL + "arguments-validation-zhihu.tsv",
            _FILE_TYPE_LABELS: _URL + "level1-labels-validation-zhihu.tsv"
        }
    },
    _CONFIG_NAME_META_A: {
        _SPLIT_TYPE_META: {
            _FILE_TYPE_META: _URL + "meta-arguments-a.tsv"
        }
    },
    _CONFIG_NAME_META_D: {
        _SPLIT_TYPE_META: {
            _FILE_TYPE_META: _URL + "meta-arguments-d.tsv"
        }
    },
    _CONFIG_NAME_META_E: {
        _SPLIT_TYPE_META: {
            _FILE_TYPE_META: _URL + "meta-arguments-e.tsv"
        }
    },
    _CONFIG_NAME_META_C: {
        _SPLIT_TYPE_META: {
            _FILE_TYPE_META: _URL + "meta-arguments-c.tsv"
        }
    },
    _CONFIG_NAME_META_F: {
        _SPLIT_TYPE_META: {
            _FILE_TYPE_META: _URL + "meta-arguments-f.tsv"
        }
    },
    _CONFIG_NAME_META_G: {
        _SPLIT_TYPE_META: {
            _FILE_TYPE_META: _URL + "meta-arguments-g.tsv"
        }
    },
    _CONFIG_NAME_VALUE_CATEGORIES: {
        _SPLIT_TYPE_META: {
            _FILE_TYPE_JSON: _URL + "value-categories.json"
        }
    }
}

_NYT_DOWNLOADER_FILES = {
    "requirements": _NYT_DOWNLOADER_URL + "requirements.txt",
    "downloader": _NYT_DOWNLOADER_URL + "nyt-downloader.py",
    "input-file": _NYT_DOWNLOADER_URL + "nyt01-spans.tsv",
    "checksum": _NYT_DOWNLOADER_URL + "arguments-test-nyt.sha256"
}
if _URL != _ZENODO_LINK:
    # running on TIRA
    _URLS[_CONFIG_NAME_NYT][_SPLIT_TYPE_TEST][_FILE_TYPE_ARGUMENTS] = _URL + _NYT_ARGUMENTS_FILE_ON_TIRA
    _URLS[_CONFIG_NAME_NYT_LEVEL1][_SPLIT_TYPE_TEST][_FILE_TYPE_ARGUMENTS] = _URL + _NYT_ARGUMENTS_FILE_ON_TIRA
else:
    # running locally
    _URLS[_CONFIG_NAME_NYT][_SPLIT_TYPE_TEST][_FILE_TYPE_DOWNLOADER] = _NYT_DOWNLOADER_FILES
    _URLS[_CONFIG_NAME_NYT_LEVEL1][_SPLIT_TYPE_TEST][_FILE_TYPE_DOWNLOADER] = _NYT_DOWNLOADER_FILES

#########################
# END OF: Data URLs #####
#########################


##########################
# START OF: Features #####
##########################

_FEATURES_ARGUMENT_SETS = datasets.Features(
    {
        "Argument ID": datasets.Value("string"),
        "Conclusion": datasets.Value("string"),
        "Stance": datasets.Value("string"),
        "Premise": datasets.Value("string"),
        "Labels": datasets.Sequence(feature=datasets.Value("int32"))
    }
)

_FEATURES_META_SETS = {
    _CONFIG_NAME_META_A: datasets.Features(
        {
            "Argument ID": datasets.Value("string"),
            "WA": datasets.Value("float64"),
            "MACE-P": datasets.Value("float64"),
            "stance_WA": datasets.Value("int32"),
            "stance_WA_conf": datasets.Value("float64")
        }
    ),
    _CONFIG_NAME_META_D: datasets.Features(
        {
            "Argument ID": datasets.Value("string"),
            "URL": datasets.Value("string")
        }
    ),
    _CONFIG_NAME_META_E: datasets.Features(
        {
            "Argument ID": datasets.Value("string"),
            "URL": datasets.Value("string")
        }
    ),
    _CONFIG_NAME_META_C: datasets.Features(
        {
            "Argument ID": datasets.Value("string"),
            "Conclusion Chinese": datasets.Value("string"),
            "Premise Chinese": datasets.Value("string"),
            "URL": datasets.Value("string")
        }
    ),
    _CONFIG_NAME_META_F: datasets.Features(
        {
            "Argument ID": datasets.Value("string"),
            "Conclusion Farsi": datasets.Value("string"),
            "Stance Farsi": datasets.Value("string"),
            "Premise Farsi": datasets.Value("string"),
            "Conclusion English": datasets.Value("string"),
            "Stance English": datasets.Value("string"),
            "Premise English": datasets.Value("string"),
            "Source": datasets.Value("string"),
            "Method": datasets.Value("string")
        }
    ),
    _CONFIG_NAME_META_G: datasets.Features(
        {
            "Argument ID": datasets.Value("string"),
            "URL": datasets.Value("string"),
            "Internet Archive timestamp": datasets.Value("string")
        }
    ),
    _CONFIG_NAME_VALUE_CATEGORIES: datasets.Features(
        {
            "Self-direction: thought": {
                "Be creative": datasets.Sequence(feature=datasets.Value("string")),
                "Be curious": datasets.Sequence(feature=datasets.Value("string")),
                "Have freedom of thought": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Self-direction: action": {
                "Be choosing own goals": datasets.Sequence(feature=datasets.Value("string")),
                "Be independent": datasets.Sequence(feature=datasets.Value("string")),
                "Have freedom of action": datasets.Sequence(feature=datasets.Value("string")),
                "Have privacy": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Stimulation": {
                "Have an exciting life": datasets.Sequence(feature=datasets.Value("string")),
                "Have a varied life": datasets.Sequence(feature=datasets.Value("string")),
                "Be daring": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Hedonism": {
                "Have pleasure": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Achievement": {
                "Be ambitious": datasets.Sequence(feature=datasets.Value("string")),
                "Have success": datasets.Sequence(feature=datasets.Value("string")),
                "Be capable": datasets.Sequence(feature=datasets.Value("string")),
                "Be intellectual": datasets.Sequence(feature=datasets.Value("string")),
                "Be courageous": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Power: dominance": {
                "Have influence": datasets.Sequence(feature=datasets.Value("string")),
                "Have the right to command": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Power: resources": {
                "Have wealth": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Face": {
                "Have social recognition": datasets.Sequence(feature=datasets.Value("string")),
                "Have a good reputation": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Security: personal": {
                "Have a sense of belonging": datasets.Sequence(feature=datasets.Value("string")),
                "Have good health": datasets.Sequence(feature=datasets.Value("string")),
                "Have no debts": datasets.Sequence(feature=datasets.Value("string")),
                "Be neat and tidy": datasets.Sequence(feature=datasets.Value("string")),
                "Have a comfortable life": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Security: societal": {
                "Have a safe country": datasets.Sequence(feature=datasets.Value("string")),
                "Have a stable society": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Tradition": {
                "Be respecting traditions": datasets.Sequence(feature=datasets.Value("string")),
                "Be holding religious faith": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Conformity: rules": {
                "Be compliant": datasets.Sequence(feature=datasets.Value("string")),
                "Be self-disciplined": datasets.Sequence(feature=datasets.Value("string")),
                "Be behaving properly": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Conformity: interpersonal": {
                "Be polite": datasets.Sequence(feature=datasets.Value("string")),
                "Be honoring elders": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Humility": {
                "Be humble": datasets.Sequence(feature=datasets.Value("string")),
                "Have life accepted as is": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Benevolence: caring": {
                "Be helpful": datasets.Sequence(feature=datasets.Value("string")),
                "Be honest": datasets.Sequence(feature=datasets.Value("string")),
                "Be forgiving": datasets.Sequence(feature=datasets.Value("string")),
                "Have the own family secured": datasets.Sequence(feature=datasets.Value("string")),
                "Be loving": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Benevolence: dependability": {
                "Be responsible": datasets.Sequence(feature=datasets.Value("string")),
                "Have loyalty towards friends": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Universalism: concern": {
                "Have equality": datasets.Sequence(feature=datasets.Value("string")),
                "Be just": datasets.Sequence(feature=datasets.Value("string")),
                "Have a world at peace": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Universalism: nature": {
                "Be protecting the environment": datasets.Sequence(feature=datasets.Value("string")),
                "Have harmony with nature": datasets.Sequence(feature=datasets.Value("string")),
                "Have a world of beauty": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Universalism: tolerance": {
                "Be broadminded": datasets.Sequence(feature=datasets.Value("string")),
                "Have the wisdom to accept others": datasets.Sequence(feature=datasets.Value("string"))
            },
            "Universalism: objectivity": {
                "Be logical": datasets.Sequence(feature=datasets.Value("string")),
                "Have an objective view": datasets.Sequence(feature=datasets.Value("string"))
            }
        }
    )
}

########################
# END OF: Features #####
########################


class ToucheValueEvalConfig(datasets.BuilderConfig):
    """BuilderConfig for Touch\u00E923-ValueEval."""

    def __init__(self, features, data_urls, citation=None, **kwargs):
        """BuilderConfig for Touch\u00E923-ValueEval.

        Args:
            features: `list[string]`, list of the features that will appear in the
                feature dict.
            data_urls: `dict[string,dict[string,string]`, urls to download the dataset files from.
            citation: `string`, citation for the data set.
            **kwargs: keyword arguments forwarded to super.
        """
        # Version history:
        # 0.0.2: Initial version.
        super(ToucheValueEvalConfig, self).__init__(version=datasets.Version("0.0.2"), **kwargs)
        self.features = features
        self.data_urls = data_urls
        self.citation = citation


class ToucheValueEval(datasets.GeneratorBasedBuilder):
    """The Touch\u00E923-ValueEval dataset."""

    BUILDER_CONFIGS = [
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_MAIN,
            features=_FEATURES_ARGUMENT_SETS,
            data_urls=_URLS[_CONFIG_NAME_MAIN],
            description=_IBM_DESCRIPTION + '\n' + _COFE_DESCRIPTION + '\n' + _GROUP_DISCUSSION_IDEAS_DESCRIPTION + '\n' + _LEVEL2_DESCRIPTION,
            citation=_IBM_CITATION + '\n' + _COFE_CITATION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_MAIN_LEVEL1,
            features=_FEATURES_ARGUMENT_SETS,
            data_urls=_URLS[_CONFIG_NAME_MAIN_LEVEL1],
            description=_IBM_DESCRIPTION + '\n' + _COFE_DESCRIPTION + '\n' + _GROUP_DISCUSSION_IDEAS_DESCRIPTION + '\n' + _LEVEL1_DESCRIPTION,
            citation=_IBM_CITATION + '\n' + _COFE_CITATION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_NAHJALBALAGHA,
            features=_FEATURES_ARGUMENT_SETS,
            data_urls=_URLS[_CONFIG_NAME_NAHJALBALAGHA],
            description=_NAHJALBALAGHA_DESCRIPTION + '\n' + _LEVEL2_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_NAHJALBALAGHA_LEVEL1,
            features=_FEATURES_ARGUMENT_SETS,
            data_urls=_URLS[_CONFIG_NAME_NAHJALBALAGHA],
            description=_NAHJALBALAGHA_DESCRIPTION + '\n' + _LEVEL1_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_NYT,
            features=_FEATURES_ARGUMENT_SETS,
            data_urls=_URLS[_CONFIG_NAME_NYT],
            description=_NYT_DESCRIPTION + '\n' + _LEVEL2_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_NYT_LEVEL1,
            features=_FEATURES_ARGUMENT_SETS,
            data_urls=_URLS[_CONFIG_NAME_NYT_LEVEL1],
            description=_NYT_DESCRIPTION + '\n' + _LEVEL1_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_ZHIHU,
            features=_FEATURES_ARGUMENT_SETS,
            data_urls=_URLS[_CONFIG_NAME_ZHIHU],
            description=_ZHIHU_DESCRIPTION + '\n' + _LEVEL2_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_ZHIHU_LEVEL1,
            features=_FEATURES_ARGUMENT_SETS,
            data_urls=_URLS[_CONFIG_NAME_ZHIHU_LEVEL1],
            description=_ZHIHU_DESCRIPTION + '\n' + _LEVEL1_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_META_A,
            features=_FEATURES_META_SETS[_CONFIG_NAME_META_A],
            data_urls=_URLS[_CONFIG_NAME_META_A],
            description=_IBM_DESCRIPTION + '\n' + _IBM_META_DESCRIPTION,
            citation=_IBM_CITATION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_META_D,
            features=_FEATURES_META_SETS[_CONFIG_NAME_META_D],
            data_urls=_URLS[_CONFIG_NAME_META_D],
            description=_GROUP_DISCUSSION_IDEAS_DESCRIPTION + '\n' + _GROUP_DISCUSSION_IDEAS_META_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_META_E,
            features=_FEATURES_META_SETS[_CONFIG_NAME_META_E],
            data_urls=_URLS[_CONFIG_NAME_META_E],
            description=_COFE_DESCRIPTION + '\n' + _COFE_META_DESCRIPTION,
            citation=_COFE_CITATION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_META_C,
            features=_FEATURES_META_SETS[_CONFIG_NAME_META_C],
            data_urls=_URLS[_CONFIG_NAME_META_C],
            description=_ZHIHU_DESCRIPTION + '\n' + _ZHIHU_META_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_META_F,
            features=_FEATURES_META_SETS[_CONFIG_NAME_META_F],
            data_urls=_URLS[_CONFIG_NAME_META_F],
            description=_NAHJALBALAGHA_DESCRIPTION + '\n' + _NAHJALBALAGHA_META_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_META_G,
            features=_FEATURES_META_SETS[_CONFIG_NAME_META_G],
            data_urls=_URLS[_CONFIG_NAME_META_G],
            description=_NYT_DESCRIPTION + '\n' + _NYT_META_DESCRIPTION
        ),
        ToucheValueEvalConfig(
            name=_CONFIG_NAME_VALUE_CATEGORIES,
            features=_FEATURES_META_SETS[_CONFIG_NAME_VALUE_CATEGORIES],
            data_urls=_URLS[_CONFIG_NAME_VALUE_CATEGORIES],
            description=_CATEGORIES_JSON_DESCRIPTION
        ),
    ]

    DEFAULT_CONFIG_NAME = _CONFIG_NAME_MAIN

    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION + self.config.description,
            features=self.config.features,
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=(self.config.citation + '\n' if self.config.citation is not None else '') + _CITATION,
        )

    def _split_generators(self, dl_manager):
        urls = self.config.data_urls
        file_dict = dl_manager.download_and_extract(urls)

        if self.config.name == _CONFIG_NAME_MAIN or self.config.name == _CONFIG_NAME_MAIN_LEVEL1:
            splits = [
                datasets.SplitGenerator(
                    name=datasets.Split.TRAIN,
                    gen_kwargs={
                        "filepaths": file_dict[_SPLIT_TYPE_TRAIN],
                        "split": _SPLIT_TYPE_TRAIN
                    },
                ),
                datasets.SplitGenerator(
                    name=datasets.Split.VALIDATION,
                    gen_kwargs={
                        "filepaths": file_dict[_SPLIT_TYPE_VAL],
                        "split": _SPLIT_TYPE_VAL
                    },
                ),
                datasets.SplitGenerator(
                    name=datasets.Split.TEST,
                    gen_kwargs={
                        "filepaths": file_dict[_SPLIT_TYPE_TEST],
                        "split": _SPLIT_TYPE_TEST
                    },
                ),
            ]
        elif self.config.name in [_CONFIG_NAME_ZHIHU, _CONFIG_NAME_ZHIHU_LEVEL1]:
            splits = [
                datasets.SplitGenerator(
                    name=datasets.Split.VALIDATION,
                    gen_kwargs={
                        "filepaths": file_dict[_SPLIT_TYPE_VAL],
                        "split": _SPLIT_TYPE_VAL
                    },
                ),
            ]
        elif self.config.name in [_CONFIG_NAME_NYT, _CONFIG_NAME_NYT_LEVEL1]:
            splits = [
                datasets.SplitGenerator(
                    name=datasets.Split.TEST,
                    gen_kwargs={
                        "filepaths": file_dict[_SPLIT_TYPE_TEST],
                        "split": _SPLIT_TYPE_TEST
                    },
                ),
            ]
        elif self.config.name in [_CONFIG_NAME_NAHJALBALAGHA, _CONFIG_NAME_NAHJALBALAGHA_LEVEL1]:
            splits = [
                datasets.SplitGenerator(
                    name=datasets.Split.TEST,
                    gen_kwargs={
                        "filepaths": file_dict[_SPLIT_TYPE_TEST],
                        "split": _SPLIT_TYPE_TEST
                    },
                ),
            ]
        else:
            splits = [
                datasets.SplitGenerator(
                    name=_SPLIT_META,
                    gen_kwargs={
                        "filepaths": file_dict[_SPLIT_TYPE_META],
                        "split": _SPLIT_TYPE_META
                    },
                ),
            ]
        return splits

    # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
    def _generate_examples(self, filepaths, split):
        file_types = filepaths.keys()

        if self.config.name in [_CONFIG_NAME_NYT, _CONFIG_NAME_NYT_LEVEL1] and _FILE_TYPE_DOWNLOADER in file_types:
            # running locally => download nyt arguments
            downloader_paths = filepaths[_FILE_TYPE_DOWNLOADER]

            directory = os.path.dirname(downloader_paths['downloader'])
            arguments_file = os.path.join(directory, _NYT_ARGUMENTS_FILE_LOCAL)
            if not os.path.exists(arguments_file):
                subprocess.check_call(f"pip3 install -r {downloader_paths['requirements']}", shell=True, stdout=sys.stdout,
                                      stderr=subprocess.STDOUT)
                subprocess.check_call(f"spacy download en_core_web_sm", shell=True, stdout=sys.stdout,
                                      stderr=subprocess.STDOUT)
                subprocess.check_call(
                    f"python3 {downloader_paths['downloader']} --input-file {downloader_paths['input-file']} --output-file {arguments_file}",
                    shell=True, stdout=sys.stdout, stderr=subprocess.STDOUT)
            # extract checksum
            with open(downloader_paths['checksum'], mode='r', encoding='utf-8') as f:
                checksum = f.readline().split('  ')[0]
            subprocess.check_call(f"echo \"{checksum} {arguments_file}\" | sha256sum --check", shell=True,
                                  stdout=sys.stdout, stderr=subprocess.STDOUT)

            filepaths[_FILE_TYPE_ARGUMENTS] = arguments_file

        if _FILE_TYPE_ARGUMENTS in file_types:
            # argument data
            with open(filepaths[_FILE_TYPE_ARGUMENTS], encoding='utf-8') as f:
                dataframe_arguments = pd.read_csv(f, sep='\t', header=0)

            if _FILE_TYPE_LABELS not in file_types:
                label_names = []
            else:
                with open(filepaths[_FILE_TYPE_LABELS], encoding='utf-8') as f:
                    dataframe_labels = pd.read_csv(f, sep='\t', header=0)

                label_names = [x for x in dataframe_labels.columns if x != "Argument ID"]
                dataframe_arguments = dataframe_arguments.join(
                    dataframe_labels.set_index('Argument ID'), on='Argument ID', how='inner'
                )

            for key, row in dataframe_arguments.iterrows():
                yield key, {
                    "Argument ID": row["Argument ID"],
                    "Conclusion": row["Conclusion"],
                    "Stance": row["Stance"],
                    "Premise": row["Premise"],
                    "Labels": [int(row[x]) for x in label_names],
                }
        elif _FILE_TYPE_META in file_types:
            # meta data
            with open(filepaths[_FILE_TYPE_META], encoding='utf-8') as f:
                dataframe_meta = pd.read_csv(f, sep='\t', header=0)

            for key, row in dataframe_meta.iterrows():
                yield key, {str(column): row[str(column)] for column in row.keys()}
        else:
            # json data
            with open(filepaths[_FILE_TYPE_JSON], encoding='utf-8') as f:
                value_categories = json.load(f)

            yield 0, value_categories