|
|
import datasets |
|
|
import json |
|
|
|
|
|
class SchemapileConfig(datasets.BuilderConfig): |
|
|
def __init__(self, **kwargs): |
|
|
super().__init__(**kwargs) |
|
|
|
|
|
class Schemapile(datasets.GeneratorBasedBuilder): |
|
|
BUILDER_CONFIGS = [ |
|
|
SchemapileConfig(name="default", version=datasets.Version("1.0.0"), description="Schemapile dataset"), |
|
|
] |
|
|
|
|
|
def _info(self): |
|
|
return datasets.DatasetInfo( |
|
|
description="Schemapile dataset", |
|
|
features=datasets.Features({ |
|
|
"INFO": { |
|
|
"URL": datasets.Value("string"), |
|
|
"LICENSE": datasets.Value("string"), |
|
|
"PERMISSIVE": datasets.Value("bool"), |
|
|
"ID": datasets.Value("string"), |
|
|
"FILENAME": datasets.Value("string"), |
|
|
}, |
|
|
"LICENSE": datasets.Value("string"), |
|
|
"PERMISSIVE": datasets.Value("bool"), |
|
|
"TABLES": datasets.Sequence({ |
|
|
"TABLE_NAME": datasets.Value("string"), |
|
|
"COLUMNS": datasets.Sequence({ |
|
|
"NAME": datasets.Value("string"), |
|
|
"TYPE": datasets.Value("string"), |
|
|
"NULLABLE": datasets.Value("bool"), |
|
|
"UNIQUE": datasets.Value("bool"), |
|
|
"DEFAULT": datasets.Value("string"), |
|
|
"CHECKS": datasets.Sequence(datasets.Value("string")), |
|
|
"IS_PRIMARY": datasets.Value("bool"), |
|
|
"IS_INDEX": datasets.Value("bool"), |
|
|
"VALUES": datasets.Sequence(datasets.Value("string")), |
|
|
}), |
|
|
"PRIMARY_KEYS": datasets.Sequence(datasets.Value("string")), |
|
|
"FOREIGN_KEYS": datasets.Sequence({ |
|
|
"COLUMNS": datasets.Sequence(datasets.Value("string")), |
|
|
"FOREIGN_TABLE": datasets.Value("string"), |
|
|
"REFERRED_COLUMNS": datasets.Sequence(datasets.Value("string")), |
|
|
"ON_DELETE": datasets.Value("string"), |
|
|
"ON_UPDATE": datasets.Value("string"), |
|
|
}), |
|
|
"CHECKS": datasets.Sequence(datasets.Value("string")), |
|
|
"INDEXES": datasets.Sequence(datasets.Value("string")), |
|
|
}), |
|
|
}), |
|
|
supervised_keys=None, |
|
|
) |
|
|
|
|
|
def _split_generators(self, dl_manager): |
|
|
data_files = getattr(self.config, "data_files", None) |
|
|
data_path = dl_manager.download_and_extract(data_files or "data.jsonl") |
|
|
|
|
|
return [ |
|
|
datasets.SplitGenerator( |
|
|
name="full", |
|
|
gen_kwargs={"filepath": data_path}, |
|
|
) |
|
|
] |
|
|
|
|
|
def _generate_examples(self, filepath): |
|
|
with open(filepath, encoding="utf-8") as f: |
|
|
for idx, line in enumerate(f): |
|
|
data = json.loads(line) |
|
|
yield idx, data |
|
|
|