Commit
·
833fc3a
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +173 -0
- dataset_infos.json +1 -0
- dummy/annotated/1.0.0/dummy_data.zip +3 -0
- dummy/raw/1.0.0/dummy_data.zip +3 -0
- id_clickbait.py +149 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- expert-generated
|
4 |
+
language_creators:
|
5 |
+
- expert-generated
|
6 |
+
languages:
|
7 |
+
- id
|
8 |
+
licenses:
|
9 |
+
- cc-by-4-0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- 10k>n>100k
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- text-classification
|
18 |
+
task_ids:
|
19 |
+
- fact-checking
|
20 |
+
---
|
21 |
+
|
22 |
+
# Dataset Card for Indonesian Clickbait Headlines
|
23 |
+
|
24 |
+
## Table of Contents
|
25 |
+
|
26 |
+
- [Dataset Description](#dataset-description)
|
27 |
+
- [Dataset Summary](#dataset-summary)
|
28 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
29 |
+
- [Languages](#languages)
|
30 |
+
- [Dataset Structure](#dataset-structure)
|
31 |
+
- [Data Instances](#data-instances)
|
32 |
+
- [Data Fields](#data-instances)
|
33 |
+
- [Data Splits](#data-instances)
|
34 |
+
- [Dataset Creation](#dataset-creation)
|
35 |
+
- [Curation Rationale](#curation-rationale)
|
36 |
+
- [Source Data](#source-data)
|
37 |
+
- [Annotations](#annotations)
|
38 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
39 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
40 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
41 |
+
- [Discussion of Biases](#discussion-of-biases)
|
42 |
+
- [Other Known Limitations](#other-known-limitations)
|
43 |
+
- [Additional Information](#additional-information)
|
44 |
+
- [Dataset Curators](#dataset-curators)
|
45 |
+
- [Licensing Information](#licensing-information)
|
46 |
+
- [Citation Information](#citation-information)
|
47 |
+
|
48 |
+
## Dataset Description
|
49 |
+
|
50 |
+
- **Homepage:** [CLICK-ID: A Novel Dataset for Indonesian Clickbait Headlines](https://www.sciencedirect.com/science/article/pii/S2352340920311252#!)
|
51 |
+
- **Repository:** [CLICK-ID: A Novel Dataset for Indonesian Clickbait Headlines](http://dx.doi.org/10.17632/k42j7x2kpn.1)
|
52 |
+
- **Paper:** [CLICK-ID: A Novel Dataset for Indonesian Clickbait Headlines](https://www.sciencedirect.com/science/article/pii/S2352340920311252#!)
|
53 |
+
- **Leaderboard:**
|
54 |
+
- **Point of Contact:** [Andika William](mailto:[email protected]), [Yunita Sari](mailto:[email protected])
|
55 |
+
|
56 |
+
### Dataset Summary
|
57 |
+
|
58 |
+
The CLICK-ID dataset is a collection of Indonesian news headlines that was collected from 12 local online news
|
59 |
+
publishers; detikNews, Fimela, Kapanlagi, Kompas, Liputan6, Okezone, Posmetro-Medan, Republika, Sindonews, Tempo,
|
60 |
+
Tribunnews, and Wowkeren. This dataset is comprised of mainly two parts; (i) 46,119 raw article data, and (ii)
|
61 |
+
15,000 clickbait annotated sample headlines. Annotation was conducted with 3 annotator examining each headline.
|
62 |
+
Judgment were based only on the headline. The majority then is considered as the ground truth. In the annotated
|
63 |
+
sample, our annotation shows 6,290 clickbait and 8,710 non-clickbait.
|
64 |
+
|
65 |
+
### Supported Tasks and Leaderboards
|
66 |
+
|
67 |
+
[More Information Needed]
|
68 |
+
|
69 |
+
### Languages
|
70 |
+
Indonesian
|
71 |
+
|
72 |
+
## Dataset Structure
|
73 |
+
### Data Instances
|
74 |
+
An example of the annotated article:
|
75 |
+
```
|
76 |
+
{
|
77 |
+
'id': '100',
|
78 |
+
'label': 1,
|
79 |
+
'title': "SAH! Ini Daftar Nama Menteri Kabinet Jokowi - Ma'ruf Amin"
|
80 |
+
}
|
81 |
+
>
|
82 |
+
```
|
83 |
+
|
84 |
+
### Data Fields
|
85 |
+
|
86 |
+
#### Annotated
|
87 |
+
- `id`: id of the sample
|
88 |
+
- `title`: the title of the news article
|
89 |
+
- `label`: the label of the article, either non-clickbait or clickbait
|
90 |
+
|
91 |
+
#### Raw
|
92 |
+
- `id`: id of the sample
|
93 |
+
- `title`: the title of the news article
|
94 |
+
- `source`: the name of the publisher/newspaper
|
95 |
+
- `date`: date
|
96 |
+
- `category`: the category of the article
|
97 |
+
- `sub-category`: the sub category of the article
|
98 |
+
- `content`: the content of the article
|
99 |
+
- `url`: the url of the article
|
100 |
+
|
101 |
+
### Data Splits
|
102 |
+
|
103 |
+
The dataset contains train set.
|
104 |
+
|
105 |
+
## Dataset Creation
|
106 |
+
|
107 |
+
### Curation Rationale
|
108 |
+
|
109 |
+
[More Information Needed]
|
110 |
+
|
111 |
+
### Source Data
|
112 |
+
|
113 |
+
#### Initial Data Collection and Normalization
|
114 |
+
|
115 |
+
[More Information Needed]
|
116 |
+
|
117 |
+
#### Who are the source language producers?
|
118 |
+
|
119 |
+
[More Information Needed]
|
120 |
+
|
121 |
+
### Annotations
|
122 |
+
|
123 |
+
#### Annotation process
|
124 |
+
|
125 |
+
[More Information Needed]
|
126 |
+
|
127 |
+
#### Who are the annotators?
|
128 |
+
[More Information Needed]
|
129 |
+
|
130 |
+
### Personal and Sensitive Information
|
131 |
+
|
132 |
+
[More Information Needed]
|
133 |
+
|
134 |
+
## Considerations for Using the Data
|
135 |
+
|
136 |
+
### Social Impact of Dataset
|
137 |
+
|
138 |
+
[More Information Needed]
|
139 |
+
|
140 |
+
### Discussion of Biases
|
141 |
+
|
142 |
+
[More Information Needed]
|
143 |
+
|
144 |
+
### Other Known Limitations
|
145 |
+
|
146 |
+
[More Information Needed]
|
147 |
+
|
148 |
+
## Additional Information
|
149 |
+
|
150 |
+
### Dataset Curators
|
151 |
+
|
152 |
+
[More Information Needed]
|
153 |
+
|
154 |
+
### Licensing Information
|
155 |
+
|
156 |
+
Creative Commons Attribution 4.0 International license
|
157 |
+
|
158 |
+
### Citation Information
|
159 |
+
```
|
160 |
+
@article{WILLIAM2020106231,
|
161 |
+
title = "CLICK-ID: A novel dataset for Indonesian clickbait headlines",
|
162 |
+
journal = "Data in Brief",
|
163 |
+
volume = "32",
|
164 |
+
pages = "106231",
|
165 |
+
year = "2020",
|
166 |
+
issn = "2352-3409",
|
167 |
+
doi = "https://doi.org/10.1016/j.dib.2020.106231",
|
168 |
+
url = "http://www.sciencedirect.com/science/article/pii/S2352340920311252",
|
169 |
+
author = "Andika William and Yunita Sari",
|
170 |
+
keywords = "Indonesian, Natural Language Processing, News articles, Clickbait, Text-classification",
|
171 |
+
abstract = "News analysis is a popular task in Natural Language Processing (NLP). In particular, the problem of clickbait in news analysis has gained attention in recent years [1, 2]. However, the majority of the tasks has been focused on English news, in which there is already a rich representative resource. For other languages, such as Indonesian, there is still a lack of resource for clickbait tasks. Therefore, we introduce the CLICK-ID dataset of Indonesian news headlines extracted from 12 Indonesian online news publishers. It is comprised of 15,000 annotated headlines with clickbait and non-clickbait labels. Using the CLICK-ID dataset, we then developed an Indonesian clickbait classification model achieving favourable performance. We believe that this corpus will be useful for replicable experiments in clickbait detection or other experiments in NLP areas."
|
172 |
+
}
|
173 |
+
```
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"annotated": {"description": "The CLICK-ID dataset is a collection of Indonesian news headlines that was collected from 12 local online news\npublishers; detikNews, Fimela, Kapanlagi, Kompas, Liputan6, Okezone, Posmetro-Medan, Republika, Sindonews, Tempo,\nTribunnews, and Wowkeren. This dataset is comprised of mainly two parts; (i) 46,119 raw article data, and (ii)\n15,000 clickbait annotated sample headlines. Annotation was conducted with 3 annotator examining each headline.\nJudgment were based only on the headline. The majority then is considered as the ground truth. In the annotated\nsample, our annotation shows 6,290 clickbait and 8,710 non-clickbait.\n", "citation": "@inproceedings{id_clickbait,\n author = {Andika William, Yunita Sari},\n title = {CLICK-ID: A Novel Dataset for Indonesian Clickbait Headlines},\n year = {2020},\n url = {http://dx.doi.org/10.17632/k42j7x2kpn.1},\n}\n", "homepage": "https://github.com/feryandi/Dataset-Artikel", "license": "Creative Commons Attribution 4.0 International license", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["non-clickbait", "clickbait"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "id_clickbait", "config_name": "annotated", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1268698, "num_examples": 15000, "dataset_name": "id_clickbait"}}, "download_checksums": {"https://md-datasets-cache-zipfiles-prod.s3.eu-west-1.amazonaws.com/k42j7x2kpn-1.zip": {"num_bytes": 150769127, "checksum": "42a2607d38422630e100165eb1bf120b16191798993cd5d04bfedf768bb2bd50"}}, "download_size": 150769127, "post_processing_size": null, "dataset_size": 1268698, "size_in_bytes": 152037825}, "raw": {"description": "The CLICK-ID dataset is a collection of Indonesian news headlines that was collected from 12 local online news\npublishers; detikNews, Fimela, Kapanlagi, Kompas, Liputan6, Okezone, Posmetro-Medan, Republika, Sindonews, Tempo,\nTribunnews, and Wowkeren. This dataset is comprised of mainly two parts; (i) 46,119 raw article data, and (ii)\n15,000 clickbait annotated sample headlines. Annotation was conducted with 3 annotator examining each headline.\nJudgment were based only on the headline. The majority then is considered as the ground truth. In the annotated\nsample, our annotation shows 6,290 clickbait and 8,710 non-clickbait.\n", "citation": "@inproceedings{id_clickbait,\n author = {Andika William, Yunita Sari},\n title = {CLICK-ID: A Novel Dataset for Indonesian Clickbait Headlines},\n year = {2020},\n url = {http://dx.doi.org/10.17632/k42j7x2kpn.1},\n}\n", "homepage": "https://github.com/feryandi/Dataset-Artikel", "license": "Creative Commons Attribution 4.0 International license", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "source": {"dtype": "string", "id": null, "_type": "Value"}, "date": {"dtype": "string", "id": null, "_type": "Value"}, "category": {"dtype": "string", "id": null, "_type": "Value"}, "sub-category": {"dtype": "string", "id": null, "_type": "Value"}, "content": {"dtype": "string", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "id_clickbait", "config_name": "raw", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 81669386, "num_examples": 38655, "dataset_name": "id_clickbait"}}, "download_checksums": {"https://md-datasets-cache-zipfiles-prod.s3.eu-west-1.amazonaws.com/k42j7x2kpn-1.zip": {"num_bytes": 150769127, "checksum": "42a2607d38422630e100165eb1bf120b16191798993cd5d04bfedf768bb2bd50"}}, "download_size": 150769127, "post_processing_size": null, "dataset_size": 81669386, "size_in_bytes": 232438513}}
|
dummy/annotated/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:56a65db08d1184582b852ddc7bbe9e0633c161c3b91a323b82d473e39777ed47
|
3 |
+
size 1539
|
dummy/raw/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c7d740b86299744fa6eabfe8ab7233b7e9d4aa4e751b1e93e86e1b78dfb551ec
|
3 |
+
size 2301
|
id_clickbait.py
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""CLICK-ID: A Novel Dataset for Indonesian Clickbait Headlines"""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import csv
|
20 |
+
import glob
|
21 |
+
import logging
|
22 |
+
import os
|
23 |
+
|
24 |
+
import datasets
|
25 |
+
|
26 |
+
|
27 |
+
_CITATION = """\
|
28 |
+
@inproceedings{id_clickbait,
|
29 |
+
author = {Andika William, Yunita Sari},
|
30 |
+
title = {CLICK-ID: A Novel Dataset for Indonesian Clickbait Headlines},
|
31 |
+
year = {2020},
|
32 |
+
url = {http://dx.doi.org/10.17632/k42j7x2kpn.1},
|
33 |
+
}
|
34 |
+
"""
|
35 |
+
|
36 |
+
_DESCRIPTION = """\
|
37 |
+
The CLICK-ID dataset is a collection of Indonesian news headlines that was collected from 12 local online news
|
38 |
+
publishers; detikNews, Fimela, Kapanlagi, Kompas, Liputan6, Okezone, Posmetro-Medan, Republika, Sindonews, Tempo,
|
39 |
+
Tribunnews, and Wowkeren. This dataset is comprised of mainly two parts; (i) 46,119 raw article data, and (ii)
|
40 |
+
15,000 clickbait annotated sample headlines. Annotation was conducted with 3 annotator examining each headline.
|
41 |
+
Judgment were based only on the headline. The majority then is considered as the ground truth. In the annotated
|
42 |
+
sample, our annotation shows 6,290 clickbait and 8,710 non-clickbait.
|
43 |
+
"""
|
44 |
+
|
45 |
+
_HOMEPAGE = "https://github.com/feryandi/Dataset-Artikel"
|
46 |
+
|
47 |
+
_LICENSE = "Creative Commons Attribution 4.0 International license"
|
48 |
+
|
49 |
+
_URLs = ["https://md-datasets-cache-zipfiles-prod.s3.eu-west-1.amazonaws.com/k42j7x2kpn-1.zip"]
|
50 |
+
|
51 |
+
|
52 |
+
class IdClickbaitConfig(datasets.BuilderConfig):
|
53 |
+
"""BuilderConfig for IdClickbait"""
|
54 |
+
|
55 |
+
def __init__(self, label_classes=None, path=None, **kwargs):
|
56 |
+
"""BuilderConfig for IdClickbait.
|
57 |
+
Args:
|
58 |
+
**kwargs: keyword arguments forwarded to super.
|
59 |
+
"""
|
60 |
+
super(IdClickbaitConfig, self).__init__(**kwargs)
|
61 |
+
self.label_classes = label_classes
|
62 |
+
self.path = path
|
63 |
+
|
64 |
+
|
65 |
+
class IdClickbait(datasets.GeneratorBasedBuilder):
|
66 |
+
VERSION = datasets.Version("1.0.0")
|
67 |
+
|
68 |
+
BUILDER_CONFIGS = [
|
69 |
+
IdClickbaitConfig(
|
70 |
+
name="annotated",
|
71 |
+
version=VERSION,
|
72 |
+
description="Annotated clickbait dataset",
|
73 |
+
label_classes=["non-clickbait", "clickbait"],
|
74 |
+
path="annotated/csv",
|
75 |
+
),
|
76 |
+
IdClickbaitConfig(name="raw", version=VERSION, description="Raw dataset", path="raw/csv"),
|
77 |
+
]
|
78 |
+
|
79 |
+
BUILDER_CONFIG_CLASS = IdClickbaitConfig
|
80 |
+
|
81 |
+
def _info(self):
|
82 |
+
if self.config.name == "annotated":
|
83 |
+
features = datasets.Features(
|
84 |
+
{
|
85 |
+
"id": datasets.Value("string"),
|
86 |
+
"title": datasets.Value("string"),
|
87 |
+
"label": datasets.features.ClassLabel(names=self.config.label_classes),
|
88 |
+
}
|
89 |
+
)
|
90 |
+
else:
|
91 |
+
features = datasets.Features(
|
92 |
+
{
|
93 |
+
"id": datasets.Value("string"),
|
94 |
+
"title": datasets.Value("string"),
|
95 |
+
"source": datasets.Value("string"),
|
96 |
+
"date": datasets.Value("string"),
|
97 |
+
"category": datasets.Value("string"),
|
98 |
+
"sub-category": datasets.Value("string"),
|
99 |
+
"content": datasets.Value("string"),
|
100 |
+
"url": datasets.Value("string"),
|
101 |
+
}
|
102 |
+
)
|
103 |
+
return datasets.DatasetInfo(
|
104 |
+
description=_DESCRIPTION,
|
105 |
+
features=features,
|
106 |
+
supervised_keys=None,
|
107 |
+
homepage=_HOMEPAGE,
|
108 |
+
license=_LICENSE,
|
109 |
+
citation=_CITATION,
|
110 |
+
)
|
111 |
+
|
112 |
+
def _split_generators(self, dl_manager):
|
113 |
+
my_urls = _URLs[0]
|
114 |
+
data_dir = dl_manager.download_and_extract(my_urls)
|
115 |
+
return [
|
116 |
+
datasets.SplitGenerator(
|
117 |
+
name=datasets.Split.TRAIN,
|
118 |
+
gen_kwargs={
|
119 |
+
"article_dir": os.path.join(data_dir, self.config.path),
|
120 |
+
"split": "train",
|
121 |
+
},
|
122 |
+
)
|
123 |
+
]
|
124 |
+
|
125 |
+
def _generate_examples(self, article_dir, split):
|
126 |
+
logging.info("⏳ Generating %s examples from = %s", split, article_dir)
|
127 |
+
id = 0
|
128 |
+
for path in sorted(glob.glob(os.path.join(article_dir, "**/*.csv"), recursive=True)):
|
129 |
+
with open(path, encoding="utf-8-sig", newline="") as f:
|
130 |
+
reader = csv.DictReader(f)
|
131 |
+
for row in reader:
|
132 |
+
if self.config.name == "annotated":
|
133 |
+
yield id, {
|
134 |
+
"id": str(id),
|
135 |
+
"title": row["title"],
|
136 |
+
"label": row["label"],
|
137 |
+
}
|
138 |
+
else:
|
139 |
+
yield id, {
|
140 |
+
"id": str(id),
|
141 |
+
"title": row["title"],
|
142 |
+
"source": row["source"],
|
143 |
+
"date": row["date"],
|
144 |
+
"category": row["category"],
|
145 |
+
"sub-category": row["sub-category"],
|
146 |
+
"content": row["content"],
|
147 |
+
"url": row["url"],
|
148 |
+
}
|
149 |
+
id += 1
|