import datasets from datasets import DatasetBuilder, DatasetInfo import pandas as pd class TMDataset(datasets.GeneratorBasedBuilder): def __init__(self): self.downloads = [ "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_1.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_10.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_11.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_12.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_13.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_2.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_3.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_4.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_5.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_6.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_7.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_8.parquet", "https://huggingface.co/datasets/Locutusque/TM-DATA/resolve/main/combined_datasets_batch_9.parquet", ] VERSION = datasets.Version("1.0.0") def _info(self): features = datasets.Features({ "text": datasets.Value("string"), }) return datasets.DatasetInfo( description="Combination of text completion datasets", features=features, supervised_keys=None ) def _split_generators(self, dl_manager): data_dir = dl_manager.download_and_extract(self.downloads) return [ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_dir}) ] def _generate_examples(self, filepath): for file in filepath: df = pd.read_parquet(file) for idx, row in df.iterrows(): yield idx, { "text": row["text"], }