Datasets:

Languages:
Dutch
Size Categories:
1K<n<10K
ArXiv:
Tags:
lam
License:
davanstrien HF staff commited on
Commit
ace4c13
1 Parent(s): 742d093

draft loading script

Browse files
Files changed (2) hide show
  1. README.md +109 -0
  2. unsilence_voc.py +232 -0
README.md CHANGED
@@ -1,3 +1,112 @@
1
  ---
2
  license: cc-by-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
1
  ---
2
  license: cc-by-4.0
3
+ dataset_info:
4
+ features:
5
+ - name: tokens
6
+ sequence: string
7
+ - name: NE-MAIN
8
+ sequence:
9
+ class_label:
10
+ names:
11
+ '0': B-Organization
12
+ '1': B-Organization,B-Place
13
+ '2': B-Organization,I-Person
14
+ '3': B-Organization,I-Place
15
+ '4': B-Person
16
+ '5': B-Person,B-Place
17
+ '6': B-Person,I-Place
18
+ '7': B-Place
19
+ '8': I-Organization
20
+ '9': I-Organization,B-Place
21
+ '10': I-Organization,I-Person
22
+ '11': I-Organization,I-Person,B-Place
23
+ '12': I-Organization,I-Person,I-Place
24
+ '13': I-Organization,I-Place
25
+ '14': I-Person
26
+ '15': I-Person,B-Place
27
+ '16': I-Person,I-Place
28
+ '17': I-Place
29
+ '18': O
30
+ - name: NE-PER-NAME
31
+ sequence:
32
+ class_label:
33
+ names:
34
+ '0': I-ProperName
35
+ '1': O
36
+ '2': B-ProperName
37
+ '3': ''
38
+ - name: NE-PER-GENDER
39
+ sequence:
40
+ class_label:
41
+ names:
42
+ '0': B-Group
43
+ '1': B-Man
44
+ '2': B-Man,B-Unspecified
45
+ '3': B-Man,I-Woman
46
+ '4': B-Unspecified
47
+ '5': B-Unspecified,I-Woman
48
+ '6': B-Woman
49
+ '7': I-Group
50
+ '8': I-Man
51
+ '9': I-Man,I-Unspecified
52
+ '10': I-Man,I-Woman
53
+ '11': I-Unspecified
54
+ '12': I-Unspecified,I-Woman
55
+ '13': I-Woman
56
+ '14': NE-PER-GENDER
57
+ '15': O
58
+ - name: NE-PER-LEGAL-STATUS
59
+ sequence:
60
+ class_label:
61
+ names:
62
+ '0': B-Enslaved
63
+ '1': B-Freed
64
+ '2': B-Unspecified
65
+ '3': I-Enslaved
66
+ '4': I-Freed
67
+ '5': I-Unspecified
68
+ '6': NE-PER-LEGAL-STATUS
69
+ '7': O
70
+ - name: NE-PER-ROLE
71
+ sequence:
72
+ class_label:
73
+ names:
74
+ '0': B-Acting_Notary
75
+ '1': B-Beneficiary
76
+ '2': B-Notary
77
+ '3': B-Other
78
+ '4': B-Testator
79
+ '5': B-Testator_Beneficiary
80
+ '6': B-Witness
81
+ '7': I-Acting_Notary
82
+ '8': I-Beneficiary
83
+ '9': I-Beneficiary,B-Other
84
+ '10': I-Beneficiary,I-Other
85
+ '11': I-Notary
86
+ '12': I-Other
87
+ '13': I-Testator
88
+ '14': I-Testator_Beneficiary
89
+ '15': I-Witness
90
+ '16': NE-PER-ROLE
91
+ '17': O
92
+ - name: NE-ORG-BENEFICIARY
93
+ sequence:
94
+ class_label:
95
+ names:
96
+ '0': B-No
97
+ '1': B-Yes
98
+ '2': I-No
99
+ '3': I-Yes
100
+ '4': NE-ORG-BENEFICIARY
101
+ '5': O
102
+ - name: MISC
103
+ dtype: string
104
+ - name: document_id
105
+ dtype: string
106
+ splits:
107
+ - name: train
108
+ num_bytes: 31436367
109
+ num_examples: 2199
110
+ download_size: 12669993
111
+ dataset_size: 31436367
112
  ---
unsilence_voc.py ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 HuggingFace Datasets Authors.
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
+ # Lint as: python3
17
+ """UnSilenceVOC dataset"""
18
+
19
+
20
+ import datasets
21
+ import re
22
+ from datasets import ClassLabel, Sequence, Value
23
+
24
+
25
+ _CITATION = """\
26
+ TODO
27
+ """
28
+
29
+ _DESCRIPTION = """\
30
+ TODO
31
+ """
32
+
33
+ NE_MAIN_LABELS = [
34
+ "B-Organization",
35
+ "B-Organization,B-Place",
36
+ "B-Organization,I-Person",
37
+ "B-Organization,I-Place",
38
+ "B-Person",
39
+ "B-Person,B-Place",
40
+ "B-Person,I-Place",
41
+ "B-Place",
42
+ "I-Organization",
43
+ "I-Organization,B-Place",
44
+ "I-Organization,I-Person",
45
+ "I-Organization,I-Person,B-Place",
46
+ "I-Organization,I-Person,I-Place",
47
+ "I-Organization,I-Place",
48
+ "I-Person",
49
+ "I-Person,B-Place",
50
+ "I-Person,I-Place",
51
+ "I-Place",
52
+ "O",
53
+ ]
54
+
55
+ NE_PER_NAME = ["I-ProperName", "O", "B-ProperName", ""]
56
+ NE_PER_GENDER = [
57
+ "B-Group",
58
+ "B-Man",
59
+ "B-Man,B-Unspecified",
60
+ "B-Man,I-Woman",
61
+ "B-Unspecified",
62
+ "B-Unspecified,I-Woman",
63
+ "B-Woman",
64
+ "I-Group",
65
+ "I-Man",
66
+ "I-Man,I-Unspecified",
67
+ "I-Man,I-Woman",
68
+ "I-Unspecified",
69
+ "I-Unspecified,I-Woman",
70
+ "I-Woman",
71
+ "NE-PER-GENDER",
72
+ "O",
73
+ ]
74
+
75
+ NE_PER_LEGAL_STATUS = [
76
+ "B-Enslaved",
77
+ "B-Freed",
78
+ "B-Unspecified",
79
+ "I-Enslaved",
80
+ "I-Freed",
81
+ "I-Unspecified",
82
+ "NE-PER-LEGAL-STATUS",
83
+ "O",
84
+ ]
85
+
86
+ NE_PER_ROLE = [
87
+ "B-Acting_Notary",
88
+ "B-Beneficiary",
89
+ "B-Notary",
90
+ "B-Other",
91
+ "B-Testator",
92
+ "B-Testator_Beneficiary",
93
+ "B-Witness",
94
+ "I-Acting_Notary",
95
+ "I-Beneficiary",
96
+ "I-Beneficiary,B-Other",
97
+ "I-Beneficiary,I-Other",
98
+ "I-Notary",
99
+ "I-Other",
100
+ "I-Testator",
101
+ "I-Testator_Beneficiary",
102
+ "I-Witness",
103
+ "NE-PER-ROLE",
104
+ "O",
105
+ ]
106
+
107
+ NE_ORG_BENEFICIARY = [
108
+ "B-No",
109
+ "B-Yes",
110
+ "I-No",
111
+ "I-Yes",
112
+ "NE-ORG-BENEFICIARY",
113
+ "O",
114
+ ]
115
+
116
+ _BASE_URL = (
117
+ "https://raw.githubusercontent.com/budh333/UnSilence_VOC/main/processed_data"
118
+ )
119
+
120
+ _URLS = {
121
+ "train": f"{_BASE_URL}/train-nl.tsv",
122
+ "test": f"{_BASE_URL}/test-nl.tsv",
123
+ "dev": f"{_BASE_URL}/dev-nl.tsv",
124
+ }
125
+
126
+
127
+ class UnSilenceVOC(datasets.GeneratorBasedBuilder):
128
+ """UnSilence VOC dataset."""
129
+
130
+ def _info(self):
131
+ return datasets.DatasetInfo(
132
+ description=_DESCRIPTION,
133
+ features=datasets.Features(
134
+ {
135
+ "tokens": Sequence(datasets.Value("string")),
136
+ "NE-MAIN": Sequence(
137
+ ClassLabel(names=NE_MAIN_LABELS),
138
+ ),
139
+ "NE-PER-NAME": Sequence(ClassLabel(names=NE_PER_NAME)),
140
+ "NE-PER-GENDER": Sequence(ClassLabel(names=NE_PER_GENDER)),
141
+ "NE-PER-LEGAL-STATUS": Sequence(
142
+ ClassLabel(names=NE_PER_LEGAL_STATUS)
143
+ ),
144
+ "NE-PER-ROLE": Sequence(ClassLabel(names=NE_PER_ROLE)),
145
+ "NE-ORG-BENEFICIARY": Sequence(
146
+ ClassLabel(names=NE_ORG_BENEFICIARY)
147
+ ),
148
+ "MISC": Value("string"),
149
+ "document_id": datasets.Value("string"),
150
+ }
151
+ ),
152
+ homepage="TODO",
153
+ citation=_CITATION,
154
+ )
155
+
156
+ def _split_generators(self, dl_manager):
157
+ """Returns SplitGenerators."""
158
+ downloaded_files = dl_manager.download_and_extract(_URLS)
159
+ return [
160
+ datasets.SplitGenerator(
161
+ name=datasets.Split.TRAIN,
162
+ gen_kwargs={"filepath": downloaded_files["train"]},
163
+ )
164
+ ]
165
+
166
+ def _generate_examples(self, filepath):
167
+ document_id_re = re.compile(r"# document_path = ..(\/.*.txt)")
168
+ with open(filepath, encoding="utf-8") as f:
169
+ guid = 0
170
+ tokens = []
171
+ NE_MAIN_LABELS = []
172
+ NE_PER_NAME = []
173
+ NE_PER_GENDER = []
174
+ NE_PER_LEGAL_STATUS = []
175
+ NE_PER_ROLE = []
176
+ NE_ORG_BENEFICIARY = []
177
+ MISC = []
178
+
179
+ for line in f:
180
+ if line.startswith("TOKEN"):
181
+ continue
182
+ if line.startswith("#") or line.startswith("\t"):
183
+ document_id_match = re.search(document_id_re, line)
184
+ if document_id_match:
185
+ document_id = document_id_match.groups(0)[0]
186
+
187
+ if not tokens:
188
+ continue
189
+ yield guid, {
190
+ "tokens": tokens,
191
+ "NE-MAIN": NE_MAIN_LABELS,
192
+ "NE-PER-NAME": NE_PER_NAME,
193
+ "NE-PER-GENDER": NE_PER_GENDER,
194
+ "NE-PER-LEGAL-STATUS": NE_PER_LEGAL_STATUS,
195
+ "NE-PER-ROLE": NE_PER_ROLE,
196
+ "NE-ORG-BENEFICIARY": NE_ORG_BENEFICIARY,
197
+ "MISC": MISC,
198
+ "document_id": document_id,
199
+ }
200
+ guid += 1
201
+ tokens = []
202
+ NE_MAIN_LABELS = []
203
+ NE_PER_NAME = []
204
+ NE_PER_GENDER = []
205
+ NE_PER_LEGAL_STATUS = []
206
+ NE_PER_ROLE = []
207
+ NE_ORG_BENEFICIARY = []
208
+ MISC = []
209
+ else:
210
+ # tokens are tab separated
211
+ splits = line.split("\t")
212
+ tokens.append(splits[0])
213
+ NE_MAIN_LABELS.append(splits[1])
214
+ NE_PER_NAME.append(splits[2])
215
+ NE_PER_GENDER.append(splits[3])
216
+ NE_PER_LEGAL_STATUS.append(splits[4])
217
+ NE_PER_ROLE.append(splits[5])
218
+ NE_ORG_BENEFICIARY.append(splits[6])
219
+ MISC.append(splits[-1].replace("\n", ""))
220
+
221
+ # last example
222
+ yield guid, {
223
+ "tokens": tokens,
224
+ "NE-MAIN": NE_MAIN_LABELS,
225
+ "NE-PER-NAME": NE_PER_NAME,
226
+ "NE-PER-GENDER": NE_PER_GENDER,
227
+ "NE-PER-LEGAL-STATUS": NE_PER_LEGAL_STATUS,
228
+ "NE-PER-ROLE": NE_PER_ROLE,
229
+ "NE-ORG-BENEFICIARY": NE_ORG_BENEFICIARY,
230
+ "MISC": MISC,
231
+ "document_id": "document_id",
232
+ }