Delete loading script
Browse files- urdu_fake_news.py +0 -97
urdu_fake_news.py
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
"""Urdu Fake News Dataset"""
|
2 |
-
|
3 |
-
|
4 |
-
import glob
|
5 |
-
import os
|
6 |
-
|
7 |
-
import datasets
|
8 |
-
|
9 |
-
|
10 |
-
_CITATION = """
|
11 |
-
@article{MaazUrdufake2020,
|
12 |
-
author = {Amjad, Maaz and Sidorov, Grigori and Zhila, Alisa and G’{o}mez-Adorno, Helena and Voronkov, Ilia and Gelbukh, Alexander},
|
13 |
-
title = {Bend the Truth: A Benchmark Dataset for Fake News Detection in Urdu and Its Evaluation},
|
14 |
-
journal={Journal of Intelligent & Fuzzy Systems},
|
15 |
-
volume={39},
|
16 |
-
number={2},
|
17 |
-
pages={2457-2469},
|
18 |
-
doi = {10.3233/JIFS-179905},
|
19 |
-
year={2020},
|
20 |
-
publisher={IOS Press}
|
21 |
-
}
|
22 |
-
"""
|
23 |
-
|
24 |
-
_DESCRIPTION = """
|
25 |
-
Urdu fake news datasets that contain news of 5 different news domains.
|
26 |
-
These domains are Sports, Health, Technology, Entertainment, and Business.
|
27 |
-
The real news are collected by combining manual approaches.
|
28 |
-
"""
|
29 |
-
|
30 |
-
_URL = "https://github.com/MaazAmjad/Datasets-for-Urdu-news/blob/master/"
|
31 |
-
_URL += "Urdu%20Fake%20News%20Dataset.zip?raw=true"
|
32 |
-
|
33 |
-
|
34 |
-
class UrduFakeNews(datasets.GeneratorBasedBuilder):
|
35 |
-
VERSION = datasets.Version("1.0.0")
|
36 |
-
|
37 |
-
category_list = [
|
38 |
-
"bus",
|
39 |
-
"hlth",
|
40 |
-
"sp",
|
41 |
-
"tch",
|
42 |
-
"sbz",
|
43 |
-
]
|
44 |
-
|
45 |
-
def _info(self):
|
46 |
-
labels_list = ["Fake", "Real"]
|
47 |
-
|
48 |
-
return datasets.DatasetInfo(
|
49 |
-
description=_DESCRIPTION,
|
50 |
-
features=datasets.Features(
|
51 |
-
{
|
52 |
-
"news": datasets.Value("string"),
|
53 |
-
"label": datasets.ClassLabel(names=labels_list),
|
54 |
-
"category": datasets.ClassLabel(names=self.category_list),
|
55 |
-
}
|
56 |
-
),
|
57 |
-
homepage="https://github.com/MaazAmjad/Datasets-for-Urdu-news",
|
58 |
-
citation=_CITATION,
|
59 |
-
)
|
60 |
-
|
61 |
-
def _split_generators(self, dl_manager):
|
62 |
-
"""Returns SplitGenerators."""
|
63 |
-
dl_path = dl_manager.download_and_extract(_URL)
|
64 |
-
input_path = os.path.join(dl_path, "1.Corpus")
|
65 |
-
return [
|
66 |
-
datasets.SplitGenerator(
|
67 |
-
name=datasets.Split.TRAIN,
|
68 |
-
gen_kwargs={"pattern": os.path.join(input_path, "Train", "*", "*.txt")},
|
69 |
-
),
|
70 |
-
datasets.SplitGenerator(
|
71 |
-
name=datasets.Split.TEST,
|
72 |
-
gen_kwargs={"pattern": os.path.join(input_path, "Test", "*", "*.txt")},
|
73 |
-
),
|
74 |
-
]
|
75 |
-
|
76 |
-
def _generate_examples(self, pattern=None):
|
77 |
-
"""Yields examples."""
|
78 |
-
for filename in sorted(glob.glob(pattern)):
|
79 |
-
|
80 |
-
with open(filename, encoding="utf-8") as f:
|
81 |
-
news = ""
|
82 |
-
for line in f:
|
83 |
-
if line == "\n":
|
84 |
-
continue
|
85 |
-
news += line
|
86 |
-
|
87 |
-
name = os.path.basename(filename)
|
88 |
-
key = name.rstrip(".txt")
|
89 |
-
|
90 |
-
_class = 1 if ("Real" in filename) else 0
|
91 |
-
_class_name = "Real" if ("Real" in filename) else "Fake"
|
92 |
-
category = "".join([i for i in key if not i.isdigit()])
|
93 |
-
if category == "":
|
94 |
-
continue
|
95 |
-
category = self.category_list.index(category)
|
96 |
-
|
97 |
-
yield f"{_class_name}_{key}", {"news": news, "label": _class, "category": category}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|