SuzanaB commited on
Commit
d6f6dec
1 Parent(s): d71a4a8
Files changed (4) hide show
  1. copa_hr.py +100 -0
  2. test.jsonl +3 -0
  3. train.jsonl +3 -0
  4. val.jsonl +3 -0
copa_hr.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
16
+
17
+ import json
18
+
19
+ import datasets
20
+
21
+
22
+ _CITATION = ''
23
+ _DESCRIPTION = """The COPA-HR dataset (Choice of plausible alternatives in Croatian) is a translation
24
+ of the English COPA dataset (https://people.ict.usc.edu/~gordon/copa.html) by following the
25
+ XCOPA dataset translation methodology (https://arxiv.org/abs/2005.00333). The dataset consists of 1000 premises
26
+ (My body cast a shadow over the grass), each given a question (What is the cause?), and two choices
27
+ (The sun was rising; The grass was cut), with a label encoding which of the choices is more plausible
28
+ given the annotator or translator (The sun was rising).
29
+
30
+ The dataset is split into 400 training samples, 100 validation samples, and 500 test samples. It includes the
31
+ following features: 'premise', 'choice1', 'choice2', 'label', 'question', 'changed' (boolean).
32
+ """
33
+ _HOMEPAGE = 'https://www.clarin.si/repository/xmlui/handle/11356/1404'
34
+ _LICENSE = ''
35
+
36
+ _TRAINING_FILE = 'train.jsonl'
37
+ _DEV_FILE = 'val.jsonl'
38
+ _TEST_FILE = 'test.jsonl'
39
+
40
+
41
+ class CopaHr(datasets.GeneratorBasedBuilder):
42
+ VERSION = datasets.Version('1.1.0')
43
+
44
+ BUILDER_CONFIGS = [
45
+ datasets.BuilderConfig(
46
+ name='copa_hr',
47
+ version=VERSION,
48
+ data_files=[_TRAINING_FILE, _DEV_FILE, _TEST_FILE],
49
+ description=''
50
+ )
51
+ ]
52
+
53
+ def _info(self):
54
+ features = datasets.Features(
55
+ {
56
+ 'premise': datasets.Value('string'),
57
+ 'choice1': datasets.Value('string'),
58
+ 'choice2': datasets.Value('string'),
59
+ 'label': datasets.features.ClassLabel(names=['0', '1']),
60
+ 'question': datasets.Value('string'),
61
+ 'idx': datasets.Value('int64'),
62
+ 'changed': datasets.Value('bool')
63
+ }
64
+ )
65
+
66
+ return datasets.DatasetInfo(
67
+ description=_DESCRIPTION,
68
+ features=features,
69
+ supervised_keys=None,
70
+ homepage=_HOMEPAGE,
71
+ license=_LICENSE,
72
+ citation=_CITATION,
73
+ )
74
+
75
+ def _split_generators(self, dl_manager):
76
+ return [
77
+ datasets.SplitGenerator(
78
+ name=datasets.Split.TRAIN, gen_kwargs={'filepath': _TRAINING_FILE, 'split': 'train'}
79
+ ),
80
+ datasets.SplitGenerator(
81
+ name=datasets.Split.VALIDATION, gen_kwargs={'filepath': _DEV_FILE, 'split': 'dev'}
82
+ ),
83
+ datasets.SplitGenerator(
84
+ name=datasets.Split.TEST, gen_kwargs={'filepath': _TEST_FILE, 'split': 'test'}
85
+ ),
86
+ ]
87
+
88
+ def _generate_examples(self, filepath, split):
89
+ with open(filepath, encoding='utf-8') as f:
90
+ for i, line in enumerate(f):
91
+ data = json.loads(line)
92
+ yield i, {
93
+ 'premise': data['premise'],
94
+ 'choice1': data['choice1'],
95
+ 'choice2': data['choice2'],
96
+ 'question': data['question'],
97
+ 'label': str(data['label']),
98
+ 'idx': data['idx'],
99
+ 'changed': data['changed']
100
+ }
test.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:809967a09c31862d51efde4ae6ae0ed7d36d0e5179e260a786fc267569326875
3
+ size 98496
train.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a96f4bbcfb3d7dac287b31231b61a73f080b9cc9d68496cb6aaaa927f735230c
3
+ size 80381
val.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20b4348af5cfaf4be074a57e7b9e5c5d6fdb23eb0530681c7cd0295341a163a8
3
+ size 19982