init
Browse files- THUCNewsTitle.py +49 -0
- dataset_info.json +1 -0
- thuc_news_title-test.arrow +3 -0
- thuc_news_title-train.arrow +3 -0
- thuc_news_title-validation.arrow +3 -0
THUCNewsTitle.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
|
3 |
+
import datasets
|
4 |
+
|
5 |
+
|
6 |
+
_TRAIN_DOWNLOAD_URL = "https://drive.google.com/u/0/uc?id=1xnicHROZsgtxKodf8sZiRiXoWJ7fpQt2&export=download"
|
7 |
+
_DEV_DOWNLOAD_URL = "https://drive.google.com/u/0/uc?id=1dxhCfB7h4YZMvmPwoh3VTqW6z0AESgjo&export=download"
|
8 |
+
_TEST_DOWNLOAD_URL = "https://drive.google.com/u/0/uc?id=1EHiQl2i2LX6xuGYRhdlk_uj2eF79sr8r&export=download"
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
class THUCNewsTitle(datasets.GeneratorBasedBuilder):
|
13 |
+
|
14 |
+
|
15 |
+
def _info(self):
|
16 |
+
return datasets.DatasetInfo(
|
17 |
+
description=None,
|
18 |
+
features=datasets.Features(
|
19 |
+
{
|
20 |
+
"text": datasets.Value("string"),
|
21 |
+
"label": datasets.features.ClassLabel(names=['education', 'entertainment', 'fashion', 'finance', 'game', 'politic', 'society', 'sport', 'stock', 'technology']),
|
22 |
+
}
|
23 |
+
|
24 |
+
),
|
25 |
+
homepage=None,
|
26 |
+
citation=None,
|
27 |
+
)
|
28 |
+
|
29 |
+
def _split_generators(self, dl_manager):
|
30 |
+
train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URL)
|
31 |
+
dev_path = dl_manager.download_and_extract(_DEV_DOWNLOAD_URL)
|
32 |
+
test_path = dl_manager.download_and_extract(_TEST_DOWNLOAD_URL)
|
33 |
+
return [
|
34 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
|
35 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": dev_path}),
|
36 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
|
37 |
+
]
|
38 |
+
|
39 |
+
def _generate_examples(self, filepath):
|
40 |
+
with open(filepath, encoding="utf-8") as csv_file:
|
41 |
+
csv_reader = csv.reader(
|
42 |
+
csv_file, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True
|
43 |
+
)
|
44 |
+
for id_, row in enumerate(csv_reader):
|
45 |
+
if id_ == 0:
|
46 |
+
continue
|
47 |
+
label, text = row
|
48 |
+
label = int(label)
|
49 |
+
yield id_, {"text": text, "label": label}
|
dataset_info.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"description": "", "citation": "", "homepage": "", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 10, "names": ["education", "entertainment", "fashion", "finance", "game", "politic", "society", "sport", "stock", "technology"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "thuc_news_title", "config_name": "default", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3243019, "num_examples": 50000, "dataset_name": "thuc_news_title"}, "validation": {"name": "validation", "num_bytes": 324390, "num_examples": 5000, "dataset_name": "thuc_news_title"}, "test": {"name": "test", "num_bytes": 648546, "num_examples": 10000, "dataset_name": "thuc_news_title"}}, "download_checksums": {"https://drive.google.com/u/0/uc?id=1xnicHROZsgtxKodf8sZiRiXoWJ7fpQt2&export=download": {"num_bytes": 2843021, "checksum": "d1ebcc61385bbe2fc5aa63f80e9895343582d2b8fd4a88771a721e85e1fe0aea"}, "https://drive.google.com/u/0/uc?id=1dxhCfB7h4YZMvmPwoh3VTqW6z0AESgjo&export=download": {"num_bytes": 284400, "checksum": "b07fde52b6097f266eaec4499f51aa08da25f89a94671004c4c8239a6ee7c79f"}, "https://drive.google.com/u/0/uc?id=1EHiQl2i2LX6xuGYRhdlk_uj2eF79sr8r&export=download": {"num_bytes": 568556, "checksum": "234203489d9ecbb66402bd8874bff2a5f40aeaf9cd7478264ec7da3495947b9b"}}, "download_size": 3695977, "post_processing_size": null, "dataset_size": 4215955, "size_in_bytes": 7911932}
|
thuc_news_title-test.arrow
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0c99f6d4087cf6d7ce4e577880d76ff25fac57a3da9a6bb6841435998d7a4439
|
3 |
+
size 649304
|
thuc_news_title-train.arrow
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c6cd07e0c1e88510272d73c8b9def1397e9ccc4ee9c31e755b5a83c10c162092
|
3 |
+
size 3244640
|
thuc_news_title-validation.arrow
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2290162cfeeacaa798dbee6e8353baf9f9a8146afb4630044d2b7c6c47fadd1a
|
3 |
+
size 325152
|