Datasets:
Commit
•
0261d13
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 +184 -0
- dataset_infos.json +1 -0
- dummy/kinnews_cleaned/0.0.0/dummy_data.zip +3 -0
- dummy/kinnews_raw/0.0.0/dummy_data.zip +3 -0
- dummy/kirnews_cleaned/0.0.0/dummy_data.zip +3 -0
- dummy/kirnews_raw/0.0.0/dummy_data.zip +3 -0
- kinnews_kirnews.py +151 -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,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- expert-generated
|
4 |
+
language_creators:
|
5 |
+
- found
|
6 |
+
languages:
|
7 |
+
- rn
|
8 |
+
- rw
|
9 |
+
licenses:
|
10 |
+
- mit
|
11 |
+
multilinguality:
|
12 |
+
- monolingual
|
13 |
+
size_categories:
|
14 |
+
kinnews_cleaned:
|
15 |
+
- 10K<n<100K
|
16 |
+
kinnews_raw:
|
17 |
+
- 10K<n<100K
|
18 |
+
kirnews_cleaned:
|
19 |
+
- 1K<n<10K
|
20 |
+
kirnews_raw:
|
21 |
+
- 1K<n<10K
|
22 |
+
source_datasets:
|
23 |
+
- original
|
24 |
+
task_categories:
|
25 |
+
- text-classification
|
26 |
+
task_ids:
|
27 |
+
- multi-class-classification
|
28 |
+
- topic-classification
|
29 |
+
---
|
30 |
+
# Dataset Card for kinnews_kirnews
|
31 |
+
|
32 |
+
## Table of Contents
|
33 |
+
- [Dataset Description](#dataset-description)
|
34 |
+
- [Dataset Summary](#dataset-summary)
|
35 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
36 |
+
- [Languages](#languages)
|
37 |
+
- [Dataset Structure](#dataset-structure)
|
38 |
+
- [Data Instances](#data-instances)
|
39 |
+
- [Data Fields](#data-instances)
|
40 |
+
- [Data Splits](#data-instances)
|
41 |
+
- [Dataset Creation](#dataset-creation)
|
42 |
+
- [Curation Rationale](#curation-rationale)
|
43 |
+
- [Source Data](#source-data)
|
44 |
+
- [Annotations](#annotations)
|
45 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
46 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
47 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
48 |
+
- [Discussion of Biases](#discussion-of-biases)
|
49 |
+
- [Other Known Limitations](#other-known-limitations)
|
50 |
+
- [Additional Information](#additional-information)
|
51 |
+
- [Dataset Curators](#dataset-curators)
|
52 |
+
- [Licensing Information](#licensing-information)
|
53 |
+
- [Citation Information](#citation-information)
|
54 |
+
|
55 |
+
## Dataset Description
|
56 |
+
|
57 |
+
- **Homepage:** [More Information Needed]
|
58 |
+
- **Repository:** https://github.com/Andrews2017/KINNEWS-and-KIRNEWS-Corpus
|
59 |
+
- **Paper:** [KINNEWS and KIRNEWS: Benchmarking Cross-Lingual Text Classification for Kinyarwanda and Kirundi](https://arxiv.org/abs/2010.12174)
|
60 |
+
- **Leaderboard:** NA
|
61 |
+
- **Point of Contact:** [Rubungo Andre Niyongabo1](mailto:niyongabor.andre@std.uestc.edu.cn)
|
62 |
+
|
63 |
+
### Dataset Summary
|
64 |
+
|
65 |
+
Kinyarwanda and Kirundi news classification datasets (KINNEWS and KIRNEWS,respectively), which were both collected from Rwanda and Burundi news websites and newspapers, for low-resource monolingual and cross-lingual multiclass classification tasks.
|
66 |
+
|
67 |
+
### Supported Tasks and Leaderboards
|
68 |
+
This dataset can be used for text classification of news articles in Kinyarwadi and Kirundi languages. Each news article can be classified into one of the 14 possible classes. The classes are:
|
69 |
+
|
70 |
+
- politics
|
71 |
+
- sport
|
72 |
+
- economy
|
73 |
+
- health
|
74 |
+
- entertainment
|
75 |
+
- history
|
76 |
+
- technology
|
77 |
+
- culture
|
78 |
+
- religion
|
79 |
+
- environment
|
80 |
+
- education
|
81 |
+
- relationship
|
82 |
+
|
83 |
+
|
84 |
+
### Languages
|
85 |
+
|
86 |
+
Kinyarwanda and Kirundi
|
87 |
+
|
88 |
+
## Dataset Structure
|
89 |
+
|
90 |
+
### Data Instances
|
91 |
+
|
92 |
+
Here is an example from the dataset:
|
93 |
+
|
94 |
+
| Field | Value |
|
95 |
+
| ----- | ----------- |
|
96 |
+
| label | 1 |
|
97 |
+
| kin_label/kir_label | 'inkino' |
|
98 |
+
| url | 'https://nawe.bi/Primus-Ligue-Imirwi-igiye-guhura-gute-ku-ndwi-ya-6-y-ihiganwa.html' |
|
99 |
+
| title | 'Primus Ligue\xa0: Imirwi igiye guhura gute ku ndwi ya 6 y’ihiganwa\xa0?'|
|
100 |
+
| content | ' Inkino zitegekanijwe kuruno wa gatandatu igenekerezo rya 14 Nyakanga umwaka wa 2019...'|
|
101 |
+
| en_label| 'sport'|
|
102 |
+
|
103 |
+
|
104 |
+
|
105 |
+
|
106 |
+
### Data Fields
|
107 |
+
|
108 |
+
The raw version of the data for Kinyarwanda language consists of these fields
|
109 |
+
- label: The category of the news article
|
110 |
+
- kin_label/kir_label: The associated label in Kinyarwanda/Kirundi language
|
111 |
+
- en_label: The associated label in English
|
112 |
+
- url: The URL of the news article
|
113 |
+
- title: The title of the news article
|
114 |
+
- content: The content of the news article
|
115 |
+
|
116 |
+
The cleaned version contains only the `label`, `title` and the `content` fields
|
117 |
+
|
118 |
+
|
119 |
+
### Data Splits
|
120 |
+
|
121 |
+
Lang| Train | Test |
|
122 |
+
|---| ----- | ---- |
|
123 |
+
|Kinyarwandai Raw|17014|4254|
|
124 |
+
|Kinyarwandai Clean|17014|4254|
|
125 |
+
|Kirundi Raw|3689|923|
|
126 |
+
|Kirundi Clean|3689|923|
|
127 |
+
|
128 |
+
## Dataset Creation
|
129 |
+
|
130 |
+
### Curation Rationale
|
131 |
+
|
132 |
+
[More Information Needed]
|
133 |
+
|
134 |
+
### Source Data
|
135 |
+
|
136 |
+
#### Initial Data Collection and Normalization
|
137 |
+
|
138 |
+
[More Information Needed]
|
139 |
+
|
140 |
+
#### Who are the source language producers?
|
141 |
+
|
142 |
+
[More Information Needed]
|
143 |
+
|
144 |
+
### Annotations
|
145 |
+
|
146 |
+
#### Annotation process
|
147 |
+
|
148 |
+
[More Information Needed]
|
149 |
+
|
150 |
+
#### Who are the annotators?
|
151 |
+
|
152 |
+
[More Information Needed]
|
153 |
+
|
154 |
+
### Personal and Sensitive Information
|
155 |
+
|
156 |
+
[More Information Needed]
|
157 |
+
|
158 |
+
## Considerations for Using the Data
|
159 |
+
|
160 |
+
### Social Impact of Dataset
|
161 |
+
|
162 |
+
[More Information Needed]
|
163 |
+
|
164 |
+
### Discussion of Biases
|
165 |
+
|
166 |
+
[More Information Needed]
|
167 |
+
|
168 |
+
### Other Known Limitations
|
169 |
+
|
170 |
+
[More Information Needed]
|
171 |
+
|
172 |
+
## Additional Information
|
173 |
+
|
174 |
+
### Dataset Curators
|
175 |
+
|
176 |
+
[More Information Needed]
|
177 |
+
|
178 |
+
### Licensing Information
|
179 |
+
|
180 |
+
[More Information Needed]
|
181 |
+
|
182 |
+
### Citation Information
|
183 |
+
|
184 |
+
[More Information Needed]
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"kinnews_raw": {"description": "Kinyarwanda and Kirundi news classification datasets\n", "citation": "@article{niyongabo2020kinnews,\n title={KINNEWS and KIRNEWS: Benchmarking Cross-Lingual Text Classification for Kinyarwanda and Kirundi},\n author={Niyongabo, Rubungo Andre and Qu, Hong and Kreutzer, Julia and Huang, Li},\n journal={arXiv preprint arXiv:2010.12174},\n year={2020}\n}\n", "homepage": "https://github.com/Andrews2017/KINNEWS-and-KIRNEWS-Corpus", "license": "MIT License", "features": {"label": {"num_classes": 14, "names": ["politics", "sport", "economy", "health", "entertainment", "history", "technology", "tourism", "culture", "fashion", "religion", "environment", "education", "relationship"], "names_file": null, "id": null, "_type": "ClassLabel"}, "kin_label": {"dtype": "string", "id": null, "_type": "Value"}, "en_label": {"dtype": "string", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "content": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kinnews_kirnews", "config_name": "kinnews_raw", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 38316546, "num_examples": 17014, "dataset_name": "kinnews_kirnews"}, "test": {"name": "test", "num_bytes": 11971938, "num_examples": 4254, "dataset_name": "kinnews_kirnews"}}, "download_checksums": {"https://github.com/saradhix/kinnews_kirnews/raw/master/KINNEWS.zip": {"num_bytes": 27377755, "checksum": "79397b825aa701b058aeef0f751d6ea0760bba4d4abfd989280554ce8af56869"}}, "download_size": 27377755, "post_processing_size": null, "dataset_size": 50288484, "size_in_bytes": 77666239}, "kinnews_cleaned": {"description": "Kinyarwanda and Kirundi news classification datasets\n", "citation": "@article{niyongabo2020kinnews,\n title={KINNEWS and KIRNEWS: Benchmarking Cross-Lingual Text Classification for Kinyarwanda and Kirundi},\n author={Niyongabo, Rubungo Andre and Qu, Hong and Kreutzer, Julia and Huang, Li},\n journal={arXiv preprint arXiv:2010.12174},\n year={2020}\n}\n", "homepage": "https://github.com/Andrews2017/KINNEWS-and-KIRNEWS-Corpus", "license": "MIT License", "features": {"label": {"num_classes": 14, "names": ["politics", "sport", "economy", "health", "entertainment", "history", "technology", "tourism", "culture", "fashion", "religion", "environment", "education", "relationship"], "names_file": null, "id": null, "_type": "ClassLabel"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "content": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kinnews_kirnews", "config_name": "kinnews_cleaned", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 32780382, "num_examples": 17014, "dataset_name": "kinnews_kirnews"}, "test": {"name": "test", "num_bytes": 8217453, "num_examples": 4254, "dataset_name": "kinnews_kirnews"}}, "download_checksums": {"https://github.com/saradhix/kinnews_kirnews/raw/master/KINNEWS.zip": {"num_bytes": 27377755, "checksum": "79397b825aa701b058aeef0f751d6ea0760bba4d4abfd989280554ce8af56869"}}, "download_size": 27377755, "post_processing_size": null, "dataset_size": 40997835, "size_in_bytes": 68375590}, "kirnews_raw": {"description": "Kinyarwanda and Kirundi news classification datasets\n", "citation": "@article{niyongabo2020kinnews,\n title={KINNEWS and KIRNEWS: Benchmarking Cross-Lingual Text Classification for Kinyarwanda and Kirundi},\n author={Niyongabo, Rubungo Andre and Qu, Hong and Kreutzer, Julia and Huang, Li},\n journal={arXiv preprint arXiv:2010.12174},\n year={2020}\n}\n", "homepage": "https://github.com/Andrews2017/KINNEWS-and-KIRNEWS-Corpus", "license": "MIT License", "features": {"label": {"num_classes": 14, "names": ["politics", "sport", "economy", "health", "entertainment", "history", "technology", "tourism", "culture", "fashion", "religion", "environment", "education", "relationship"], "names_file": null, "id": null, "_type": "ClassLabel"}, "kir_label": {"dtype": "string", "id": null, "_type": "Value"}, "en_label": {"dtype": "string", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "content": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kinnews_kirnews", "config_name": "kirnews_raw", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 7343223, "num_examples": 3689, "dataset_name": "kinnews_kirnews"}, "test": {"name": "test", "num_bytes": 2499189, "num_examples": 923, "dataset_name": "kinnews_kirnews"}}, "download_checksums": {"https://github.com/saradhix/kinnews_kirnews/raw/master/KIRNEWS.zip": {"num_bytes": 5186111, "checksum": "f3e7079456567ab581ff2fd0418f9fc4002b4364142a476e79e41a581607d7f2"}}, "download_size": 5186111, "post_processing_size": null, "dataset_size": 9842412, "size_in_bytes": 15028523}, "kirnews_cleaned": {"description": "Kinyarwanda and Kirundi news classification datasets\n", "citation": "@article{niyongabo2020kinnews,\n title={KINNEWS and KIRNEWS: Benchmarking Cross-Lingual Text Classification for Kinyarwanda and Kirundi},\n author={Niyongabo, Rubungo Andre and Qu, Hong and Kreutzer, Julia and Huang, Li},\n journal={arXiv preprint arXiv:2010.12174},\n year={2020}\n}\n", "homepage": "https://github.com/Andrews2017/KINNEWS-and-KIRNEWS-Corpus", "license": "MIT License", "features": {"label": {"num_classes": 14, "names": ["politics", "sport", "economy", "health", "entertainment", "history", "technology", "tourism", "culture", "fashion", "religion", "environment", "education", "relationship"], "names_file": null, "id": null, "_type": "ClassLabel"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "content": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kinnews_kirnews", "config_name": "kirnews_cleaned", "version": "0.0.0", "splits": {"train": {"name": "train", "num_bytes": 6629767, "num_examples": 3689, "dataset_name": "kinnews_kirnews"}, "test": {"name": "test", "num_bytes": 1570745, "num_examples": 923, "dataset_name": "kinnews_kirnews"}}, "download_checksums": {"https://github.com/saradhix/kinnews_kirnews/raw/master/KIRNEWS.zip": {"num_bytes": 5186111, "checksum": "f3e7079456567ab581ff2fd0418f9fc4002b4364142a476e79e41a581607d7f2"}}, "download_size": 5186111, "post_processing_size": null, "dataset_size": 8200512, "size_in_bytes": 13386623}}
|
dummy/kinnews_cleaned/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3718325b425bfca804f8e7c86351e573c2de08b836610127b1381279017a6189
|
3 |
+
size 13945
|
dummy/kinnews_raw/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:911970c25560583bd5e0d57a49feaeb290617c78163eb7163b4bb8023755d077
|
3 |
+
size 13945
|
dummy/kirnews_cleaned/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:46c51111c1b55103b404ffc8068dc4d9f01ae0d7f74c35b3875483d09fbe8765
|
3 |
+
size 12038
|
dummy/kirnews_raw/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0bf47269f5743051c86a189755e9bb954396b1d3acbce9dc39436c6e1f6574ad
|
3 |
+
size 12038
|
kinnews_kirnews.py
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""Kinyarwanda and Kirundi news classification datasets."""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import csv
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
_CITATION = """\
|
26 |
+
@article{niyongabo2020kinnews,
|
27 |
+
title={KINNEWS and KIRNEWS: Benchmarking Cross-Lingual Text Classification for Kinyarwanda and Kirundi},
|
28 |
+
author={Niyongabo, Rubungo Andre and Qu, Hong and Kreutzer, Julia and Huang, Li},
|
29 |
+
journal={arXiv preprint arXiv:2010.12174},
|
30 |
+
year={2020}
|
31 |
+
}
|
32 |
+
"""
|
33 |
+
|
34 |
+
_DESCRIPTION = """\
|
35 |
+
Kinyarwanda and Kirundi news classification datasets
|
36 |
+
"""
|
37 |
+
|
38 |
+
_HOMEPAGE = "https://github.com/Andrews2017/KINNEWS-and-KIRNEWS-Corpus"
|
39 |
+
_LICENSE = "MIT License"
|
40 |
+
|
41 |
+
_URLs = {
|
42 |
+
"kinnews": "https://github.com/saradhix/kinnews_kirnews/raw/master/KINNEWS.zip",
|
43 |
+
"kirnews": "https://github.com/saradhix/kinnews_kirnews/raw/master/KIRNEWS.zip",
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
class KinnewsKirnews(datasets.GeneratorBasedBuilder):
|
48 |
+
"""This is Kinyarwanda and Kirundi news dataset called KINNEWS and KIRNEWS."""
|
49 |
+
|
50 |
+
VERSION = datasets.Version("1.1.0")
|
51 |
+
|
52 |
+
BUILDER_CONFIGS = [
|
53 |
+
datasets.BuilderConfig(name="kinnews_raw", description="Dataset for Kinyarwanda language"),
|
54 |
+
datasets.BuilderConfig(name="kinnews_cleaned", description="Cleaned dataset for Kinyarwanda language"),
|
55 |
+
datasets.BuilderConfig(name="kirnews_raw", description="Dataset for Kirundi language"),
|
56 |
+
datasets.BuilderConfig(name="kirnews_cleaned", description="Cleaned dataset for Kirundi language"),
|
57 |
+
]
|
58 |
+
class_labels = [
|
59 |
+
"politics",
|
60 |
+
"sport",
|
61 |
+
"economy",
|
62 |
+
"health",
|
63 |
+
"entertainment",
|
64 |
+
"history",
|
65 |
+
"technology",
|
66 |
+
"tourism",
|
67 |
+
"culture",
|
68 |
+
"fashion",
|
69 |
+
"religion",
|
70 |
+
"environment",
|
71 |
+
"education",
|
72 |
+
"relationship",
|
73 |
+
]
|
74 |
+
label_columns = {"kinnews_raw": "kin_label", "kirnews_raw": "kir_label"}
|
75 |
+
|
76 |
+
def _info(self):
|
77 |
+
if "raw" in self.config.name:
|
78 |
+
features = datasets.Features(
|
79 |
+
{
|
80 |
+
"label": datasets.ClassLabel(names=self.class_labels),
|
81 |
+
self.label_columns[self.config.name]: datasets.Value("string"),
|
82 |
+
"en_label": datasets.Value("string"),
|
83 |
+
"url": datasets.Value("string"),
|
84 |
+
"title": datasets.Value("string"),
|
85 |
+
"content": datasets.Value("string"),
|
86 |
+
}
|
87 |
+
)
|
88 |
+
else:
|
89 |
+
features = datasets.Features(
|
90 |
+
{
|
91 |
+
"label": datasets.ClassLabel(names=self.class_labels),
|
92 |
+
"title": datasets.Value("string"),
|
93 |
+
"content": datasets.Value("string"),
|
94 |
+
}
|
95 |
+
)
|
96 |
+
return datasets.DatasetInfo(
|
97 |
+
description=_DESCRIPTION,
|
98 |
+
features=features,
|
99 |
+
supervised_keys=None,
|
100 |
+
homepage=_HOMEPAGE,
|
101 |
+
license=_LICENSE,
|
102 |
+
citation=_CITATION,
|
103 |
+
)
|
104 |
+
|
105 |
+
def _split_generators(self, dl_manager):
|
106 |
+
"""Returns SplitGenerators."""
|
107 |
+
lang, kind = self.config.name.split("_")
|
108 |
+
data_dir = dl_manager.download_and_extract(_URLs[lang])
|
109 |
+
lang_dir = lang.upper()
|
110 |
+
|
111 |
+
return [
|
112 |
+
datasets.SplitGenerator(
|
113 |
+
name=datasets.Split.TRAIN,
|
114 |
+
gen_kwargs={
|
115 |
+
"filepath": os.path.join(data_dir, lang_dir, kind, "train.csv"),
|
116 |
+
"split": "train",
|
117 |
+
},
|
118 |
+
),
|
119 |
+
datasets.SplitGenerator(
|
120 |
+
name=datasets.Split.TEST,
|
121 |
+
gen_kwargs={"filepath": os.path.join(data_dir, lang_dir, kind, "test.csv"), "split": "test"},
|
122 |
+
),
|
123 |
+
]
|
124 |
+
|
125 |
+
def _generate_examples(self, filepath, split):
|
126 |
+
""" Yields examples. """
|
127 |
+
|
128 |
+
with open(filepath, encoding="utf-8") as csv_file:
|
129 |
+
csv_reader = csv.reader(
|
130 |
+
csv_file, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True
|
131 |
+
)
|
132 |
+
next(csv_reader)
|
133 |
+
|
134 |
+
for id_, row in enumerate(csv_reader):
|
135 |
+
if "raw" in self.config.name:
|
136 |
+
label, k_label, en_label, url, title, content = row
|
137 |
+
yield id_, {
|
138 |
+
"label": self.class_labels[int(label) - 1],
|
139 |
+
self.label_columns[self.config.name]: k_label,
|
140 |
+
"en_label": en_label,
|
141 |
+
"url": url,
|
142 |
+
"title": title,
|
143 |
+
"content": content,
|
144 |
+
}
|
145 |
+
else:
|
146 |
+
label, title, content = row
|
147 |
+
yield id_, {
|
148 |
+
"label": self.class_labels[int(label) - 1],
|
149 |
+
"title": title,
|
150 |
+
"content": content,
|
151 |
+
}
|