@thien commited on
Commit
6966631
•
1 Parent(s): 1b9a201

pre-compile dataset for convenience

Browse files
README.md CHANGED
@@ -10,18 +10,46 @@ tags:
10
  pretty_name: Political Slant Tweets Dataset
11
  size_categories:
12
  - 100K<n<1M
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  ---
14
 
15
- ## Political Slant Tweets Dataset
16
 
17
  Political slant transfer dataset. Contains two classes of political tweets between Democratic and Republican Politicans. This dataset can be used for classification tasks.
18
 
19
- This is taken directly from:
20
 
21
  http://tts.speech.cs.cmu.edu/style_models/political_data.tar
22
  tar -xvf political_data.tar
23
 
24
- I can't take credit for this dataset; this is largely the work of Prabhumoye et al. This is simply a Wrapper for that dataset. See References below.
25
 
26
  ## Reference
27
 
 
10
  pretty_name: Political Slant Tweets Dataset
11
  size_categories:
12
  - 100K<n<1M
13
+ configs:
14
+ - config_name: style
15
+ default: true
16
+ data_files:
17
+ - split: train
18
+ path:
19
+ - "political_data/democratic_only.train.en.parquet"
20
+ - "political_data/republican_only.train.en.parquet"
21
+ - split: eval
22
+ path:
23
+ - "political_data/democratic_only.dev.en.parquet"
24
+ - "political_data/republican_only.dev.en.parquet"
25
+ - split: test
26
+ path:
27
+ - "political_data/democratic_only.test.en.parquet"
28
+ - "political_data/republican_only.test.en.parquet"
29
+ - config_name: classifier
30
+ data_files:
31
+ - split: train
32
+ path: "political_data/classtrain.txt.parquet"
33
+ - split: eval
34
+ path:
35
+ - "political_data/democratic_only.dev.en.parquet"
36
+ - "political_data/republican_only.dev.en.parquet"
37
+ - split: test
38
+ path:
39
+ - "political_data/democratic_only.test.en.parquet"
40
+ - "political_data/republican_only.test.en.parquet"
41
  ---
42
 
43
+ # Political Slant Tweets Dataset
44
 
45
  Political slant transfer dataset. Contains two classes of political tweets between Democratic and Republican Politicans. This dataset can be used for classification tasks.
46
 
47
+ This is taken directly from the below:
48
 
49
  http://tts.speech.cs.cmu.edu/style_models/political_data.tar
50
  tar -xvf political_data.tar
51
 
52
+ I can't take credit for this dataset; this is largely the work of Prabhumoye et al. (See References below). I have detokenized (via MosesDetokenizer), and added relevant labels for creature comforts.
53
 
54
  ## Reference
55
 
political.py DELETED
@@ -1,134 +0,0 @@
1
- import os
2
- from pathlib import Path
3
- import datasets
4
- from typing import List
5
-
6
- STYLE, CLASSIFIER = "style", "classifier"
7
- _CITATION = """\
8
- @inproceedings{style_transfer_acl18,
9
- title={Style Transfer Through Back-Translation},
10
- author={Prabhumoye, Shrimai and Tsvetkov, Yulia and Salakhutdinov, Ruslan and Black, Alan W},
11
- year={2018},
12
- booktitle={Proc. ACL}
13
- }
14
- """
15
-
16
- _DESCRIPTION = """\
17
- Political slant transfer dataset. Contains two classes of political tweets between Democratic and Republican Politicans. This dataset can be used for classification tasks.
18
- """
19
- _HOMEPAGE = "https://github.com/shrimai/Style-Transfer-Through-Back-Translation"
20
- _LICENSE = "" # could not find.
21
-
22
-
23
- class PoliticalDataset(datasets.GeneratorBasedBuilder):
24
- VERSION = datasets.Version("1.0.0")
25
- DEFAULT_CONFIG_NAME = STYLE
26
-
27
- BUILDER_CONFIGS = [
28
- datasets.BuilderConfig(
29
- name=STYLE,
30
- version=VERSION,
31
- description="Political Tweets Dataset, used for Style Transfer tasks.",
32
- ),
33
- datasets.BuilderConfig(
34
- name=CLASSIFIER,
35
- version=VERSION,
36
- description="Political Tweets Dataset, Used for classification tasks.",
37
- ),
38
- ]
39
-
40
- def _info(self):
41
- features = datasets.Features(
42
- {
43
- "text": datasets.Value("string"),
44
- "label": datasets.Value("string"),
45
- }
46
- )
47
- return datasets.DatasetInfo(
48
- description=_DESCRIPTION,
49
- features=features,
50
- supervised_keys=("text", "label"),
51
- homepage=_HOMEPAGE,
52
- license=_LICENSE,
53
- citation=_CITATION,
54
- )
55
-
56
- def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
57
- data_dir = "political_data"
58
-
59
- splits: List[datasets.SplitGenerator] = []
60
- if self.config.name == STYLE:
61
- splits.append(
62
- datasets.SplitGenerator(
63
- name=datasets.Split.TRAIN,
64
- gen_kwargs={
65
- "filepaths": [
66
- os.path.join(data_dir, "republican_only.train.en"),
67
- os.path.join(data_dir, "democratic_only.train.en"),
68
- ],
69
- "split": "train",
70
- },
71
- )
72
- )
73
- else:
74
- splits.append(
75
- datasets.SplitGenerator(
76
- name=datasets.Split.TRAIN,
77
- gen_kwargs={
78
- "filepaths": [os.path.join(data_dir, "classtrain.txt")],
79
- "split": "train",
80
- },
81
- )
82
- )
83
-
84
- splits += [
85
- datasets.SplitGenerator(
86
- name=datasets.Split.VALIDATION,
87
- gen_kwargs={
88
- "filepaths": [
89
- os.path.join(data_dir, "republican_only.dev.en"),
90
- os.path.join(data_dir, "democratic_only.dev.en"),
91
- ],
92
- "split": "dev",
93
- },
94
- ),
95
- datasets.SplitGenerator(
96
- name=datasets.Split.TEST,
97
- gen_kwargs={
98
- "filepaths": [
99
- os.path.join(data_dir, "republican_only.test.en"),
100
- os.path.join(data_dir, "democratic_only.test.en"),
101
- ],
102
- "split": "test",
103
- },
104
- ),
105
- ]
106
- return splits
107
-
108
- def _generate_examples(self, filepaths: List[str], split: str):
109
- for filepath in filepaths:
110
- filename = Path(filepath).name
111
- label = filename.split(".")[0].split("_")[0]
112
- with open(filepath, encoding="utf-8") as f:
113
- for key, row in enumerate(f):
114
- text = row.strip()
115
- if split != "test":
116
- # label only exists in train/eval files.
117
- text = text.split()
118
- label, text = text[0], text[1:]
119
- text = " ".join(text)
120
-
121
- yield (
122
- key,
123
- {"text": text, "label": label},
124
- )
125
-
126
-
127
- if __name__ == "__main__":
128
- from tqdm import tqdm
129
-
130
- dataset = PoliticalDataset(config_name="classifier")
131
- dataset = dataset.as_streaming_dataset()
132
- print(dataset)
133
- for row in tqdm(dataset["train"]):
134
- row["text"] = "hello"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
political_data/classtrain.txt DELETED
The diff for this file is too large to render. See raw diff
 
political_data/{republican_only.test.en → classtrain.txt.parquet} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:15ca942110dcb8d0690ddd8b292d1284bab974087a3bfef5113256ecdb05a38f
3
- size 2292494
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8423df1e42eddeecc99746cd80147a53c879162b9b0a66b3be29b68ea1c490e
3
+ size 9286667
political_data/{republican_only.dev.en → democratic_only.dev.en.parquet} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:da2a8ac301562b521dc9922d9635ca030ee5e6dd3846183ae5848266df55ead9
3
- size 186309
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a510f3e98efff0cf7654afaf0394312d0a1cc0e389fd079e722dce113c48f1dd
3
+ size 237800
political_data/{democratic_only.test.en → democratic_only.test.en.parquet} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:100b382aefbde27b34bb00bbd14fe5c187c16bbdc687557c598111746ab7cc46
3
- size 2358533
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2cd0152ce0ca404ef2f79d3cb6864c32d3693c42ac545c2d74943b083f335163
3
+ size 3258396
political_data/{democratic_only.train.en → democratic_only.train.en.parquet} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3705adeecd8758859f6b1729ea55cdd327efdbde8b00938d2477b139f45ecc66
3
- size 25559362
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:401e69d0a996fd5e3388fb32bdec193ea690a03efabb451cbe956fb1141ee58b
3
+ size 30826508
political_data/{democratic_only.dev.en → republican_only.dev.en.parquet} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:67b0e9358ff8b75a49c761ee3c0f4491fe85cadb486d535d29f814decd77f5b2
3
- size 186804
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98c8bd9f34bd2d355d427cfb8a9b07b49194b01d2299170225328ffc78dd1d09
3
+ size 231669
political_data/republican_only.test.en.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1957a66d2d8e5930e9602da16902fe997b2e32016d30622e4019aa8b072e4874
3
+ size 3117740
political_data/republican_only.train.en DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c8e609ecabcaee7d1fb96c12a523b9259718b5f4a00a323d24bfdea57457944e
3
- size 25145176
 
 
 
 
political_data/republican_only.train.en.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:96e15a9e566e341274f5043ffb4bc976c1ee6f5e7d656c20aae31517a947a51e
3
+ size 29691039