Julian von der Goltz commited on
Commit
728e117
1 Parent(s): b2d6e1c

Use arrow instead of jsonl

Browse files
.gitignore CHANGED
@@ -1 +1,2 @@
1
- .idea
 
 
1
+ .idea
2
+ /src/tmp/
data/{train.jsonl → train/data-00000-of-00002.arrow} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ca34d7e2b504fe40131a8bd658eac0b4e61678a5db17479567d9cc70a92d3aa2
3
- size 720222877
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4f204beb10890b715b4cd82d3f14ed28d31fac0aa42f6dd3d929e8af9b695e1
3
+ size 377355400
data/train/data-00001-of-00002.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:537dd53cfdf036ffd64d9d0dfb475a6bca75d59d48b6dea829588fd12fca96be
3
+ size 238560632
data/train/dataset_info.json ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "json",
3
+ "citation": "",
4
+ "config_name": "default",
5
+ "dataset_name": "json",
6
+ "dataset_size": 615370214,
7
+ "description": "",
8
+ "download_checksums": {
9
+ "/home/julian/repos/dbnl.org-dutch-public-domain-collection/src/tmp/train.jsonl": {
10
+ "num_bytes": 720222877,
11
+ "checksum": null
12
+ }
13
+ },
14
+ "download_size": 720222877,
15
+ "features": {
16
+ "meta": {
17
+ "ti_id": {
18
+ "dtype": "string",
19
+ "_type": "Value"
20
+ },
21
+ "titel": {
22
+ "dtype": "string",
23
+ "_type": "Value"
24
+ },
25
+ "vols": {
26
+ "dtype": "string",
27
+ "_type": "Value"
28
+ },
29
+ "jaar": {
30
+ "dtype": "string",
31
+ "_type": "Value"
32
+ },
33
+ "druk": {
34
+ "dtype": "string",
35
+ "_type": "Value"
36
+ },
37
+ "ppn_o": {
38
+ "dtype": "string",
39
+ "_type": "Value"
40
+ },
41
+ "bibliotheek": {
42
+ "dtype": "string",
43
+ "_type": "Value"
44
+ },
45
+ "categorie": {
46
+ "dtype": "int64",
47
+ "_type": "Value"
48
+ },
49
+ "_jaar": {
50
+ "dtype": "int64",
51
+ "_type": "Value"
52
+ },
53
+ "pers_id": {
54
+ "dtype": "string",
55
+ "_type": "Value"
56
+ },
57
+ "voornaam": {
58
+ "dtype": "string",
59
+ "_type": "Value"
60
+ },
61
+ "voorvoegsel": {
62
+ "dtype": "string",
63
+ "_type": "Value"
64
+ },
65
+ "achternaam": {
66
+ "dtype": "string",
67
+ "_type": "Value"
68
+ },
69
+ "jaar_geboren": {
70
+ "dtype": "string",
71
+ "_type": "Value"
72
+ },
73
+ "jaar_overlijden": {
74
+ "dtype": "string",
75
+ "_type": "Value"
76
+ },
77
+ "geb_datum": {
78
+ "dtype": "string",
79
+ "_type": "Value"
80
+ },
81
+ "overl_datum": {
82
+ "dtype": "string",
83
+ "_type": "Value"
84
+ },
85
+ "geb_plaats": {
86
+ "dtype": "string",
87
+ "_type": "Value"
88
+ },
89
+ "overl_plaats": {
90
+ "dtype": "string",
91
+ "_type": "Value"
92
+ },
93
+ "geb_plaats_code": {
94
+ "dtype": "string",
95
+ "_type": "Value"
96
+ },
97
+ "geb_land_code": {
98
+ "dtype": "string",
99
+ "_type": "Value"
100
+ },
101
+ "overl_plaats_code": {
102
+ "dtype": "string",
103
+ "_type": "Value"
104
+ },
105
+ "overl_land_code": {
106
+ "dtype": "string",
107
+ "_type": "Value"
108
+ },
109
+ "vrouw": {
110
+ "dtype": "int64",
111
+ "_type": "Value"
112
+ },
113
+ "url": {
114
+ "dtype": "string",
115
+ "_type": "Value"
116
+ },
117
+ "text_url": {
118
+ "dtype": "string",
119
+ "_type": "Value"
120
+ },
121
+ "maand": {
122
+ "dtype": "string",
123
+ "_type": "Value"
124
+ },
125
+ "genre": {
126
+ "dtype": "string",
127
+ "_type": "Value"
128
+ },
129
+ "Unnamed: 28": {
130
+ "dtype": "string",
131
+ "_type": "Value"
132
+ },
133
+ "revision_date": {
134
+ "dtype": "timestamp[s]",
135
+ "_type": "Value"
136
+ },
137
+ "edition": {
138
+ "dtype": "string",
139
+ "_type": "Value"
140
+ },
141
+ "language": {
142
+ "dtype": "string",
143
+ "_type": "Value"
144
+ },
145
+ "chapter": {
146
+ "dtype": "int64",
147
+ "_type": "Value"
148
+ },
149
+ "section": {
150
+ "dtype": "int64",
151
+ "_type": "Value"
152
+ }
153
+ },
154
+ "text": {
155
+ "dtype": "string",
156
+ "_type": "Value"
157
+ },
158
+ "id": {
159
+ "dtype": "string",
160
+ "_type": "Value"
161
+ }
162
+ },
163
+ "homepage": "",
164
+ "license": "",
165
+ "size_in_bytes": 1335593091,
166
+ "splits": {
167
+ "train": {
168
+ "name": "train",
169
+ "num_bytes": 615370214,
170
+ "num_examples": 206086,
171
+ "shard_lengths": [
172
+ 149790,
173
+ 56296
174
+ ],
175
+ "dataset_name": "json"
176
+ }
177
+ },
178
+ "version": {
179
+ "version_str": "0.0.0",
180
+ "major": 0,
181
+ "minor": 0,
182
+ "patch": 0
183
+ }
184
+ }
data/train/state.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00002.arrow"
5
+ },
6
+ {
7
+ "filename": "data-00001-of-00002.arrow"
8
+ }
9
+ ],
10
+ "_fingerprint": "645cec5bd749f9c8",
11
+ "_format_columns": null,
12
+ "_format_kwargs": {},
13
+ "_format_type": null,
14
+ "_output_all_columns": false,
15
+ "_split": "train"
16
+ }
data/{val.jsonl → validation/data-00000-of-00001.arrow} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:57e2329bcc71867d030daaf040a0d97603409aba1de71256fde0d6eb10845f8e
3
- size 15156646
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c1a9c417cc3d133f29399e79dd9996984c134bc8a1139745515573b81a17fcd
3
+ size 12270544
data/validation/dataset_info.json ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "json",
3
+ "citation": "",
4
+ "config_name": "default",
5
+ "dataset_name": "json",
6
+ "dataset_size": 12249133,
7
+ "description": "",
8
+ "download_checksums": {
9
+ "/home/julian/repos/dbnl.org-dutch-public-domain-collection/src/tmp/val.jsonl": {
10
+ "num_bytes": 15156646,
11
+ "checksum": null
12
+ }
13
+ },
14
+ "download_size": 15156646,
15
+ "features": {
16
+ "meta": {
17
+ "ti_id": {
18
+ "dtype": "string",
19
+ "_type": "Value"
20
+ },
21
+ "titel": {
22
+ "dtype": "string",
23
+ "_type": "Value"
24
+ },
25
+ "vols": {
26
+ "dtype": "string",
27
+ "_type": "Value"
28
+ },
29
+ "jaar": {
30
+ "dtype": "string",
31
+ "_type": "Value"
32
+ },
33
+ "druk": {
34
+ "dtype": "string",
35
+ "_type": "Value"
36
+ },
37
+ "ppn_o": {
38
+ "dtype": "string",
39
+ "_type": "Value"
40
+ },
41
+ "bibliotheek": {
42
+ "dtype": "string",
43
+ "_type": "Value"
44
+ },
45
+ "categorie": {
46
+ "dtype": "int64",
47
+ "_type": "Value"
48
+ },
49
+ "_jaar": {
50
+ "dtype": "int64",
51
+ "_type": "Value"
52
+ },
53
+ "pers_id": {
54
+ "dtype": "string",
55
+ "_type": "Value"
56
+ },
57
+ "voornaam": {
58
+ "dtype": "string",
59
+ "_type": "Value"
60
+ },
61
+ "voorvoegsel": {
62
+ "dtype": "string",
63
+ "_type": "Value"
64
+ },
65
+ "achternaam": {
66
+ "dtype": "string",
67
+ "_type": "Value"
68
+ },
69
+ "jaar_geboren": {
70
+ "dtype": "string",
71
+ "_type": "Value"
72
+ },
73
+ "jaar_overlijden": {
74
+ "dtype": "string",
75
+ "_type": "Value"
76
+ },
77
+ "geb_datum": {
78
+ "dtype": "string",
79
+ "_type": "Value"
80
+ },
81
+ "overl_datum": {
82
+ "dtype": "string",
83
+ "_type": "Value"
84
+ },
85
+ "geb_plaats": {
86
+ "dtype": "string",
87
+ "_type": "Value"
88
+ },
89
+ "overl_plaats": {
90
+ "dtype": "string",
91
+ "_type": "Value"
92
+ },
93
+ "geb_plaats_code": {
94
+ "dtype": "string",
95
+ "_type": "Value"
96
+ },
97
+ "geb_land_code": {
98
+ "dtype": "string",
99
+ "_type": "Value"
100
+ },
101
+ "overl_plaats_code": {
102
+ "dtype": "string",
103
+ "_type": "Value"
104
+ },
105
+ "overl_land_code": {
106
+ "dtype": "string",
107
+ "_type": "Value"
108
+ },
109
+ "vrouw": {
110
+ "dtype": "int64",
111
+ "_type": "Value"
112
+ },
113
+ "url": {
114
+ "dtype": "string",
115
+ "_type": "Value"
116
+ },
117
+ "text_url": {
118
+ "dtype": "string",
119
+ "_type": "Value"
120
+ },
121
+ "maand": {
122
+ "dtype": "string",
123
+ "_type": "Value"
124
+ },
125
+ "genre": {
126
+ "dtype": "string",
127
+ "_type": "Value"
128
+ },
129
+ "Unnamed: 28": {
130
+ "dtype": "string",
131
+ "_type": "Value"
132
+ },
133
+ "revision_date": {
134
+ "dtype": "timestamp[s]",
135
+ "_type": "Value"
136
+ },
137
+ "edition": {
138
+ "dtype": "string",
139
+ "_type": "Value"
140
+ },
141
+ "language": {
142
+ "dtype": "string",
143
+ "_type": "Value"
144
+ },
145
+ "chapter": {
146
+ "dtype": "int64",
147
+ "_type": "Value"
148
+ },
149
+ "section": {
150
+ "dtype": "int64",
151
+ "_type": "Value"
152
+ }
153
+ },
154
+ "text": {
155
+ "dtype": "string",
156
+ "_type": "Value"
157
+ },
158
+ "id": {
159
+ "dtype": "string",
160
+ "_type": "Value"
161
+ }
162
+ },
163
+ "homepage": "",
164
+ "license": "",
165
+ "size_in_bytes": 27405779,
166
+ "splits": {
167
+ "validation": {
168
+ "name": "validation",
169
+ "num_bytes": 12249133,
170
+ "num_examples": 5768,
171
+ "dataset_name": "json"
172
+ }
173
+ },
174
+ "version": {
175
+ "version_str": "0.0.0",
176
+ "major": 0,
177
+ "minor": 0,
178
+ "patch": 0
179
+ }
180
+ }
data/validation/state.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00001.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "cda191967f8bb0a5",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_output_all_columns": false,
12
+ "_split": "validation"
13
+ }
src/create_nl_dataset.py CHANGED
@@ -3,6 +3,7 @@ import math
3
  import zipfile
4
 
5
  import bs4
 
6
  import dateutil.parser
7
  import pandas as pd
8
  from tqdm import tqdm
@@ -70,7 +71,7 @@ def yield_file_contents(zip_path, train_df, val_df):
70
 
71
 
72
  if __name__ == '__main__':
73
- train_fraction = 0.95
74
  metadata_path = '../origin/titels_pd.csv'
75
  meta_df = pd.read_csv(metadata_path, header=1, sep='|')
76
 
@@ -80,10 +81,13 @@ if __name__ == '__main__':
80
  train_df = meta_df.iloc[:num_train]
81
  val_df = meta_df.iloc[num_train:]
82
 
83
- with open('../data/train.jsonl', 'w') as train_file:
84
- with open('../data/val.jsonl', 'w') as val_file:
85
  for item, split in tqdm(yield_file_contents('../origin/xml_pd.zip', train_df, val_df)):
86
  if split == 'train':
87
  train_file.write('{}\n'.format(json.dumps(item)))
88
  if split == 'validation':
89
  val_file.write('{}\n'.format(json.dumps(item)))
 
 
 
 
3
  import zipfile
4
 
5
  import bs4
6
+ import datasets
7
  import dateutil.parser
8
  import pandas as pd
9
  from tqdm import tqdm
 
71
 
72
 
73
  if __name__ == '__main__':
74
+ train_fraction = 0.90
75
  metadata_path = '../origin/titels_pd.csv'
76
  meta_df = pd.read_csv(metadata_path, header=1, sep='|')
77
 
 
81
  train_df = meta_df.iloc[:num_train]
82
  val_df = meta_df.iloc[num_train:]
83
 
84
+ with open('tmp/train.jsonl', 'w') as train_file:
85
+ with open('tmp/val.jsonl', 'w') as val_file:
86
  for item, split in tqdm(yield_file_contents('../origin/xml_pd.zip', train_df, val_df)):
87
  if split == 'train':
88
  train_file.write('{}\n'.format(json.dumps(item)))
89
  if split == 'validation':
90
  val_file.write('{}\n'.format(json.dumps(item)))
91
+
92
+ datasets.Dataset.from_json('tmp/train.jsonl', split='train').save_to_disk('../data/train')
93
+ datasets.Dataset.from_json('tmp/val.jsonl', split='validation').save_to_disk('../data/validation')