Commit ·
f334992
1
Parent(s): ff08b3a
Delete imdb
Browse files
imdb
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
import csv
|
| 2 |
-
import datasets
|
| 3 |
-
from datasets.tasks import TextClassification
|
| 4 |
-
|
| 5 |
-
_TRAIN_DOWNLOAD_URL = "https://huggingface.co/datasets/linxinyuan/imdb/resolve/main/train.csv"
|
| 6 |
-
_TEST_DOWNLOAD_URL = "https://huggingface.co/datasets/linxinyuan/imdb/resolve/main/test.csv"
|
| 7 |
-
|
| 8 |
-
class imdb(datasets.GeneratorBasedBuilder):
|
| 9 |
-
def _info(self):
|
| 10 |
-
return datasets.DatasetInfo(
|
| 11 |
-
description="imdb",
|
| 12 |
-
features=datasets.Features(
|
| 13 |
-
{
|
| 14 |
-
"text": datasets.Value("string"),
|
| 15 |
-
"label": datasets.features.ClassLabel(names=['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']),
|
| 16 |
-
}
|
| 17 |
-
),
|
| 18 |
-
task_templates=[TextClassification(text_column="text", label_column="label")],
|
| 19 |
-
)
|
| 20 |
-
|
| 21 |
-
def _split_generators(self, dl_manager):
|
| 22 |
-
train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URL)
|
| 23 |
-
test_path = dl_manager.download_and_extract(_TEST_DOWNLOAD_URL)
|
| 24 |
-
return [
|
| 25 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
|
| 26 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
|
| 27 |
-
]
|
| 28 |
-
|
| 29 |
-
def _generate_examples(self, filepath):
|
| 30 |
-
with open(filepath, encoding="utf-8") as csv_file:
|
| 31 |
-
csv_reader = csv.reader(csv_file, delimiter="\t")
|
| 32 |
-
for id_, row in enumerate(csv_reader):
|
| 33 |
-
yield id_, {"text": row[1], "label": (int)(row[0])}
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|