Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
parquet
Languages:
English
Size:
< 1K
Tags:
shakespeare
License:
File size: 909 Bytes
e7e1253 70565f3 e7e1253 70565f3 e7e1253 70565f3 e7e1253 70565f3 e7e1253 |
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 31 32 |
import os
import datasets
script_path = os.path.abspath(__file__)
src_path = os.path.dirname(script_path)
root_path = os.path.dirname(src_path)
res_path = root_path+"/res"
texts = []
for name in os.listdir(res_path):
if name.endswith(".txt"):
with open(res_path+"/"+name, "r") as file:
text = file.read()
texts.append(text)
dataset = datasets.Dataset.from_dict({"text": texts})
dataset = dataset.train_test_split(train_size=None, test_size=4, shuffle=False)
train_val_dataset = dataset["train"]
train_val_dataset = train_val_dataset.train_test_split(train_size=None, test_size=2, shuffle=False)
train_dataset = train_val_dataset["train"]
val_dataset = train_val_dataset["test"]
test_dataset = dataset["test"]
dataset = datasets.DatasetDict({
"train": train_dataset,
"val": val_dataset,
"test": test_dataset
})
dataset.push_to_hub("shakespearefirstfolio")
|