Datasets:
Delete mbib-base.py
Browse files- mbib-base.py +0 -44
mbib-base.py
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
import datasets
|
2 |
-
import pandas as pd
|
3 |
-
|
4 |
-
|
5 |
-
_MBIB_DESCRIPTION = 'bla bla'
|
6 |
-
|
7 |
-
class MBIBConfig(datasets.BuilderConfig):
|
8 |
-
def __init__(self,data_dir,**kwargs):
|
9 |
-
super(MBIBConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
|
10 |
-
self.data_dir = data_dir
|
11 |
-
|
12 |
-
|
13 |
-
class MBIB(datasets.GeneratorBasedBuilder):
|
14 |
-
BUILDER_CONFIGS = [
|
15 |
-
MBIBConfig(name="cognitive-bias",data_dir="mbib-aggregated/cognitive-bias.csv"),
|
16 |
-
MBIBConfig(name="fake-news",data_dir="mbib-aggregated/fake-news.csv"),
|
17 |
-
MBIBConfig(name="gender-bias",data_dir="mbib-aggregated/gender-bias.csv"),
|
18 |
-
MBIBConfig(name="hate-speech",data_dir="mbib-aggregated/hate-speech.csv"),
|
19 |
-
MBIBConfig(name="linguistic-bias",data_dir="mbib-aggregated/linguistic-bias.csv"),
|
20 |
-
MBIBConfig(name="political-bias",data_dir="mbib-aggregated/political-bias.csv"),
|
21 |
-
MBIBConfig(name="racial-bias",data_dir="mbib-aggregated/racial-bias.csv"),
|
22 |
-
MBIBConfig(name="text-level-bias",data_dir="mbib-aggregated/text-level-bias.csv")]
|
23 |
-
|
24 |
-
def _info(self):
|
25 |
-
features=datasets.Features(
|
26 |
-
{"text":datasets.Value("string"),
|
27 |
-
"label":datasets.Value("int32")}
|
28 |
-
)
|
29 |
-
|
30 |
-
return datasets.DatasetInfo(
|
31 |
-
description=_MBIB_DESCRIPTION,
|
32 |
-
features=features
|
33 |
-
)
|
34 |
-
|
35 |
-
def _split_generators(self, dl_manager):
|
36 |
-
data_file = dl_manager.download(self.config.data_dir)
|
37 |
-
return [datasets.SplitGenerator(name=datasets.Split.TRAIN,gen_kwargs={"data_dir": data_file})]
|
38 |
-
|
39 |
-
|
40 |
-
def _generate_examples(self, data_dir):
|
41 |
-
df = pd.read_csv(data_dir)[['text','label']].sample(frac=1)
|
42 |
-
|
43 |
-
for i, row in df.iterrows():
|
44 |
-
yield i, {"text":row['text'],"label":row['label']}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|