Datasets:

Modalities:
Text
Formats:
csv
Size:
< 1K
Libraries:
Datasets
pandas
License:
horychtom commited on
Commit
294e592
1 Parent(s): 6b01637

Create news-unfold-dataset.py

Browse files
Files changed (1) hide show
  1. news-unfold-dataset.py +47 -0
news-unfold-dataset.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import absolute_import, division, print_function
2
+
3
+ import datasets
4
+ import os
5
+ import pandas as pd
6
+ from ast import literal_eval
7
+
8
+ _DESCRIPTION = "dataset focused on media bias classification"
9
+
10
+ _URL = "news_unfold_new_sentences_final.csv"
11
+ _HOMEPAGE = ""
12
+ _LICENSE = ""
13
+
14
+ class BABE(datasets.GeneratorBasedBuilder):
15
+
16
+ def _info(self):
17
+ return datasets.DatasetInfo(
18
+ description=_DESCRIPTION,
19
+ citation=_CITATION,
20
+ features=datasets.Features(
21
+ {"text":datasets.Value("string"),
22
+ "news_link":datasets.Value("string"),
23
+ "outlet":datasets.Value("string"),
24
+ "topic":datasets.Value("string"),
25
+ "label":datasets.Value("int16")}
26
+ )
27
+ )
28
+
29
+
30
+
31
+ def _split_generators(self, dl_manager):
32
+ path = dl_manager.download_and_extract(_URL)
33
+
34
+ # There is no predefined train/val/test split for this dataset.
35
+ return [
36
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"file_path": path}),
37
+ ]
38
+
39
+ def _generate_examples(self, file_path):
40
+ df = pd.read_csv(file_path)
41
+
42
+ for i, row in df.iterrows():
43
+ yield i, {"text":row['text'],
44
+ "label":row['label'],
45
+ "news_link":str(row['news_link']),
46
+ "outlet":str(row['outlet']),
47
+ "topic":str(row['topic'])}