joelniklaus commited on
Commit
8b5f6f6
1 Parent(s): 1840ecd

added dataset files

Browse files
Files changed (6) hide show
  1. .gitattributes +3 -0
  2. README.md +273 -0
  3. convert_to_hf_dataset.py +118 -0
  4. test.jsonl +3 -0
  5. train.jsonl +3 -0
  6. validation.jsonl +3 -0
.gitattributes CHANGED
@@ -35,3 +35,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
35
  *.mp3 filter=lfs diff=lfs merge=lfs -text
36
  *.ogg filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
 
 
 
35
  *.mp3 filter=lfs diff=lfs merge=lfs -text
36
  *.ogg filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
38
+ test.jsonl filter=lfs diff=lfs merge=lfs -text
39
+ train.jsonl filter=lfs diff=lfs merge=lfs -text
40
+ validation.jsonl filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - found
4
+ - other
5
+ language_creators:
6
+ - found
7
+ languages:
8
+ - de
9
+ - en
10
+ - it
11
+ - pl
12
+ license:
13
+ - cc-by-nc-2.5
14
+ multilinguality:
15
+ - multilingual
16
+ pretty_name: A Corpus for Multilingual Analysis of Online Terms of Service
17
+ size_categories:
18
+ - 1K<n<10K
19
+ source_datasets:
20
+ - original
21
+ task_categories:
22
+ - text-classification
23
+ task_ids:
24
+ - multi-class-classification
25
+ - multi-label-classification
26
+ ---
27
+
28
+ # Dataset Card for A Corpus for Multilingual Analysis of Online Terms of Service
29
+
30
+ ## Table of Contents
31
+
32
+ - [Table of Contents](#table-of-contents)
33
+ - [Dataset Description](#dataset-description)
34
+ - [Dataset Summary](#dataset-summary)
35
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
36
+ - [Languages](#languages)
37
+ - [Dataset Structure](#dataset-structure)
38
+ - [Data Instances](#data-instances)
39
+ - [Data Fields](#data-fields)
40
+ - [Data Splits](#data-splits)
41
+ - [Dataset Creation](#dataset-creation)
42
+ - [Curation Rationale](#curation-rationale)
43
+ - [Source Data](#source-data)
44
+ - [Annotations](#annotations)
45
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
46
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
47
+ - [Social Impact of Dataset](#social-impact-of-dataset)
48
+ - [Discussion of Biases](#discussion-of-biases)
49
+ - [Other Known Limitations](#other-known-limitations)
50
+ - [Additional Information](#additional-information)
51
+ - [Dataset Curators](#dataset-curators)
52
+ - [Licensing Information](#licensing-information)
53
+ - [Citation Information](#citation-information)
54
+ - [Contributions](#contributions)
55
+
56
+ ## Dataset Description
57
+
58
+ - **Homepage:**
59
+ - **Repository:** http://claudette.eui.eu/corpus_multilingual_NLLP2021.zip
60
+ - **Paper:** Drawzeski, K., Galassi, A., Jablonowska, A., Lagioia, F., Lippi, M., Micklitz, H. W., Sartor, G., Tagiuri,
61
+ G., & Torroni, P. (2021). A Corpus for Multilingual Analysis of Online Terms of Service. Proceedings of the Natural
62
+ Legal Language Processing Workshop 2021, 1–8. https://doi.org/10.18653/v1/2021.nllp-1.1
63
+ - **Leaderboard:**
64
+ - **Point of Contact:** [Joel Niklaus](joel.niklaus.2@bfh.ch)
65
+
66
+ ### Dataset Summary
67
+
68
+ *"We present the first annotated corpus for multilingual analysis of potentially unfair clauses in online Terms of
69
+ Service [=ToS]. The data set comprises a total of 100 contracts, obtained from 25 documents annotated in four different
70
+ languages: English, German, Italian, and Polish. For each contract, potentially unfair clauses for the consumer are
71
+ annotated, for nine different unfairness categories."* (Drawzeski et al., 2021)
72
+
73
+ ### Supported Tasks and Leaderboards
74
+
75
+ The dataset can be used for multi-class multi-label text classification tasks, more specifically, for classifying unfair clauses in
76
+ ToS.
77
+
78
+ ### Languages
79
+
80
+ English, German, Italian, and Polish.
81
+
82
+ ## Dataset Structure
83
+
84
+ ### Data Instances
85
+
86
+ The file format is jsonl and three data splits are present (train, validation and test).
87
+
88
+ ### Data Fields
89
+
90
+ The dataset contains the following fields:
91
+ - `language`: The language of the sentence/document.
92
+ - `company`: The company of the document.
93
+ - `line_number`: The line number of the sentence in the document.
94
+ - `sentence`: The sentence to be classified.
95
+ - `unfairness_level`: The unfairness level assigned to the sentence (if two clauses apply, the higher unfairness level is assigned here).
96
+
97
+ The documents have been annotated using nine tags that represent different categories of clause unfairness. These tags are:
98
+ - `a` = Arbitration: *”This clause requires or allows the parties to resolve their disputes through an arbitration process, before the case could go to court. It is therefore considered a kind of forum selection clause. However, such a clause may or may not specify that arbitration should occur within a specific jurisdiction. Clauses stipulating that the arbitration should (1) take place in a state other than the state of consumer’s residence and/or (2) be based not on law but on arbiter’s discretion were marked as clearly unfair.”* (Lippi et al., 2019)
99
+ - `ch` = Unilateral change: *"This clause specifies the conditions under which the service provider could amend and modify the terms of service and/or the service itself. Such clauses were always considered as potentially unfair. This is because the ECJ has not yet issued a judgment in this regard, though the Annex to the Direc- tive contains several examples supporting such a qualification."* (Lippi et al., 2019)
100
+ - `cr` = Content removal : *"This gives the provider a right to modify/delete user’s content, including in-app purchases, and sometimes specifies the conditions under which the service provider may do so. As in the case of unilateral termination, clauses that indicate conditions for content removal were marked as potentially unfair, whereas clauses stipulating that the service provider may remove content in his full discretion, and/or at any time for any or no reasons and/or without notice nor possibility to retrieve the content were marked as clearly unfair."* (Lippi et al., 2019)
101
+ - `j` = Jurisdiction : *"This type of clause stipulates what courts will have the competence to adjudicate disputes under the contract. Jurisdiction clauses giving consumers a right to bring disputes in their place of residence were marked as clearly fair, whereas clauses stating that any judicial proceeding takes a residence away (i.e. in a different city, different country) were marked as clearly unfair. This assessment is grounded in ECJ’s case law, see for example Oceano case number C-240/98."* (Lippi et al., 2019)
102
+ - `law` = Choice of law: *"This clause specifies what law will govern the contract, meaning also what law will be applied in potential adjudication of a dispute arising under the contract. Clauses defining the applicable law as the law of the consumer’s country of residence were marked as clearly fair [...]"* (Lippi et al., 2019)
103
+ - `ltd` = Limitation of liability: *"This clause stipulates that the duty to pay damages is limited or excluded, for certain kinds of losses and under certain conditions. Clauses that explicitly affirm non-excludable providers’ liabilities were marked as clearly fair."* (Lippi et al., 2019)
104
+ - `ter` = Unilateral termination: *"This clause gives provider the right to suspend and/or terminate the service and/or the contract, and sometimes details the circumstances under which the provider claims to have a right to do so. Unilateral termination clauses that specify reasons for termination were marked as potentially unfair. Whereas clauses stipulating that the service provider may suspend or terminate the service at any time for any or no reasons and/or without notice were marked as clearly unfair."* (Lippi et al., 2019)
105
+ - `use` = Contract by using: *"This clause stipulates that the consumer is bound by the terms of use of a specific service, simply by using the service, without even being required to mark that he or she has read and accepted them. We always marked such clauses as potentially unfair. The reason for this choice is that a good argument can be offered for these clauses to be unfair, because they originate an imbalance in rights and duties of the parties, but this argument has no decisive authoritative backing yet, since the ECJ has never assessed a clause of this type."* (Lippi et al., 2019)
106
+ - `pinc` = Privacy included: This tag identifies *"clauses stating that consumers consent to the privacy policy simply by using the service. Such clauses have been always considered potentially unfair"* (Drawzeski et al., 2021)
107
+
108
+ *”We assumed that each type of clause could be classified as either clearly fair, or potentially unfair, or clearly unfair. In order to mark the different degrees of (un)fairness we appended a numeric value to each XML tag, with 1 meaning clearly fair, 2 potentially unfair, and 3 clearly unfair. Nested tags were used to annotate text segments relevant to more than one type of clause. With clauses covering multiple paragraphs, we chose to tag each paragraph separately, possibly with different degrees of (un)fairness.”* (Lippi et al., 2019)
109
+
110
+ ### Data Splits
111
+
112
+ No splits provided in the original paper.
113
+
114
+ Joel Niklaus created the splits manually. The train split contains the 20 (80%) first companies in alphabetic order (*Booking, Dropbox, Electronic_Arts, Evernote, Facebook, Garmin, Google, Grindr, Linkedin, Mozilla,
115
+ Pinterest, Quora, Ryanair, Skype, Skyscanner, Snap, Spotify, Terravision, Tinder, Tripadvisor*). The
116
+ validation split contains the 2 (8%) companies *Tumblr* and *Uber*. The test split contains the 3 (12%) companies *Weebly*,
117
+ *Yelp*, *Zynga*.
118
+
119
+ There are two tasks possible for this dataset.
120
+
121
+ #### Clause Topics
122
+
123
+ By only considering the clause topic, we separated the clause topic from the fairness level classification. Thus, the label set could be reduced to just 9 classes.
124
+ This dataset poses a multi-label multi-class sentence classification problem.
125
+
126
+ The following label distribution shows the number of occurrences per label per split. `total occurrences` sums up the previous rows (number of clause topics per split). `split size` is the number of sentences per split.
127
+
128
+
129
+ | clause topic | train | validation | test |
130
+ |:----------------------|------------:|-----------------:|-----------:|
131
+ | a | 117 | 6 | 21 |
132
+ | ch | 308 | 45 | 53 |
133
+ | cr | 155 | 4 | 44 |
134
+ | j | 206 | 8 | 36 |
135
+ | law | 178 | 8 | 26 |
136
+ | ltd | 714 | 84 | 161 |
137
+ | ter | 361 | 39 | 83 |
138
+ | use | 185 | 14 | 32 |
139
+ | pinc | 71 | 0 | 8 |
140
+ | **total occurrences** | **2295** | **208** | **464** |
141
+ | **split size** | **19942** | **1690** | **4297** |
142
+
143
+
144
+ #### Unfairness Levels
145
+
146
+ When predicting unfairness levels, all untagged sentences can be removed. This reduces the dataset size considerably.
147
+ This dataset poses a single-label multi-class sentence classification problem.
148
+
149
+ | unfairness_level | train | validation | test |
150
+ |:---------------------------|------------:|-----------:|----------:|
151
+ | untagged | 17868 | 1499 | 3880 |
152
+ | potentially_unfair | 1560 | 142 | 291 |
153
+ | clearly_unfair | 259 | 31 | 65 |
154
+ | clearly_fair | 156 | 5 | 32 |
155
+ | **total without untagged** | **1975** | **178** | **388** |
156
+ | **total** | **19942** | **1690** | **4297** |
157
+
158
+
159
+
160
+
161
+ ## Dataset Creation
162
+
163
+ ### Curation Rationale
164
+
165
+ The EU legislation is published in all official languages. This multilingualism comes with costs and challenges, such as limited cross-linguistical interpretability. The EU has refrained from regulating languages in which standard terms in consumer contracts should be drafted, allowing for differing approaches to emerge in various jurisdictions. Consumer protection authorities and non-governmental organizations in Europe tend to operate only in their respective languages. Therefore, consumer protection technologies are needed that are capable of dealing with multiple languages. The dataset at hand can be used for the automated detection of unfair clauses in ToS which, in most cases, are available in multiple languages. (Drawzeski et al., 2021)
166
+
167
+ ### Source Data
168
+
169
+ #### Initial Data Collection and Normalization
170
+
171
+ *"The analysed ToS were retrieved from the [Claudette pre-existing corpus](http://claudette.eui.eu/ToS.zip), covering 100 English ToS (Lippi et al., 2019; Ruggeri et al., 2021). Such terms mainly concern popular digital services provided to consumers, including leading online platforms (such as search engines and social media). The predominant language of drafting of these ToS is English, with differing availability of corresponding ToS in other languages. To carry out the present study, the ultimate 25 ToS were selected on the basis of three main criteria: a) their availability in the four selected languages; b) the possibility of identifying a correspondence between the different versions, given their publication date; and c) the similarity of their structure (e.g. number of clauses, sections, etc.). To illustrate, while ToS in both German and Italian were identified for 63 out of the 100 ToS contained in the pre-existing Claudette training corpus, Polish versions were found for only 42 of these 63 ToS. Out of the 42 ToS available in the four languages, we selected those with the more closely corresponding versions based on criteria b) and c) above. Perfect correspondence across the 4 languages, however, could not be achieved for all 25 ToS."* (Drawzeski et al., 2021)
172
+
173
+ #### Who are the source language producers?
174
+
175
+ The source language producers are likely to be lawyers.
176
+
177
+ ### Annotations
178
+
179
+ #### Annotation process
180
+
181
+ The dataset at hand is described by Drawzeski et al. (2021). The ToS of the dataset were retrieved from the pre-existing
182
+ and mono-lingual (English) Claudette corpus which is described in (Lippi et al., 2019). Drawzeski et al. (2021) *“investigate methods for automatically transferring the annotations made on ToS in the context of the Claudette project
183
+ onto the corresponding versions of the same documents in a target language, where such resources and expertise may be
184
+ lacking.”*
185
+
186
+ Therefore, in the following, we will present the annotation process for the Claudette corpus as described in (Lippi et
187
+ al., 2019).
188
+
189
+ *”The corpus consists of 50 relevant on-line consumer contracts, i.e., ToS of on-line platforms. Such contracts were
190
+ selected among those offered by some of the major players in terms of number of users, global relevance, and time the
191
+ service was established. Such contracts are usually quite detailed in content, are frequently updated to reflect changes
192
+ both in the service and in the applicable law, and are often available in different versions for different
193
+ jurisdictions. Given multiple versions of the same contract, we selected the most recent version available on-line to
194
+ European customers. The mark-up was done in XML by three annotators, which jointly worked for the formulation of the
195
+ annotation guidelines. The whole annotation process included several revisions, where some corrections were also
196
+ suggested by an analysis of the false positives and false negatives retrieved by the initial machine learning
197
+ prototypes. Due to the large interaction among the annotators during this process, in order to assess inter-annotation
198
+ agreement, a further test set consisting of 10 additional contracts was tagged, following the final version of the
199
+ guidelines. […] We produced an additional test set consisting of 10 more annotated contracts. Such documents were
200
+ independently tagged by two distinct annotators who had carefully studied the guidelines. In order to quantitatively
201
+ measure the inter-annotation agreement, for this test set we computed the standard Cohen’s 𝜅 metric […] which resulted
202
+ to be 0.871 […].”*
203
+
204
+ #### Who are the annotators?
205
+
206
+ Not specified.
207
+
208
+ ### Personal and Sensitive Information
209
+
210
+ [More Information Needed]
211
+
212
+ ## Considerations for Using the Data
213
+
214
+ ### Social Impact of Dataset
215
+
216
+ [More Information Needed]
217
+
218
+ ### Discussion of Biases
219
+
220
+ It is very likely that some ToS in German, Italian and Polish are direct translations from English. Drawzeski et al. (2021) write: *“Although we could not assess this comprehensively in the present study, we infer from the wording of the ToS that at least in 9 out of 25 cases, German, Italian and Polish documents were indeed translations of the English originals.”*
221
+
222
+ ### Other Known Limitations
223
+
224
+ Note that the information given in this dataset card refer to the dataset version as provided by Joel Niklaus and Veton Matoshi. The dataset at hand is intended to be part of a bigger benchmark dataset. Creating a benchmark dataset consisting of several other datasets from different sources requires postprocessing. Therefore, the structure of the dataset at hand, including the folder structure, may differ considerably from the original dataset. In addition to that, differences with regard to dataset statistics as give in the respective papers can be expected. The reader is advised to have a look at the conversion script ```convert_to_hf_dataset.py``` in order to retrace the steps for converting the original dataset into the present jsonl-format. For further information on the original dataset structure, we refer to the bibliographical references and the original Github repositories and/or web pages provided in this dataset card.
225
+
226
+ ## Additional Information
227
+
228
+ ### Dataset Curators
229
+
230
+ The names of the original dataset curators and creators can be found in references given below, in the section *Citation Information*.
231
+ Additional changes were made by Joel Niklaus ([Email](joel.niklaus.2@bfh.ch); [Github](https://github.com/joelniklaus)) and Veton Matoshi ([Email](veton.matoshi@bfh.ch); [Github](https://github.com/kapllan)).
232
+
233
+
234
+ ### Licensing Information
235
+
236
+ [More Information Needed]
237
+
238
+ ### Citation Information
239
+
240
+ ```
241
+ @inproceedings{drawzeski-etal-2021-corpus,
242
+ address = {Punta Cana, Dominican Republic},
243
+ author = {Drawzeski, Kasper and Galassi, Andrea and Jablonowska, Agnieszka and Lagioia, Francesca and Lippi, Marco and Micklitz, Hans Wolfgang and Sartor, Giovanni and Tagiuri, Giacomo and Torroni, Paolo},
244
+ booktitle = {Proceedings of the Natural Legal Language Processing Workshop 2021},
245
+ doi = {10.18653/v1/2021.nllp-1.1},
246
+ month = {nov},
247
+ pages = {1--8},
248
+ publisher = {Association for Computational Linguistics},
249
+ title = {{A Corpus for Multilingual Analysis of Online Terms of Service}},
250
+ url = {https://aclanthology.org/2021.nllp-1.1},
251
+ year = {2021}
252
+ }
253
+ ```
254
+
255
+ ```
256
+ @article{Lippi2019,
257
+ author = {Lippi, Marco and Pa{\l}ka, Przemys{\l}aw and Contissa, Giuseppe and Lagioia, Francesca and Micklitz, Hans-Wolfgang and Sartor, Giovanni and Torroni, Paolo},
258
+ doi = {10.1007/s10506-019-09243-2},
259
+ issn = {1572-8382},
260
+ journal = {Artificial Intelligence and Law},
261
+ number = {2},
262
+ pages = {117--139},
263
+ title = {{CLAUDETTE: an automated detector of potentially unfair clauses in online terms of service}},
264
+ url = {https://doi.org/10.1007/s10506-019-09243-2},
265
+ volume = {27},
266
+ year = {2019}
267
+ }
268
+ ```
269
+
270
+ ### Contributions
271
+
272
+ Thanks to [@JoelNiklaus](https://github.com/joelniklaus) and [@kapllan](https://github.com/kapllan) for adding this
273
+ dataset.
convert_to_hf_dataset.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import glob
2
+ import os
3
+ from pathlib import Path
4
+
5
+ import pandas as pd
6
+
7
+ data_path = Path("corpus_NLLP2021")
8
+ languages = ["de", "en", "it", "pl"]
9
+ clause_topics = ["a", "ch", "cr", "j", "law", "ltd", "ter", "use", "pinc"]
10
+ unfairness_levels = {1: "clearly_fair", 2: "potentially_unfair", 3: "clearly_unfair", -1: "untagged"}
11
+
12
+ file_names = glob.glob(str(data_path / "sentences" / "de" / "original/*"))
13
+ companies = sorted([Path(file_name).stem for file_name in file_names])
14
+ print(companies)
15
+
16
+
17
+ def get_file_name(type, language, company):
18
+ return data_path / type / language / "original" / (company + ".txt")
19
+
20
+
21
+ def read_lines(file_name):
22
+ with open(file_name) as file:
23
+ return [line.strip() for line in file.readlines()]
24
+
25
+
26
+ def read_companies(languages, companies):
27
+ data = []
28
+ for language in languages:
29
+ for company in companies:
30
+ tags = read_lines(get_file_name("tags", language, company))
31
+ sentences = read_lines(get_file_name("sentences", language, company))
32
+ assert len(tags) == len(sentences), "The number of tags is not equal to the number of sentences"
33
+ for i in range(len(sentences)):
34
+ topics = [tag[:-1] for tag in tags[i].split(" ")] if tags[i] else [] # getting only the topic
35
+ levels = [int(tag[-1:]) for tag in tags[i].split(" ")] if tags[i] else [] # getting only the level
36
+ levels = list(set(levels)) # remove any duplicates
37
+ row = {"language": language, "company": company, "line_number": i, "sentence": sentences[i]}
38
+ # assign "untagged" if not annotated (levels empty)
39
+ if not levels:
40
+ level = -1
41
+ elif len(levels) > 1:
42
+ level = max(levels) # if multiple different levels present, keep the highest level
43
+ else: # there is exactly one level
44
+ level = levels[0]
45
+ assert level in [1, 2, 3]
46
+ row["unfairness_level"] = unfairness_levels[level]
47
+ for topic in clause_topics:
48
+ row[topic] = True if topic in topics else False
49
+
50
+ data.append(row)
51
+ return pd.DataFrame.from_records(data)
52
+
53
+
54
+ df = read_companies(languages, companies)
55
+
56
+ df.to_csv("dataset.csv")
57
+
58
+ # not removing sentences with no tag ==> detecting whether a tag at all applies is part of the task
59
+ # print(len(df.index))
60
+ # df = df[df.tag != ("",)]
61
+ # print(len(df.index))
62
+
63
+ # splits: train: 20 (80%) first companies in alphabetic order, validation: 2 (8%) (Tumblr and Uber), test: 3 (12%) (Weebly, Yelp, Zynga)
64
+ validation_companies = ["Tumblr", "Uber"]
65
+ test_companies = ["Weebly", "Yelp", "Zynga"]
66
+ train_companies = sorted(list(set(companies) - set(validation_companies) - set(test_companies)))
67
+
68
+ # create splits
69
+ train = df[df.company.isin(train_companies)]
70
+ validation = df[df.company.isin(validation_companies)]
71
+ test = df[df.company.isin(test_companies)]
72
+
73
+
74
+ # save splits
75
+ def save_splits_to_jsonl(config_name):
76
+ # save to jsonl files for huggingface
77
+ if config_name: os.makedirs(config_name, exist_ok=True)
78
+ train.to_json(os.path.join(config_name, "train.jsonl"), lines=True, orient="records", force_ascii=False)
79
+ validation.to_json(os.path.join(config_name, "validation.jsonl"), lines=True, orient="records", force_ascii=False)
80
+ test.to_json(os.path.join(config_name, "test.jsonl"), lines=True, orient="records", force_ascii=False)
81
+
82
+
83
+ def print_split_table_multi_label(splits, label_names):
84
+ data = {split_name: {} for split_name in splits.keys()}
85
+ for split_name, split in splits.items():
86
+ sum = 0
87
+ for label_name in label_names:
88
+ counts = split[label_name].value_counts()
89
+ data[split_name][label_name] = counts[True] if True in counts else 0
90
+ sum += data[split_name][label_name]
91
+ data[split_name]["total occurrences"] = sum
92
+ data[split_name]["split size"] = len(split.index)
93
+ table = pd.DataFrame(data)
94
+
95
+ print(table.to_markdown())
96
+
97
+
98
+ def print_split_table_single_label(train, validation, test, label_name):
99
+ train_counts = train[label_name].value_counts().to_frame().rename(columns={label_name: "train"})
100
+ validation_counts = validation[label_name].value_counts().to_frame().rename(columns={label_name: "validation"})
101
+ test_counts = test[label_name].value_counts().to_frame().rename(columns={label_name: "test"})
102
+
103
+ table = train_counts.join(validation_counts)
104
+ table = table.join(test_counts)
105
+ table[label_name] = table.index
106
+ total_row = {label_name: "total",
107
+ "train": len(train.index),
108
+ "validation": len(validation.index),
109
+ "test": len(test.index)}
110
+ table = table.append(total_row, ignore_index=True)
111
+ table = table[[label_name, "train", "validation", "test"]] # reorder columns
112
+ print(table.to_markdown(index=False))
113
+
114
+
115
+ save_splits_to_jsonl("")
116
+
117
+ print_split_table_multi_label({"train": train, "validation": validation, "test": test}, clause_topics)
118
+ print_split_table_single_label(train, validation, test, "unfairness_level")
test.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe0c1f60d997211c6955e99d6ed8aa2f424d1da90d0db7026009de487ba9c87d
3
+ size 1546605
train.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85572547217470cd955952b3081ccf66968eca5e18d5bee273ffa4677eeb4c49
3
+ size 7092520
validation.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:127c1edcc8aa66b05eec523564518249da52f0a41364512eb3d6321a5c9f7644
3
+ size 620888