Convert to parquet (loading scripts are no longer supported)

#1
by davanstrien HF Staff - opened
README.md CHANGED
@@ -3,15 +3,14 @@ annotations_creators:
3
  - expert-generated
4
  - machine-generated
5
  language:
6
- - 'en'
7
  language_creators:
8
  - found
9
- paperswithcode_id: null
10
  license:
11
  - cc-by-sa-4.0
12
  multilinguality:
13
  - monolingual
14
- pretty_name: 'Corpus of Late Modern English Texts v3.1'
15
  size_categories:
16
  - n<1K
17
  source_datasets:
@@ -22,6 +21,183 @@ task_categories:
22
  task_ids:
23
  - multi-label-classification
24
  - masked-language-modeling
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  ---
26
  # Dataset Card for clmet_3_1
27
 
 
3
  - expert-generated
4
  - machine-generated
5
  language:
6
+ - en
7
  language_creators:
8
  - found
 
9
  license:
10
  - cc-by-sa-4.0
11
  multilinguality:
12
  - monolingual
13
+ pretty_name: Corpus of Late Modern English Texts v3.1
14
  size_categories:
15
  - n<1K
16
  source_datasets:
 
21
  task_ids:
22
  - multi-label-classification
23
  - masked-language-modeling
24
+ dataset_info:
25
+ - config_name: class
26
+ features:
27
+ - name: id
28
+ dtype: string
29
+ - name: period
30
+ dtype: string
31
+ - name: genre
32
+ dtype: string
33
+ - name: subgenre
34
+ dtype: string
35
+ - name: decade
36
+ dtype: string
37
+ - name: quarter_cent
38
+ dtype: string
39
+ - name: title
40
+ dtype: string
41
+ - name: notes
42
+ dtype: string
43
+ - name: comments
44
+ dtype: string
45
+ - name: author
46
+ dtype: string
47
+ - name: year
48
+ dtype: string
49
+ - name: text
50
+ list: string
51
+ - name: pos_tags
52
+ list:
53
+ class_label:
54
+ names:
55
+ '0': ADJ
56
+ '1': ADV
57
+ '2': ART
58
+ '3': CONJ
59
+ '4': INTJ
60
+ '5': PREP
61
+ '6': PRON
62
+ '7': PUNC
63
+ '8': SUBST
64
+ '9': SYM
65
+ '10': UNC
66
+ '11': VERB
67
+ '12': QUOT
68
+ splits:
69
+ - name: train
70
+ num_bytes: 641829326
71
+ num_examples: 333
72
+ download_size: 641860629
73
+ dataset_size: 641829326
74
+ - config_name: plain
75
+ features:
76
+ - name: id
77
+ dtype: string
78
+ - name: period
79
+ dtype: string
80
+ - name: genre
81
+ dtype: string
82
+ - name: subgenre
83
+ dtype: string
84
+ - name: decade
85
+ dtype: string
86
+ - name: quarter_cent
87
+ dtype: string
88
+ - name: title
89
+ dtype: string
90
+ - name: notes
91
+ dtype: string
92
+ - name: comments
93
+ dtype: string
94
+ - name: author
95
+ dtype: string
96
+ - name: year
97
+ dtype: string
98
+ - name: text
99
+ dtype: string
100
+ splits:
101
+ - name: train
102
+ num_bytes: 198791975
103
+ num_examples: 333
104
+ download_size: 115599939
105
+ dataset_size: 198791975
106
+ - config_name: pos
107
+ features:
108
+ - name: id
109
+ dtype: string
110
+ - name: period
111
+ dtype: string
112
+ - name: genre
113
+ dtype: string
114
+ - name: subgenre
115
+ dtype: string
116
+ - name: decade
117
+ dtype: string
118
+ - name: quarter_cent
119
+ dtype: string
120
+ - name: title
121
+ dtype: string
122
+ - name: notes
123
+ dtype: string
124
+ - name: comments
125
+ dtype: string
126
+ - name: author
127
+ dtype: string
128
+ - name: year
129
+ dtype: string
130
+ - name: text
131
+ list: string
132
+ - name: pos_tags
133
+ list:
134
+ class_label:
135
+ names:
136
+ '0': CC
137
+ '1': CD
138
+ '2': DT
139
+ '3': EX
140
+ '4': FW
141
+ '5': IN
142
+ '6': JJ
143
+ '7': JJR
144
+ '8': JJS
145
+ '9': MD
146
+ '10': NN
147
+ '11': NNS
148
+ '12': NP
149
+ '13': NPS
150
+ '14': PDT
151
+ '15': POS
152
+ '16': PP
153
+ '17': PP$
154
+ '18': RB
155
+ '19': RBR
156
+ '20': RBS
157
+ '21': RP
158
+ '22': SENT
159
+ '23': SYM
160
+ '24': TO
161
+ '25': UH
162
+ '26': VB
163
+ '27': VBD
164
+ '28': VBG
165
+ '29': VBN
166
+ '30': VBZ
167
+ '31': VBP
168
+ '32': WDT
169
+ '33': WP
170
+ '34': WP$
171
+ '35': WRB
172
+ '36': XX0
173
+ '37': CURR
174
+ '38': PUN
175
+ '39': LQUO
176
+ '40': RQUO
177
+ '41': BRL
178
+ '42': BRR
179
+ '43': LS
180
+ '44': ':'
181
+ '45': $
182
+ splits:
183
+ - name: train
184
+ num_bytes: 641829326
185
+ num_examples: 333
186
+ download_size: 641861564
187
+ dataset_size: 641829326
188
+ configs:
189
+ - config_name: class
190
+ data_files:
191
+ - split: train
192
+ path: class/train-*
193
+ - config_name: plain
194
+ data_files:
195
+ - split: train
196
+ path: plain/train-*
197
+ - config_name: pos
198
+ data_files:
199
+ - split: train
200
+ path: pos/train-*
201
  ---
202
  # Dataset Card for clmet_3_1
203
 
class/train-00000-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8307a12b4469e550c3d7251ecae5435fba6afcb6e627dc1b7bb8638eb6dc565a
3
+ size 373832000
class/train-00001-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20cea284640a18c206486fd81fb5f18f6f9ce2173ad89bf19a90a975773d7c2b
3
+ size 268028629
clmet_3_1.py DELETED
@@ -1,292 +0,0 @@
1
- # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- """The Corpus of Late Modern English Texts, version 3.1 (CLMET3.1) has been created by Hendrik De Smet,
15
- Susanne Flach, Hans-Jürgen Diller and Jukka Tyrkkö, as an offshoot of a bigger project developing a database
16
- of text descriptors (Diller, De Smet & Tyrkkö 2011). CLMET3.1 is a principled collection of public domain
17
- texts drawn from various online archiving projects. """
18
-
19
- import os
20
- import xml.etree.ElementTree as ET
21
- import datasets
22
- from bs4 import BeautifulSoup
23
-
24
-
25
- _CITATION = """@article{de2015corpus,
26
- title={Corpus of Late Modern English texts (version 3.1)},
27
- author={De Smet, Hendrik and Flach, Susanne and Tyrkk{\"o}, Jukka and Diller, Hans-J{\"u}rgen},
28
- year={2015}
29
- }
30
- """
31
-
32
- _DESCRIPTION = """The Corpus of Late Modern English Texts, version 3.1 (CLMET3.1) has been created by Hendrik De Smet,
33
- Susanne Flach, Hans-Jürgen Diller and Jukka Tyrkkö, as an offshoot of a bigger project developing a database of text
34
- descriptors (Diller, De Smet & Tyrkkö 2011). CLMET3.1 is a principled collection of public domain texts drawn from
35
- various online archiving projects. This dataset can be used for part-of-speech tagging, NER and text classification
36
- """
37
-
38
- _HOMEPAGE = "http://fedora.clarin-d.uni-saarland.de/clmet/clmet.html"
39
-
40
- _LICENSE = "Creative Commons Attribution Non Commercial Share Alike 4.0 International"
41
-
42
- _DATASETNAME = "clmet"
43
-
44
- _URLS = {
45
- _DATASETNAME: "http://fedora.clarin-d.uni-saarland.de/clmet/clmet3_1.zip",
46
- }
47
-
48
- _POS_LIST = [
49
- "CC",
50
- "CD",
51
- "DT",
52
- "EX",
53
- "FW",
54
- "IN",
55
- "JJ",
56
- "JJR",
57
- "JJS",
58
- "MD",
59
- "NN",
60
- "NNS",
61
- "NP",
62
- "NPS",
63
- "PDT",
64
- "POS",
65
- "PP",
66
- "PP$",
67
- "RB",
68
- "RBR",
69
- "RBS",
70
- "RP",
71
- "SENT",
72
- "SYM",
73
- "TO",
74
- "UH",
75
- "VB",
76
- "VBD",
77
- "VBG",
78
- "VBN",
79
- "VBZ",
80
- "VBP",
81
- "WDT",
82
- "WP",
83
- "WP$",
84
- "WRB",
85
- "XX0",
86
- "CURR",
87
- "PUN",
88
- "LQUO",
89
- "RQUO",
90
- "BRL",
91
- "BRR",
92
- "LS",
93
- ]
94
- _POS_LOOKUP = {tag: idx for idx, tag in enumerate(_POS_LIST)}
95
- _CLASS_LIST = [
96
- "ADJ",
97
- "ADV",
98
- "ART",
99
- "CONJ",
100
- "INTJ",
101
- "PREP",
102
- "PRON",
103
- "PUNC",
104
- "SUBST",
105
- "SYM",
106
- "UNC",
107
- "VERB",
108
- "QUOT"
109
- ]
110
- _CLASS_LOOKUP = {tag: idx for idx, tag in enumerate(_CLASS_LIST)}
111
- logger = datasets.utils.logging.get_logger(__name__)
112
-
113
-
114
- class CLMET_3_1(datasets.GeneratorBasedBuilder):
115
- """"""
116
-
117
- VERSION = datasets.Version("3.1.0")
118
-
119
- BUILDER_CONFIGS = [
120
- datasets.BuilderConfig(
121
- name="plain",
122
- version=VERSION,
123
- description="This format contains text as single string and the classifications",
124
- ),
125
- datasets.BuilderConfig(
126
- name="class",
127
- version=VERSION,
128
- description="This format contains the text as a list of tokens, annotated according to the simplified Oxford wordclass tags",
129
- ),
130
- datasets.BuilderConfig(
131
- name="pos",
132
- version=VERSION,
133
- description="This format contains the text as a list of tokens, annotated according to the Penn Treebank POS tags",
134
- ),
135
- ]
136
-
137
- DEFAULT_CONFIG_NAME = "plain"
138
-
139
- def _info(self):
140
- if self.config.name == "plain":
141
- features = datasets.Features(
142
- {
143
- "text": datasets.Value("string"),
144
- "genre": datasets.Value("string"),
145
- "subgenre": datasets.Value("string"),
146
- "year": datasets.Value("string"),
147
- "quarter_cent": datasets.Value("string"),
148
- "decade": datasets.Value("string"),
149
- "title": datasets.Value("string"),
150
- "author": datasets.Value("string"),
151
- "notes": datasets.Value("string"),
152
- "comments": datasets.Value("string"),
153
- "period": datasets.Value("string"),
154
- "id": datasets.Value("string"),
155
- }
156
- )
157
- elif self.config.name == "class":
158
- logger.warn(f"CLASS tags are as follows: {_CLASS_LIST}")
159
- features = datasets.Features(
160
- {
161
- "text": datasets.Sequence(datasets.Value("string")),
162
- "pos_tags": datasets.Sequence(datasets.Value("int32")),
163
- "genre": datasets.Value("string"),
164
- "subgenre": datasets.Value("string"),
165
- "year": datasets.Value("string"),
166
- "quarter_cent": datasets.Value("string"),
167
- "decade": datasets.Value("string"),
168
- "title": datasets.Value("string"),
169
- "author": datasets.Value("string"),
170
- "notes": datasets.Value("string"),
171
- "comments": datasets.Value("string"),
172
- "period": datasets.Value("string"),
173
- "id": datasets.Value("string"),
174
- }
175
- )
176
- elif self.config.name == "pos":
177
- logger.warn(f"POS tags are as follows: {_POS_LIST}")
178
- features = datasets.Features(
179
- {
180
- "text": datasets.Sequence(datasets.Value("string")),
181
- "pos_tags": datasets.Sequence(datasets.Value("int32")),
182
- "genre": datasets.Value("string"),
183
- "subgenre": datasets.Value("string"),
184
- "year": datasets.Value("string"),
185
- "quarter_cent": datasets.Value("string"),
186
- "decade": datasets.Value("string"),
187
- "title": datasets.Value("string"),
188
- "author": datasets.Value("string"),
189
- "notes": datasets.Value("string"),
190
- "comments": datasets.Value("string"),
191
- "period": datasets.Value("string"),
192
- "id": datasets.Value("string"),
193
- }
194
- )
195
- return datasets.DatasetInfo(
196
- description=_DESCRIPTION,
197
- features=features,
198
- homepage=_HOMEPAGE,
199
- license=_LICENSE,
200
- citation=_CITATION,
201
- )
202
-
203
- def _split_generators(self, dl_manager):
204
- urls = _URLS[_DATASETNAME]
205
- data_dir = dl_manager.download_and_extract(urls)
206
- data_dir = os.path.join(data_dir, "clmet", "corpus", "txt")
207
- return [
208
- datasets.SplitGenerator(
209
- name=datasets.Split.TRAIN,
210
- # These kwargs will be passed to _generate_examples
211
- gen_kwargs={
212
- "data_dir": data_dir,
213
- "split": "train",
214
- },
215
- ),
216
- ]
217
-
218
- def parse_pos_text(self, content_parts, pos_type):
219
- tokens = []
220
- pos_tags = []
221
- unknown_tag = False
222
- malformed_token = False
223
- for content_part in content_parts:
224
- text = content_part.text.strip()
225
- for text_part in text.split():
226
- try:
227
- token, pos_tag = text_part.split("_")
228
- pos_tag = pos_tag.replace("\n", "").strip().upper()
229
- if pos_type == "pos":
230
- pos_tag_idx = _POS_LOOKUP.get(pos_tag,-1)
231
- else:
232
- pos_tag_idx = _CLASS_LOOKUP.get(pos_tag,-1)
233
- if pos_tag_idx==-1:
234
- unknown_tag = True
235
- tokens.append(token)
236
- pos_tags.append(pos_tag_idx)
237
- except Exception as e:
238
- malformed_token = True
239
- return tokens, pos_tags, unknown_tag, malformed_token
240
-
241
- def parse_file(self, file, pos_type):
242
- with open(file, "r", encoding="utf-8") as fp:
243
- soup = BeautifulSoup(fp, features="html.parser")
244
- id = soup.id.text
245
- period = soup.period.text
246
- quarter_cent = soup.quartcent.text
247
- decade = soup.decade.text
248
- year = soup.year.text
249
- genre = soup.genre.text
250
- subgenre = soup.subgenre.text
251
- title = soup.title.text
252
- notes = soup.notes.text
253
- comments = soup.comments.text
254
- author = soup.author.text
255
- data_point = {
256
- "id": id,
257
- "period": period,
258
- "genre": genre,
259
- "subgenre": subgenre,
260
- "decade": decade,
261
- "quarter_cent": quarter_cent,
262
- "title": title,
263
- "notes": notes if notes else "",
264
- "comments": comments if comments else "",
265
- "author": author,
266
- "year": year,
267
- }
268
- content_parts = soup.find("text").find_all("p")
269
-
270
- if pos_type in ["pos", "class"]:
271
- content = self.parse_pos_text(content_parts, pos_type)
272
- if content[2]:
273
- logger.warn(f'Unknown tag in sample {id}')
274
- if content[3]:
275
- logger.warn(f'Malformed token in sample {id}')
276
- data_point["text"] = content[0]
277
- data_point["pos_tags"] = content[1]
278
- else:
279
- content = []
280
- for content_part in content_parts:
281
- content.append(content_part.text)
282
- content = " ".join(content)
283
- data_point["text"] = content
284
- return (id, data_point)
285
-
286
- def _generate_examples(self, data_dir, split):
287
- final_data_dir = os.path.join(data_dir, self.config.name)
288
- for file in os.listdir(final_data_dir):
289
- id, data = self.parse_file(
290
- os.path.join(final_data_dir, file), self.config.name
291
- )
292
- yield id, data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plain/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0c039c2b148919907c45d38531337f979f6eea0ea4e3c087a33608c9edcbf99
3
+ size 115599939
pos/train-00000-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:030d98a96488b346e412f946b5a4bd578d04d99f130d703e48f47792743e4e26
3
+ size 373832391
pos/train-00001-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:440d1becaf78f3af85a449c69dd7e3aa54f5fbf65ac75be95a32a1ded19be392
3
+ size 268029173