Datasets:

Modalities:
Text
Formats:
json
Languages:
English
Libraries:
Datasets
pandas
License:
File size: 756 Bytes
d17161f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import json
import os
from pathlib import Path

import json5
import jsonschema
import tqdm


data_path = Path("data")
for schema_file in tqdm.tqdm(list(data_path.rglob("*.json"))):
    # Skip any directories named with .json at the end
    if not schema_file.is_file():
        continue

    try:
        schema = json5.load(open(schema_file))
    except ValueError:
        continue

    vcls = jsonschema.validators.validator_for(schema)
    try:
        vcls.check_schema(schema)
    except jsonschema.exceptions.SchemaError:
        continue

    new_schema_file = Path("valid_data", *schema_file.parts[1:])
    Path.mkdir(new_schema_file.parent, parents=True, exist_ok=True)
    json.dump(schema, open(new_schema_file, "w"), sort_keys=True, indent=2)