Varun Hemachandran
commited on
Commit
·
2ad713c
1
Parent(s):
980236d
Fix dataset format for Hugging Face viewer
Browse files- convert_to_jsonl.py +45 -0
- dataset_dict.json +1 -1
- dataset_infos.json +6 -6
- default-fixed/train.jsonl +0 -0
convert_to_jsonl.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
import json
|
3 |
+
import os
|
4 |
+
|
5 |
+
# Load the existing train.json file
|
6 |
+
with open('default/train.json', 'r') as f:
|
7 |
+
data = json.load(f)
|
8 |
+
|
9 |
+
# Create the directory for the new format
|
10 |
+
os.makedirs('default-fixed', exist_ok=True)
|
11 |
+
|
12 |
+
# Convert to the correct format (JSONL - one JSON object per line)
|
13 |
+
with open('default-fixed/train.jsonl', 'w') as f:
|
14 |
+
for i in range(len(data['file_name'])):
|
15 |
+
example = {
|
16 |
+
'file_name': data['file_name'][i],
|
17 |
+
'file_path': data['file_path'][i],
|
18 |
+
'file_size': data['file_size'][i],
|
19 |
+
'content_type': data['content_type'][i]
|
20 |
+
}
|
21 |
+
f.write(json.dumps(example) + '\n')
|
22 |
+
|
23 |
+
print(f"Converted {len(data['file_name'])} examples to JSONL format")
|
24 |
+
|
25 |
+
# Update the dataset_infos.json file
|
26 |
+
with open('dataset_infos.json', 'r') as f:
|
27 |
+
dataset_infos = json.load(f)
|
28 |
+
|
29 |
+
# Rename the default config to default-fixed
|
30 |
+
dataset_infos['default-fixed'] = dataset_infos.pop('default')
|
31 |
+
|
32 |
+
with open('dataset_infos.json', 'w') as f:
|
33 |
+
json.dump(dataset_infos, f, indent=2)
|
34 |
+
|
35 |
+
# Update the dataset_dict.json file
|
36 |
+
with open('dataset_dict.json', 'r') as f:
|
37 |
+
dataset_dict = json.load(f)
|
38 |
+
|
39 |
+
# Rename the default config to default-fixed
|
40 |
+
dataset_dict['default-fixed'] = dataset_dict.pop('default')
|
41 |
+
|
42 |
+
with open('dataset_dict.json', 'w') as f:
|
43 |
+
json.dump(dataset_dict, f, indent=2)
|
44 |
+
|
45 |
+
print("Updated dataset configuration files")
|
dataset_dict.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
-
"default": {
|
3 |
"splits": {
|
4 |
"train": {
|
5 |
"name": "train",
|
|
|
1 |
{
|
2 |
+
"default-fixed": {
|
3 |
"splits": {
|
4 |
"train": {
|
5 |
"name": "train",
|
dataset_infos.json
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
{
|
2 |
-
"default": {
|
3 |
"description": "JFK Document Release 2025 - Collection of declassified documents related to the assassination of President John F. Kennedy",
|
4 |
"citation": "",
|
5 |
"homepage": "https://github.com/varun-heman/jfk-files-2025",
|
6 |
"license": "cc0-1.0",
|
7 |
"features": {
|
8 |
"file_name": {
|
9 |
-
"dtype": "string",
|
10 |
"_type": "Value"
|
11 |
},
|
12 |
"file_path": {
|
13 |
-
"dtype": "string",
|
14 |
"_type": "Value"
|
15 |
},
|
16 |
"file_size": {
|
17 |
-
"dtype": "int64",
|
18 |
"_type": "Value"
|
19 |
},
|
20 |
"content_type": {
|
21 |
-
"dtype": "string",
|
22 |
"_type": "Value"
|
23 |
}
|
24 |
},
|
@@ -32,4 +32,4 @@
|
|
32 |
}
|
33 |
]
|
34 |
}
|
35 |
-
}
|
|
|
1 |
{
|
2 |
+
"default-fixed": {
|
3 |
"description": "JFK Document Release 2025 - Collection of declassified documents related to the assassination of President John F. Kennedy",
|
4 |
"citation": "",
|
5 |
"homepage": "https://github.com/varun-heman/jfk-files-2025",
|
6 |
"license": "cc0-1.0",
|
7 |
"features": {
|
8 |
"file_name": {
|
9 |
+
"dtype": "string",
|
10 |
"_type": "Value"
|
11 |
},
|
12 |
"file_path": {
|
13 |
+
"dtype": "string",
|
14 |
"_type": "Value"
|
15 |
},
|
16 |
"file_size": {
|
17 |
+
"dtype": "int64",
|
18 |
"_type": "Value"
|
19 |
},
|
20 |
"content_type": {
|
21 |
+
"dtype": "string",
|
22 |
"_type": "Value"
|
23 |
}
|
24 |
},
|
|
|
32 |
}
|
33 |
]
|
34 |
}
|
35 |
+
}
|
default-fixed/train.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|